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