sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
sqlite / tool / build-all-msvc.bat
| 1 | @ECHO OFF |
| 2 | |
| 3 | :: |
| 4 | :: build-all-msvc.bat -- |
| 5 | :: |
| 6 | :: Multi-Platform Build Tool for MSVC |
| 7 | :: |
| 8 | |
| 9 | REM |
| 10 | REM This batch script is used to build the SQLite DLL for multiple platforms |
| 11 | REM and configurations using MSVC. The built SQLite DLLs, their associated |
| 12 | REM import libraries, and optionally their symbols files, are placed within |
| 13 | REM the directory specified on the command line, in sub-directories named for |
| 14 | REM their respective platforms and configurations. This batch script must be |
| 15 | REM run from inside a Visual Studio Command Prompt for the desired version of |
| 16 | REM Visual Studio ^(the initial platform configured for the command prompt does |
| 17 | REM not really matter^). Exactly one command line argument is required, the |
| 18 | REM name of an existing directory to be used as the final destination directory |
| 19 | REM for the generated output files, which will be placed in sub-directories |
| 20 | REM created therein. Ideally, the directory specified should be empty. |
| 21 | REM |
| 22 | REM Example: |
| 23 | REM |
| 24 | REM CD /D C:\dev\sqlite\core |
| 25 | REM CALL tool\build-all-msvc.bat C:\Temp |
| 26 | REM |
| 27 | REM In the example above, "C:\dev\sqlite\core" represents the root of the |
| 28 | REM source tree for SQLite and "C:\Temp" represents the final destination |
| 29 | REM directory for the generated output files. |
| 30 | REM |
| 31 | REM Please note that the SQLite build process performed by the Makefile |
| 32 | REM associated with this batch script requires a Tcl shell to be present |
| 33 | REM in a directory contained in the PATH environment variable unless a |
| 34 | REM pre-existing amalgamation file is used. |
| 35 | REM |
| 36 | REM There are several environment variables that may be set to modify the |
| 37 | REM behavior of this batch script and its associated Makefile. The list of |
| 38 | REM platforms to build may be overriden by using the PLATFORMS environment |
| 39 | REM variable, which should contain a list of platforms ^(e.g. x86 x86_amd64 |
| 40 | REM x86_arm^). All platforms must be supported by the version of Visual Studio |
| 41 | REM being used. The list of configurations to build may be overridden by |
| 42 | REM setting the CONFIGURATIONS environment variable, which should contain a |
| 43 | REM list of configurations to build ^(e.g. Debug Retail^). Neither of these |
| 44 | REM variable values may contain any double quotes, surrounding or embedded. |
| 45 | REM |
| 46 | REM Finally, the NCRTLIBPATH, NUCRTLIBPATH, and NSDKLIBPATH environment |
| 47 | REM variables may be set to specify the location of the CRT, Universal CRT, and |
| 48 | REM Windows SDK, respectively, that may be needed to compile executables native |
| 49 | REM to the architecture of the build machine during any cross-compilation that |
| 50 | REM may be necessary, depending on the platforms to be built. These values in |
| 51 | REM these three variables should be surrounded by double quotes if they contain |
| 52 | REM spaces. |
| 53 | REM |
| 54 | REM There are a few other environment variables that impact the build process |
| 55 | REM when set ^(to anything^), they are: |
| 56 | REM |
| 57 | REM USE_AUTOCONF_MAKEFILE |
| 58 | REM |
| 59 | REM When set, the "autoconf" Makefile for MSVC will be used instead of the main |
| 60 | REM Makefile for MSVC. It must exist at "%ROOT%\autoconf\Makefile.msc". |
| 61 | REM |
| 62 | REM NOCLEAN |
| 63 | REM |
| 64 | REM When set, the "clean" target will not be used during each build iteration. |
| 65 | REM However, the target binaries, if any, will still be deleted manually prior |
| 66 | REM to being rebuilt. Setting this environment variable is only rarely needed |
| 67 | REM and could cause issues in some circumstances; therefore, setting it is not |
| 68 | REM recommended. |
| 69 | REM |
| 70 | REM NOSYMBOLS |
| 71 | REM |
| 72 | REM When set, copying of symbol files ^(*.pdb^) created during the build will |
| 73 | REM be skipped and they will not appear in the final destination directory. |
| 74 | REM Setting this environment variable is never strictly needed and could cause |
| 75 | REM issues in some circumstances; therefore, setting it is not recommended. |
| 76 | REM |
| 77 | REM NOMEMDEBUG |
| 78 | REM |
| 79 | REM When set, disables use of MEMDEBUG when building binaries for the "Debug" |
| 80 | REM configuration. |
| 81 | REM |
| 82 | REM BUILD_ALL_SHELL |
| 83 | REM |
| 84 | REM When set, the command line shell will be built for each selected platform |
| 85 | REM and configuration as well. In addition, the command line shell binaries |
| 86 | REM will be copied, with their symbols, to the final destination directory. |
| 87 | REM |
| 88 | REM USE_WINV63_NSDKLIBPATH |
| 89 | REM |
| 90 | REM When set, modifies how the NSDKLIBPATH environment variable is built, based |
| 91 | REM on the WindowsSdkDir environment variable. It forces this batch script to |
| 92 | REM assume the Windows 8.1 SDK location should be used. |
| 93 | REM |
| 94 | REM USE_WINV100_NSDKLIBPATH |
| 95 | REM |
| 96 | REM When set, modifies how the NSDKLIBPATH environment variable is built, based |
| 97 | REM on the WindowsSdkDir environment variable. It causes this batch script to |
| 98 | REM assume the Windows 10.0 SDK location should be used. |
| 99 | REM |
| 100 | REM NMAKE_ARGS |
| 101 | REM NMAKE_ARGS_DEBUG |
| 102 | REM NMAKE_ARGS_RETAIL |
| 103 | REM |
| 104 | REM When set, these values are expanded and passed to the NMAKE command line, |
| 105 | REM after its other arguments. These may be used to specify additional NMAKE |
| 106 | REM options, for example: |
| 107 | REM |
| 108 | REM SET NMAKE_ARGS_DEBUG=MEMDEBUG=1 |
| 109 | REM SET NMAKE_ARGS_RETAIL=WIN32HEAP=1 |
| 110 | REM |
| 111 | REM Using the above command before running this tool will cause the compiled |
| 112 | REM binaries to target the WinRT environment, which provides a subset of the |
| 113 | REM Win32 API. |
| 114 | REM |
| 115 | REM DLL_FILE_NAME |
| 116 | REM DLL_PDB_FILE_NAME |
| 117 | REM LIB_FILE_NAME |
| 118 | REM EXE_FILE_NAME |
| 119 | REM EXE_PDB_FILE_NAME |
| 120 | REM |
| 121 | REM When set, these values will override the associated target file name used |
| 122 | REM for the build. |
| 123 | REM |
| 124 | SETLOCAL |
| 125 | |
| 126 | REM SET __ECHO=ECHO |
| 127 | REM SET __ECHO2=ECHO |
| 128 | REM SET __ECHO3=ECHO |
| 129 | IF NOT DEFINED _AECHO (SET _AECHO=REM) |
| 130 | IF NOT DEFINED _CECHO (SET _CECHO=REM) |
| 131 | IF NOT DEFINED _CECHO2 (SET _CECHO2=REM) |
| 132 | IF NOT DEFINED _CECHO3 (SET _CECHO3=REM) |
| 133 | IF NOT DEFINED _VECHO (SET _VECHO=REM) |
| 134 | |
| 135 | SET REDIRECT=^> |
| 136 | IF DEFINED __ECHO SET REDIRECT=^^^> |
| 137 | |
| 138 | %_AECHO% Running %0 %* |
| 139 | |
| 140 | REM SET DFLAGS=/L |
| 141 | |
| 142 | %_VECHO% DFlags = '%DFLAGS%' |
| 143 | |
| 144 | SET FFLAGS=/V /F /G /H /I /R /Y /Z |
| 145 | |
| 146 | %_VECHO% FFlags = '%FFLAGS%' |
| 147 | |
| 148 | SET ROOT=%~dp0\.. |
| 149 | SET ROOT=%ROOT:\\=\% |
| 150 | |
| 151 | %_VECHO% Root = '%ROOT%' |
| 152 | |
| 153 | REM |
| 154 | REM NOTE: The first and only argument to this batch file should be the output |
| 155 | REM directory where the platform-specific binary directories should be |
| 156 | REM created. |
| 157 | REM |
| 158 | SET BINARYDIRECTORY=%1 |
| 159 | |
| 160 | IF NOT DEFINED BINARYDIRECTORY ( |
| 161 | GOTO usage |
| 162 | ) |
| 163 | |
| 164 | %_VECHO% BinaryDirectory = '%BINARYDIRECTORY%' |
| 165 | |
| 166 | SET DUMMY=%2 |
| 167 | |
| 168 | IF DEFINED DUMMY ( |
| 169 | GOTO usage |
| 170 | ) |
| 171 | |
| 172 | REM |
| 173 | REM NOTE: From this point, we need a clean error level. Reset it now. |
| 174 | REM |
| 175 | CALL :fn_ResetErrorLevel |
| 176 | |
| 177 | REM |
| 178 | REM NOTE: Change the current directory to the root of the source tree, saving |
| 179 | REM the current directory on the directory stack. |
| 180 | REM |
| 181 | %_CECHO2% PUSHD "%ROOT%" |
| 182 | %__ECHO2% PUSHD "%ROOT%" |
| 183 | |
| 184 | IF ERRORLEVEL 1 ( |
| 185 | ECHO Could not change directory to "%ROOT%". |
| 186 | GOTO errors |
| 187 | ) |
| 188 | |
| 189 | REM |
| 190 | REM NOTE: This batch file requires the ComSpec environment variable to be set, |
| 191 | REM typically to something like "C:\Windows\System32\cmd.exe". |
| 192 | REM |
| 193 | IF NOT DEFINED ComSpec ( |
| 194 | ECHO The ComSpec environment variable must be defined. |
| 195 | GOTO errors |
| 196 | ) |
| 197 | |
| 198 | REM |
| 199 | REM NOTE: This batch file requires the VcInstallDir environment variable to be |
| 200 | REM set. Typically, this means this batch file needs to be run from an |
| 201 | REM MSVC command prompt. |
| 202 | REM |
| 203 | IF NOT DEFINED VCINSTALLDIR ( |
| 204 | ECHO The VCINSTALLDIR environment variable must be defined. |
| 205 | GOTO errors |
| 206 | ) |
| 207 | |
| 208 | REM |
| 209 | REM NOTE: If the list of platforms is not already set, use the default list. |
| 210 | REM |
| 211 | IF NOT DEFINED PLATFORMS ( |
| 212 | SET PLATFORMS=x86 x86_amd64 x86_arm |
| 213 | ) |
| 214 | |
| 215 | %_VECHO% Platforms = '%PLATFORMS%' |
| 216 | |
| 217 | REM |
| 218 | REM NOTE: If the list of configurations is not already set, use the default |
| 219 | REM list. |
| 220 | REM |
| 221 | IF NOT DEFINED CONFIGURATIONS ( |
| 222 | SET CONFIGURATIONS=Debug Retail |
| 223 | ) |
| 224 | |
| 225 | %_VECHO% Configurations = '%CONFIGURATIONS%' |
| 226 | |
| 227 | REM |
| 228 | REM NOTE: If the command used to invoke NMAKE is not already set, use the |
| 229 | REM default. |
| 230 | REM |
| 231 | IF NOT DEFINED NMAKE_CMD ( |
| 232 | IF DEFINED USE_AUTOCONF_MAKEFILE ( |
| 233 | SET NMAKE_CMD=nmake -B -f autoconf\Makefile.msc |
| 234 | ) ELSE ( |
| 235 | SET NMAKE_CMD=nmake -B -f Makefile.msc |
| 236 | ) |
| 237 | ) |
| 238 | |
| 239 | %_VECHO% NmakeCmd = '%NMAKE_CMD%' |
| 240 | %_VECHO% NmakeArgs = '%NMAKE_ARGS%' |
| 241 | %_VECHO% NmakeArgsDebug = '%NMAKE_ARGS_DEBUG%' |
| 242 | %_VECHO% NmakeArgsRetail = '%NMAKE_ARGS_RETAIL%' |
| 243 | |
| 244 | REM |
| 245 | REM NOTE: Setup environment variables to translate between the MSVC platform |
| 246 | REM names and the names to be used for the platform-specific binary |
| 247 | REM directories. |
| 248 | REM |
| 249 | SET amd64_NAME=x64 |
| 250 | SET arm_NAME=ARM |
| 251 | SET x64_NAME=x64 |
| 252 | SET x86_NAME=x86 |
| 253 | SET x86_amd64_NAME=x64 |
| 254 | SET x86_arm_NAME=ARM |
| 255 | SET x86_x64_NAME=x64 |
| 256 | |
| 257 | %_VECHO% amd64_Name = '%amd64_NAME%' |
| 258 | %_VECHO% arm_Name = '%arm_NAME%' |
| 259 | %_VECHO% x64_Name = '%x64_NAME%' |
| 260 | %_VECHO% x86_Name = '%x86_NAME%' |
| 261 | %_VECHO% x86_amd64_Name = '%x86_amd64_NAME%' |
| 262 | %_VECHO% x86_arm_Name = '%x86_arm_NAME%' |
| 263 | %_VECHO% x86_x64_Name = '%x86_x64_NAME%' |
| 264 | |
| 265 | REM |
| 266 | REM NOTE: Check for the external tools needed during the build process ^(i.e. |
| 267 | REM those that do not get compiled as part of the build process itself^) |
| 268 | REM along the PATH. |
| 269 | REM |
| 270 | IF DEFINED TCLSH_CMD ( |
| 271 | SET TCLSH_FILE=%TCLSH_CMD% |
| 272 | ) ELSE ( |
| 273 | SET TCLSH_FILE=tclsh.exe |
| 274 | ) |
| 275 | |
| 276 | FOR %%T IN (%TCLSH_FILE%) DO ( |
| 277 | SET %%T_PATH=%%~dp$PATH:T |
| 278 | ) |
| 279 | |
| 280 | REM |
| 281 | REM NOTE: A Tcl shell executable is required during the SQLite build process |
| 282 | REM unless a pre-existing amalgamation file is used. |
| 283 | REM |
| 284 | IF NOT DEFINED %TCLSH_FILE%_PATH ( |
| 285 | ECHO The Tcl shell executable "%TCLSH_FILE%" is required to be in the PATH. |
| 286 | GOTO errors |
| 287 | ) |
| 288 | |
| 289 | REM |
| 290 | REM NOTE: Setup the default names for the build targets we are creating. Any |
| 291 | REM ^(or all^) of these may end up being overridden. |
| 292 | REM |
| 293 | IF NOT DEFINED DLL_FILE_NAME ( |
| 294 | SET DLL_FILE_NAME=sqlite3.dll |
| 295 | ) |
| 296 | |
| 297 | IF NOT DEFINED DLL_PDB_FILE_NAME ( |
| 298 | SET DLL_PDB_FILE_NAME=sqlite3.pdb |
| 299 | ) |
| 300 | |
| 301 | IF NOT DEFINED LIB_FILE_NAME ( |
| 302 | SET LIB_FILE_NAME=sqlite3.lib |
| 303 | ) |
| 304 | |
| 305 | IF NOT DEFINED EXE_FILE_NAME ( |
| 306 | SET EXE_FILE_NAME=sqlite3.exe |
| 307 | ) |
| 308 | |
| 309 | IF NOT DEFINED EXE_PDB_FILE_NAME ( |
| 310 | SET EXE_PDB_FILE_NAME=sqlite3sh.pdb |
| 311 | ) |
| 312 | |
| 313 | REM |
| 314 | REM NOTE: Set the TOOLPATH variable to contain all the directories where the |
| 315 | REM external tools were found in the search above. |
| 316 | REM |
| 317 | CALL :fn_CopyVariable %TCLSH_FILE%_PATH TOOLPATH |
| 318 | |
| 319 | %_VECHO% ToolPath = '%TOOLPATH%' |
| 320 | |
| 321 | REM |
| 322 | REM NOTE: Setting the Windows SDK library path is only required for MSVC |
| 323 | REM 2012, 2013, and 2015. |
| 324 | REM |
| 325 | CALL :fn_UnsetVariable SET_NSDKLIBPATH |
| 326 | |
| 327 | REM |
| 328 | REM NOTE: Setting the Universal CRT library path is only required for MSVC |
| 329 | REM 2015. |
| 330 | REM |
| 331 | CALL :fn_UnsetVariable SET_NUCRTLIBPATH |
| 332 | |
| 333 | REM |
| 334 | REM NOTE: Check for MSVC 2012, 2013, and 2015 specially because the Windows |
| 335 | REM SDK directory handling is slightly different for those versions. |
| 336 | REM |
| 337 | IF "%VisualStudioVersion%" == "11.0" ( |
| 338 | REM |
| 339 | REM NOTE: If the Windows SDK library path has already been set, do not set |
| 340 | REM it to something else later on. |
| 341 | REM |
| 342 | IF NOT DEFINED NSDKLIBPATH ( |
| 343 | SET SET_NSDKLIBPATH=1 |
| 344 | ) |
| 345 | ) ELSE IF "%VisualStudioVersion%" == "12.0" ( |
| 346 | REM |
| 347 | REM NOTE: If the Windows SDK library path has already been set, do not set |
| 348 | REM it to something else later on. |
| 349 | REM |
| 350 | IF NOT DEFINED NSDKLIBPATH ( |
| 351 | SET SET_NSDKLIBPATH=1 |
| 352 | ) |
| 353 | ) ELSE IF "%VisualStudioVersion%" == "14.0" ( |
| 354 | REM |
| 355 | REM NOTE: If the Windows SDK library path has already been set, do not set |
| 356 | REM it to something else later on. |
| 357 | REM |
| 358 | IF NOT DEFINED NSDKLIBPATH ( |
| 359 | SET SET_NSDKLIBPATH=1 |
| 360 | ) |
| 361 | |
| 362 | REM |
| 363 | REM NOTE: If the Universal CRT library path has already been set, do not set |
| 364 | REM it to something else later on. |
| 365 | REM |
| 366 | IF NOT DEFINED NUCRTLIBPATH ( |
| 367 | SET SET_NUCRTLIBPATH=1 |
| 368 | ) |
| 369 | ) |
| 370 | |
| 371 | REM |
| 372 | REM NOTE: This is the name of the sub-directory where the UCRT libraries may |
| 373 | REM be found. It is only used when compiling against the UCRT. |
| 374 | REM |
| 375 | IF DEFINED UCRTVersion ( |
| 376 | SET NUCRTVER=%UCRTVersion% |
| 377 | ) ELSE ( |
| 378 | SET NUCRTVER=10.0.10586.0 |
| 379 | ) |
| 380 | |
| 381 | REM |
| 382 | REM NOTE: This is the name of the sub-directory where the Windows 10.0 SDK |
| 383 | REM libraries may be found. It is only used when compiling with the |
| 384 | REM Windows 10.0 SDK. |
| 385 | REM |
| 386 | IF DEFINED WindowsSDKLibVersion ( |
| 387 | SET WIN10SDKVER=%WindowsSDKLibVersion:\=% |
| 388 | ) ELSE ( |
| 389 | SET WIN10SDKVER=%NUCRTVER% |
| 390 | ) |
| 391 | |
| 392 | REM |
| 393 | REM NOTE: Check if this is the Windows Phone SDK. If so, a different batch |
| 394 | REM file is necessary to setup the build environment. Since the variable |
| 395 | REM values involved here may contain parenthesis, using GOTO instead of |
| 396 | REM an IF block is required. |
| 397 | REM |
| 398 | IF DEFINED WindowsPhoneKitDir GOTO set_vcvarsall_phone |
| 399 | SET VCVARSALL=%VCINSTALLDIR%\vcvarsall.bat |
| 400 | GOTO set_vcvarsall_done |
| 401 | :set_vcvarsall_phone |
| 402 | SET VCVARSALL=%VCINSTALLDIR%\WPSDK\WP80\vcvarsphoneall.bat |
| 403 | :set_vcvarsall_done |
| 404 | SET VCVARSALL=%VCVARSALL:\\=\% |
| 405 | |
| 406 | REM |
| 407 | REM NOTE: This is the outer loop. There should be exactly one iteration per |
| 408 | REM platform. |
| 409 | REM |
| 410 | FOR %%P IN (%PLATFORMS%) DO ( |
| 411 | REM |
| 412 | REM NOTE: Using the MSVC platform name, lookup the simpler platform name to |
| 413 | REM be used for the name of the platform-specific binary directory via |
| 414 | REM the environment variables setup earlier. |
| 415 | REM |
| 416 | CALL :fn_CopyVariable %%P_NAME PLATFORMNAME |
| 417 | |
| 418 | REM |
| 419 | REM NOTE: This is the second loop. There should be exactly one iteration. |
| 420 | REM This loop is necessary because the PlatformName environment |
| 421 | REM variable was set above and that value is needed by some of the |
| 422 | REM commands contained in the inner loop. If these commands were |
| 423 | REM directly contained in the outer loop, the PlatformName environment |
| 424 | REM variable would be stuck with its initial empty value instead. |
| 425 | REM |
| 426 | FOR /F "tokens=2* delims==" %%D IN ('SET PLATFORMNAME') DO ( |
| 427 | REM |
| 428 | REM NOTE: Attempt to clean the environment of all variables used by MSVC |
| 429 | REM and/or Visual Studio. This block may need to be updated in the |
| 430 | REM future to account for additional environment variables. |
| 431 | REM |
| 432 | CALL :fn_UnsetVariable CommandPromptType |
| 433 | CALL :fn_UnsetVariable DevEnvDir |
| 434 | CALL :fn_UnsetVariable DNX_HOME |
| 435 | CALL :fn_UnsetVariable ExtensionSdkDir |
| 436 | CALL :fn_UnsetVariable Framework35Version |
| 437 | CALL :fn_UnsetVariable Framework40Version |
| 438 | CALL :fn_UnsetVariable FrameworkDir |
| 439 | CALL :fn_UnsetVariable FrameworkDir32 |
| 440 | CALL :fn_UnsetVariable FrameworkVersion |
| 441 | CALL :fn_UnsetVariable FrameworkVersion32 |
| 442 | CALL :fn_UnsetVariable FSHARPINSTALLDIR |
| 443 | CALL :fn_UnsetVariable INCLUDE |
| 444 | CALL :fn_UnsetVariable LIB |
| 445 | CALL :fn_UnsetVariable LIBPATH |
| 446 | CALL :fn_UnsetVariable NETFXSDKDir |
| 447 | CALL :fn_UnsetVariable Platform |
| 448 | CALL :fn_UnsetVariable UCRTVersion |
| 449 | CALL :fn_UnsetVariable UniversalCRTSdkDir |
| 450 | REM CALL :fn_UnsetVariable VCINSTALLDIR |
| 451 | CALL :fn_UnsetVariable VSINSTALLDIR |
| 452 | CALL :fn_UnsetVariable WindowsLibPath |
| 453 | CALL :fn_UnsetVariable WindowsPhoneKitDir |
| 454 | CALL :fn_UnsetVariable WindowsSdkDir |
| 455 | CALL :fn_UnsetVariable WindowsSdkDir_35 |
| 456 | CALL :fn_UnsetVariable WindowsSdkDir_old |
| 457 | CALL :fn_UnsetVariable WindowsSDKLibVersion |
| 458 | CALL :fn_UnsetVariable WindowsSDKVersion |
| 459 | CALL :fn_UnsetVariable WindowsSDK_ExecutablePath_x86 |
| 460 | CALL :fn_UnsetVariable WindowsSDK_ExecutablePath_x64 |
| 461 | |
| 462 | REM |
| 463 | REM NOTE: Reset the PATH here to the absolute bare minimum required. |
| 464 | REM |
| 465 | CALL :fn_ResetPath |
| 466 | |
| 467 | REM |
| 468 | REM NOTE: This is the inner loop. There are normally two iterations, one |
| 469 | REM for each supported build configuration, e.g. Debug or Retail. |
| 470 | REM |
| 471 | FOR %%B IN (%CONFIGURATIONS%) DO ( |
| 472 | REM |
| 473 | REM NOTE: When preparing the debug build, set the DEBUG and MEMDEBUG |
| 474 | REM environment variables to be picked up by the MSVC makefile |
| 475 | REM itself. |
| 476 | REM |
| 477 | %_AECHO% Building the %%B configuration for platform %%P with name %%D... |
| 478 | |
| 479 | IF /I "%%B" == "Debug" ( |
| 480 | REM |
| 481 | REM NOTE: Using this level for the DEBUG environment variable should |
| 482 | REM disable all compiler optimizations and prevent use of the |
| 483 | REM NDEBUG define. Additionally, both SQLITE_ENABLE_API_ARMOR |
| 484 | REM and SQLITE_DEBUG defines should be enabled. |
| 485 | REM |
| 486 | SET DEBUG=3 |
| 487 | |
| 488 | REM |
| 489 | REM NOTE: Setting this to non-zero should enable the SQLITE_MEMDEBUG |
| 490 | REM define. |
| 491 | REM |
| 492 | IF NOT DEFINED NOMEMDEBUG ( |
| 493 | SET MEMDEBUG=1 |
| 494 | ) |
| 495 | ) ELSE ( |
| 496 | CALL :fn_UnsetVariable DEBUG |
| 497 | CALL :fn_UnsetVariable MEMDEBUG |
| 498 | ) |
| 499 | |
| 500 | REM |
| 501 | REM NOTE: Copy the extra NMAKE arguments for this configuration into the |
| 502 | REM common variable used by the actual commands. |
| 503 | REM |
| 504 | CALL :fn_CopyVariable NMAKE_ARGS_%%B NMAKE_ARGS_CFG |
| 505 | |
| 506 | REM |
| 507 | REM NOTE: Launch a nested command shell to perform the following steps: |
| 508 | REM |
| 509 | REM 1. Setup the MSVC environment for this platform using the |
| 510 | REM official batch file. |
| 511 | REM |
| 512 | REM 2. Make sure that no stale build output files are present. |
| 513 | REM |
| 514 | REM 3. Build the "sqlite3.dll" and "sqlite3.lib" binaries for this |
| 515 | REM platform. |
| 516 | REM |
| 517 | REM 4. Copy the "sqlite3.dll" and "sqlite3.lib" binaries for this |
| 518 | REM platform to the platform-specific directory beneath the |
| 519 | REM binary directory. |
| 520 | REM |
| 521 | REM 5. Unless prevented from doing so, copy the "sqlite3.pdb" |
| 522 | REM symbols file for this platform to the platform-specific |
| 523 | REM directory beneath the binary directory. |
| 524 | REM |
| 525 | "%ComSpec%" /C ( |
| 526 | REM |
| 527 | REM NOTE: Attempt to setup the MSVC environment for this platform. |
| 528 | REM |
| 529 | %_CECHO3% CALL "%VCVARSALL%" %%P |
| 530 | %__ECHO3% CALL "%VCVARSALL%" %%P |
| 531 | |
| 532 | IF ERRORLEVEL 1 ( |
| 533 | ECHO Failed to call "%VCVARSALL%" for platform %%P. |
| 534 | GOTO errors |
| 535 | ) |
| 536 | |
| 537 | REM |
| 538 | REM NOTE: If this batch file is not running in "what-if" mode, check to |
| 539 | REM be sure we were actually able to setup the MSVC environment |
| 540 | REM as current versions of their official batch file do not set |
| 541 | REM the exit code upon failure. |
| 542 | REM |
| 543 | IF NOT DEFINED __ECHO3 ( |
| 544 | IF NOT DEFINED WindowsPhoneKitDir ( |
| 545 | IF NOT DEFINED WindowsSdkDir ( |
| 546 | ECHO Cannot build, Windows SDK not found for platform %%P. |
| 547 | GOTO errors |
| 548 | ) |
| 549 | ) |
| 550 | ) |
| 551 | |
| 552 | REM |
| 553 | REM NOTE: When using MSVC 2012, 2013, or 2015, the native SDK path |
| 554 | REM cannot simply be the "lib" sub-directory beneath the location |
| 555 | REM specified in the WindowsSdkDir environment variable because |
| 556 | REM that location does not actually contain the necessary library |
| 557 | REM files for x86. This must be done for each iteration because |
| 558 | REM it relies upon the WindowsSdkDir environment variable being |
| 559 | REM set by the batch file used to setup the MSVC environment. |
| 560 | REM |
| 561 | IF DEFINED SET_NSDKLIBPATH ( |
| 562 | REM |
| 563 | REM NOTE: The Windows Phone SDK has a slightly different directory |
| 564 | REM structure and must be handled specially here. |
| 565 | REM |
| 566 | IF DEFINED WindowsPhoneKitDir ( |
| 567 | CALL :fn_CopyVariable WindowsPhoneKitDir NSDKLIBPATH |
| 568 | CALL :fn_AppendVariable NSDKLIBPATH \lib\x86 |
| 569 | ) ELSE IF DEFINED WindowsSdkDir ( |
| 570 | CALL :fn_CopyVariable WindowsSdkDir NSDKLIBPATH |
| 571 | |
| 572 | REM |
| 573 | REM NOTE: The Windows 8.x and Windows 10.0 SDKs have a slightly |
| 574 | REM different directory naming conventions. |
| 575 | REM |
| 576 | IF DEFINED USE_WINV100_NSDKLIBPATH ( |
| 577 | CALL :fn_AppendVariable NSDKLIBPATH \..\10\lib\%WIN10SDKVER%\um\x86 |
| 578 | CALL :fn_CopyVariable WindowsSdkDir PSDKLIBPATH |
| 579 | CALL :fn_AppendVariable PSDKLIBPATH lib\%WIN10SDKVER%\um\%%D |
| 580 | ) ELSE IF DEFINED USE_WINV63_NSDKLIBPATH ( |
| 581 | CALL :fn_AppendVariable NSDKLIBPATH \lib\winv6.3\um\x86 |
| 582 | ) ELSE IF "%VisualStudioVersion%" == "12.0" ( |
| 583 | CALL :fn_AppendVariable NSDKLIBPATH \..\8.0\lib\win8\um\x86 |
| 584 | ) ELSE IF "%VisualStudioVersion%" == "14.0" ( |
| 585 | CALL :fn_AppendVariable NSDKLIBPATH \..\8.0\lib\win8\um\x86 |
| 586 | ) ELSE ( |
| 587 | CALL :fn_AppendVariable NSDKLIBPATH \lib\win8\um\x86 |
| 588 | ) |
| 589 | ) |
| 590 | ) |
| 591 | |
| 592 | REM |
| 593 | REM NOTE: When using MSVC 2015, setting the Universal CRT library path |
| 594 | REM for x86 may be required as well. This must also be done for |
| 595 | REM each iteration because it relies upon the UniversalCRTSdkDir |
| 596 | REM environment variable being set by the batch file used to |
| 597 | REM setup the MSVC environment. |
| 598 | REM |
| 599 | IF DEFINED SET_NUCRTLIBPATH ( |
| 600 | IF DEFINED UniversalCRTSdkDir ( |
| 601 | CALL :fn_CopyVariable UniversalCRTSdkDir NUCRTLIBPATH |
| 602 | CALL :fn_AppendVariable NUCRTLIBPATH \lib\%NUCRTVER%\ucrt\x86 |
| 603 | ) |
| 604 | ) |
| 605 | |
| 606 | REM |
| 607 | REM NOTE: Unless prevented from doing so, invoke NMAKE with the MSVC |
| 608 | REM makefile to clean any stale build output from previous |
| 609 | REM iterations of this loop and/or previous runs of this batch |
| 610 | REM file, etc. |
| 611 | REM |
| 612 | IF NOT DEFINED NOCLEAN ( |
| 613 | CALL :fn_MakeClean %%D |
| 614 | |
| 615 | IF ERRORLEVEL 1 ( |
| 616 | ECHO Failed to clean for platform %%P. |
| 617 | GOTO errors |
| 618 | ) |
| 619 | ) ELSE ( |
| 620 | REM |
| 621 | REM NOTE: Even when the cleaning step has been disabled, we still |
| 622 | REM need to remove the build output for all the files we are |
| 623 | REM specifically wanting to build for each platform. |
| 624 | REM |
| 625 | %_AECHO% Cleaning final core library output files only... |
| 626 | %__ECHO% DEL /Q *.lo "%DLL_FILE_NAME%" "%LIB_FILE_NAME%" "%DLL_PDB_FILE_NAME%" 2%REDIRECT% NUL |
| 627 | ) |
| 628 | |
| 629 | REM |
| 630 | REM NOTE: Call NMAKE with the MSVC makefile to build the "sqlite3.dll" |
| 631 | REM binary. The x86 compiler will be used to compile the native |
| 632 | REM command line tools needed during the build process itself. |
| 633 | REM Also, disable looking for and/or linking to the native Tcl |
| 634 | REM runtime library. |
| 635 | REM |
| 636 | CALL :fn_MakeDll %%D |
| 637 | |
| 638 | IF ERRORLEVEL 1 ( |
| 639 | ECHO Failed to build %%B "%DLL_FILE_NAME%" for platform %%P. |
| 640 | GOTO errors |
| 641 | ) |
| 642 | |
| 643 | REM |
| 644 | REM NOTE: Copy the "sqlite3.dll" file to the appropriate directory for |
| 645 | REM the build and platform beneath the binary directory. |
| 646 | REM |
| 647 | %__ECHO% XCOPY "%DLL_FILE_NAME%" "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS% |
| 648 | |
| 649 | IF ERRORLEVEL 1 ( |
| 650 | ECHO Failed to copy "%DLL_FILE_NAME%" to "%BINARYDIRECTORY%\%%B\%%D\". |
| 651 | GOTO errors |
| 652 | ) |
| 653 | |
| 654 | REM |
| 655 | REM NOTE: Copy the "sqlite3.lib" file to the appropriate directory for |
| 656 | REM the build and platform beneath the binary directory. |
| 657 | REM |
| 658 | %__ECHO% XCOPY "%LIB_FILE_NAME%" "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS% |
| 659 | |
| 660 | IF ERRORLEVEL 1 ( |
| 661 | ECHO Failed to copy "%LIB_FILE_NAME%" to "%BINARYDIRECTORY%\%%B\%%D\". |
| 662 | GOTO errors |
| 663 | ) |
| 664 | |
| 665 | REM |
| 666 | REM NOTE: Copy the "sqlite3.pdb" file to the appropriate directory for |
| 667 | REM the build and platform beneath the binary directory unless we |
| 668 | REM are prevented from doing so. |
| 669 | REM |
| 670 | IF NOT DEFINED NOSYMBOLS ( |
| 671 | IF EXIST "%DLL_PDB_FILE_NAME%" ( |
| 672 | %__ECHO% XCOPY "%DLL_PDB_FILE_NAME%" "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS% |
| 673 | |
| 674 | IF ERRORLEVEL 1 ( |
| 675 | ECHO Failed to copy "%DLL_PDB_FILE_NAME%" to "%BINARYDIRECTORY%\%%B\%%D\". |
| 676 | GOTO errors |
| 677 | ) |
| 678 | ) |
| 679 | ) |
| 680 | |
| 681 | REM |
| 682 | REM NOTE: If requested, also build the shell executable. |
| 683 | REM |
| 684 | IF DEFINED BUILD_ALL_SHELL ( |
| 685 | REM |
| 686 | REM NOTE: If necessary, make sure any previous build output for the |
| 687 | REM shell executable is deleted. |
| 688 | REM |
| 689 | IF DEFINED NOCLEAN ( |
| 690 | REM |
| 691 | REM NOTE: Even when the cleaning step has been disabled, we still |
| 692 | REM need to remove the build output for all the files we are |
| 693 | REM specifically wanting to build for each platform. |
| 694 | REM |
| 695 | %_AECHO% Cleaning final shell executable output files only... |
| 696 | %__ECHO% DEL /Q "%EXE_FILE_NAME%" "%EXE_PDB_FILE_NAME%" 2%REDIRECT% NUL |
| 697 | ) |
| 698 | |
| 699 | REM |
| 700 | REM NOTE: Call NMAKE with the MSVC makefile to build the "sqlite3.exe" |
| 701 | REM binary. The x86 compiler will be used to compile the native |
| 702 | REM command line tools needed during the build process itself. |
| 703 | REM Also, disable looking for and/or linking to the native Tcl |
| 704 | REM runtime library. |
| 705 | REM |
| 706 | CALL :fn_MakeExe %%D |
| 707 | |
| 708 | IF ERRORLEVEL 1 ( |
| 709 | ECHO Failed to build %%B "%EXE_FILE_NAME%" for platform %%P. |
| 710 | GOTO errors |
| 711 | ) |
| 712 | |
| 713 | REM |
| 714 | REM NOTE: Copy the "sqlite3.exe" file to the appropriate directory |
| 715 | REM for the build and platform beneath the binary directory. |
| 716 | REM |
| 717 | %__ECHO% XCOPY "%EXE_FILE_NAME%" "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS% |
| 718 | |
| 719 | IF ERRORLEVEL 1 ( |
| 720 | ECHO Failed to copy "%EXE_FILE_NAME%" to "%BINARYDIRECTORY%\%%B\%%D\". |
| 721 | GOTO errors |
| 722 | ) |
| 723 | |
| 724 | REM |
| 725 | REM NOTE: Copy the "sqlite3sh.pdb" file to the appropriate directory |
| 726 | REM for the build and platform beneath the binary directory |
| 727 | REM unless we are prevented from doing so. |
| 728 | REM |
| 729 | IF NOT DEFINED NOSYMBOLS ( |
| 730 | IF EXIST "%EXE_PDB_FILE_NAME%" ( |
| 731 | %__ECHO% XCOPY "%EXE_PDB_FILE_NAME%" "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS% |
| 732 | |
| 733 | IF ERRORLEVEL 1 ( |
| 734 | ECHO Failed to copy "%EXE_PDB_FILE_NAME%" to "%BINARYDIRECTORY%\%%B\%%D\". |
| 735 | GOTO errors |
| 736 | ) |
| 737 | ) |
| 738 | ) |
| 739 | ) |
| 740 | ) |
| 741 | ) |
| 742 | ) |
| 743 | |
| 744 | REM |
| 745 | REM NOTE: Handle any errors generated during the nested command shell. |
| 746 | REM |
| 747 | IF ERRORLEVEL 1 ( |
| 748 | GOTO errors |
| 749 | ) |
| 750 | ) |
| 751 | |
| 752 | REM |
| 753 | REM NOTE: Restore the saved current directory from the directory stack. |
| 754 | REM |
| 755 | %_CECHO2% POPD |
| 756 | %__ECHO2% POPD |
| 757 | |
| 758 | IF ERRORLEVEL 1 ( |
| 759 | ECHO Could not restore directory. |
| 760 | GOTO errors |
| 761 | ) |
| 762 | |
| 763 | REM |
| 764 | REM NOTE: If we get to this point, we have succeeded. |
| 765 | REM |
| 766 | GOTO no_errors |
| 767 | |
| 768 | :fn_MakeClean |
| 769 | %__ECHO% %NMAKE_CMD% clean "PLATFORM=%1" XCOMPILE=1 USE_NATIVE_LIBPATHS=1 NO_TCL=1 %NMAKE_ARGS% %NMAKE_ARGS_CFG% |
| 770 | GOTO :EOF |
| 771 | |
| 772 | :fn_MakeDll |
| 773 | %__ECHO% %NMAKE_CMD% "%DLL_FILE_NAME%" "PLATFORM=%1" XCOMPILE=1 USE_NATIVE_LIBPATHS=1 NO_TCL=1 %NMAKE_ARGS% %NMAKE_ARGS_CFG% |
| 774 | GOTO :EOF |
| 775 | |
| 776 | :fn_MakeExe |
| 777 | %__ECHO% %NMAKE_CMD% "%EXE_FILE_NAME%" "PLATFORM=%1" XCOMPILE=1 USE_NATIVE_LIBPATHS=1 NO_TCL=1 %NMAKE_ARGS% %NMAKE_ARGS_CFG% |
| 778 | GOTO :EOF |
| 779 | |
| 780 | :fn_ShowVariable |
| 781 | SETLOCAL |
| 782 | SET __ECHO_CMD=ECHO %%%2%% |
| 783 | FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO ( |
| 784 | IF NOT "%%V" == "" ( |
| 785 | IF NOT "%%V" == "%%%2%%" ( |
| 786 | %_VECHO% %1 = '%%V' |
| 787 | ) |
| 788 | ) |
| 789 | ) |
| 790 | ENDLOCAL |
| 791 | GOTO :EOF |
| 792 | |
| 793 | :fn_ResetErrorLevel |
| 794 | VERIFY > NUL |
| 795 | GOTO :EOF |
| 796 | |
| 797 | :fn_SetErrorLevel |
| 798 | VERIFY MAYBE 2> NUL |
| 799 | GOTO :EOF |
| 800 | |
| 801 | :fn_CopyVariable |
| 802 | IF NOT DEFINED %1 GOTO :EOF |
| 803 | IF "%2" == "" GOTO :EOF |
| 804 | SETLOCAL |
| 805 | SET __ECHO_CMD=ECHO %%%1%% |
| 806 | FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO ( |
| 807 | SET VALUE=%%V |
| 808 | ) |
| 809 | ENDLOCAL && SET %2=%VALUE% |
| 810 | GOTO :EOF |
| 811 | |
| 812 | :fn_UnsetVariable |
| 813 | SETLOCAL |
| 814 | SET VALUE=%1 |
| 815 | IF DEFINED VALUE ( |
| 816 | SET VALUE= |
| 817 | ENDLOCAL |
| 818 | SET %VALUE%= |
| 819 | ) ELSE ( |
| 820 | ENDLOCAL |
| 821 | ) |
| 822 | CALL :fn_ResetErrorLevel |
| 823 | GOTO :EOF |
| 824 | |
| 825 | :fn_ResetPath |
| 826 | SET PATH=%TOOLPATH%;%SystemRoot%\System32;%SystemRoot% |
| 827 | GOTO :EOF |
| 828 | |
| 829 | :fn_AppendVariable |
| 830 | SET __ECHO_CMD=ECHO %%%1%% |
| 831 | IF DEFINED %1 ( |
| 832 | FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO ( |
| 833 | SET %1=%%V%~2 |
| 834 | ) |
| 835 | ) ELSE ( |
| 836 | SET %1=%~2 |
| 837 | ) |
| 838 | SET __ECHO_CMD= |
| 839 | CALL :fn_ResetErrorLevel |
| 840 | GOTO :EOF |
| 841 | |
| 842 | :usage |
| 843 | ECHO. |
| 844 | ECHO Usage: %~nx0 ^<binaryDirectory^> |
| 845 | ECHO. |
| 846 | GOTO errors |
| 847 | |
| 848 | :errors |
| 849 | CALL :fn_SetErrorLevel |
| 850 | ENDLOCAL |
| 851 | ECHO. |
| 852 | ECHO Failure, errors were encountered. |
| 853 | GOTO end_of_file |
| 854 | |
| 855 | :no_errors |
| 856 | CALL :fn_ResetErrorLevel |
| 857 | ENDLOCAL |
| 858 | ECHO. |
| 859 | ECHO Success, no errors were encountered. |
| 860 | GOTO end_of_file |
| 861 | |
| 862 | :end_of_file |
| 863 | %__ECHO% EXIT /B %ERRORLEVEL% |