forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShowBuildMenu.sh
executable file
·233 lines (201 loc) · 4.56 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
#!/bin/sh
cd "$(dirname "$0")"
SCRIPT_PATH="$(pwd)"
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=""
async_generator_version=""
if [ ! -f $BUILD_TOOL_PATH ]
then
cd ./Tools/BuildTool
dotnet build BuildTool.sln -c Release -o bin
fi
cd "$SCRIPT_PATH"
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 net6.0
dotnet test ./src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj -f net6.0
mainMenu
}
generateAsync(){
cd src
dotnet tool restore
dotnet restore ./NHibernate.sln
dotnet async-generator
cd ..
mainMenu
}
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