forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShowBuildMenu.sh
executable file
·261 lines (220 loc) · 5.29 KB
/
ShowBuildMenu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#!/bin/sh
BUILD_TOOL_PATH="./Tools/BuildTool/bin/BuildTool.dll"
BUILD_TOOL="dotnet $BUILD_TOOL_PATH"
AVAILABLE_CONFIGURATIONS="available-test-configurations"
CONFIG_NAME=""
TEST_PLATFORM=""
LIB_FILES=""
LIB_FILES2=""
CURRENT_CONFIGURATION="./current-test-configuration"
OPTION=0
async_generator_path=""
if [ ! -f $BUILD_TOOL_PATH ]
then
dotnet build ./Tools/BuildTool/BuildTool.sln -c Release -o bin
fi
buildDebug(){
dotnet build ./src/NHibernate.sln
echo "."
echo "Assuming the build succeeded, your results will be in the build folder."
echo "."
mainMenu
}
buildRelease(){
dotnet build ./src/NHibernate.sln -c Release
echo "."
echo "Assuming the build succeeded, your results will be in the build folder."
echo "."
mainMenu
}
testActivate(){
FILE_TEMP="folder.tmp"
$BUILD_TOOL pick-folder $AVAILABLE_CONFIGURATIONS $FILE_TEMP "Which test configuration should be activated?"
if [ -d $CURRENT_CONFIGURATION ]
then
rm -r $CURRENT_CONFIGURATION/
fi
CURRENT_FOLDER=$(pwd)
INFORMATION=$(cat $CURRENT_FOLDER/$FILE_TEMP)
cp -r $INFORMATION/ $CURRENT_CONFIGURATION
rm $FILE_TEMP
echo "Configuration activated."
mainMenu
}
testSetupGeneric() {
echo "Enter a name for your test configuration or press enter to use default name:"
read CFGNAME
if [ $CFGNAME = ""]
then
CFGNAME="$CONFIG_NAME-$TEST_PLATFORM"
echo $CFGNAME
fi
mkdir -p $AVAILABLE_CONFIGURATIONS/$CFGNAME
if [ ! "$LIB_FILES" ]
then
cp $LIB_FILES $AVAILABLE_CONFIGURATIONS/$CFGNAME
if [ ! "$LIB_FILES2" ]
then
cp $LIB_FILES2 $AVAILABLE_CONFIGURATIONS/$CFGNAME
fi
fi
cp "src/NHibernate.Config.Templates/$CONFIG_NAME.cfg.xml" "$AVAILABLE_CONFIGURATIONS/$CFGNAME/hibernate.cfg.xml"
echo "Done setting up files. Please edit the connection string in file:"
echo "$AVAILABLE_CONFIGURATIONS/$CFGNAME/hibernate.cfg.xml"
echo "When you're done, don't forget to activate the configuration through the menu."
mainMenu
}
testSetupSqlServer() {
CONFIG_NAME="MSSQL"
TEST_PLATFORM="AnyCPU"
LIB_FILES=""
LIB_FILES2=""
testSetupGeneric
}
testSetupFirebird() {
CONFIG_NAME="FireBird"
TEST_PLATFORM="AnyCPU"
LIB_FILES=""
LIB_FILES2=""
testSetupGeneric
}
testSetupSqlite() {
CONFIG_NAME="SQLite"
TEST_PLATFORM="AnyCPU"
LIB_FILES=""
LIB_FILES2=""e
testSetupGeneric
}
testSetupPostgresql() {
CONFIG_NAME="PostgreSQL"
TEST_PLATFORM="AnyCPU"
LIB_FILES=""
LIB_FILES2=""
testSetupGeneric
}
testSetupMysql() {
CONFIG_NAME="MySql"
TEST_PLATFORM="AnyCPU"
LIB_FILES=""
LIB_FILES2=""
testSetupGeneric
}
testSetupMenu() {
echo "A. Add a test configuration for SQL Server."
echo "B. Add a test configuration for Firebird."
echo "C. Add a test configuration for SQLite."
echo "D. Add a test configuration for PostgreSQL."
echo "E. Add a test configuration for MySql."
echo "."
echo "X. Exit to main menu."
echo "."
$BUILD_TOOL prompt ABCDEX
OPTION=$?
if [ $OPTION -eq 5 ]
then
echo "Main menu"
mainMenu
elif [ $OPTION -eq 4 ]
then
echo "MySQL"
testSetupMysql
mainMenu
elif [ $OPTION -eq 3 ]
then
echo "PostgreSQL"
testSetupPostgresql
mainMenu
elif [ $OPTION -eq 2 ]
then
echo "Sqlite"
testSetupSqlite
mainMenu
elif [ $OPTION -eq 1 ]
then
echo "Firebird"
testSetupFirebird
mainMenu
elif [ $OPTION -eq 0 ]
then
echo "SQL Server"
testSetupSqlServer
mainMenu
fi
}
testRun(){
dotnet test ./src/NHibernate.Test/NHibernate.Test.csproj -f netcoreapp2.0
dotnet test ./src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj -f netcoreapp2.0
mainMenu
}
generateAsync(){
dotnet msbuild /t:Restore ./src/NHibernate.sln
getAsyncGeneratorPath
cd src
mono ../"$async_generator_path"
cd ..
mainMenu
}
getAsyncGeneratorPath(){
if [ "$async_generator_path" ]
then
return
fi
cd Tools
if [ ! -f nuget.exe ]
then
wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
fi
async_generator_path="CSharpAsyncGenerator.CommandLine.$(cat packages.config | grep id=\"CSharpAsyncGenerator.CommandLine | cut -d\" -f4)/tools"
if [ ! -d $async_generator_path ]
then
mono nuget.exe install
fi
if [ ! -f $async_generator_path/SQLitePCLRaw.core.dll ]
then
# This "hidden" dependency causes a failure under some Mono setup, add it explicitly
mono nuget.exe install SQLitePCLRaw.core -Version 1.0.0
cp SQLitePCLRaw.core.1.0.0/lib/net45/SQLitePCLRaw.core.dll $async_generator_path/
fi
async_generator_path="Tools/$async_generator_path/AsyncGenerator.CommandLine.exe"
cd ..
}
mainMenu() {
echo "========================= NHIBERNATE BUILD MENU =========================="
echo "--- TESTING ---"
echo "A. (Step 1) Set up a new test configuration for a particular database."
echo "B. (Step 2) Activate a test configuration."
echo "C. (Step 3) Run tests."
echo "."
echo "--- BUILD ---"
echo "E. Build NHibernate (Debug)"
echo "F. Build NHibernate (Release)"
echo "."
echo "--- Code generation ---"
echo "H. Generate async code (Generates files in Async sub-folders)"
echo "."
echo "--- Exit ---"
echo "X. Make the beautiful build menu go away."
echo "."
$BUILD_TOOL prompt ABCEFHX
OPTION=$?
if [ $OPTION -eq 5 ]
then
generateAsync
elif [ $OPTION -eq 4 ]
then
buildRelease
elif [ $OPTION -eq 3 ]
then
buildDebug
elif [ $OPTION -eq 2 ]
then
testRun
elif [ $OPTION -eq 1 ]
then
testActivate
elif [ $OPTION -eq 0 ]
then
testSetupMenu
fi
}
mainMenu