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