interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / tool / build-all-msvc.bat

863 lines · 29272 bytes Raw Blame History
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_DEBUG=MEMDEBUG=1
109REM SET NMAKE_ARGS_RETAIL=WIN32HEAP=1
110REM
111REM Using the above command before running this tool will cause the compiled
112REM binaries to target the WinRT environment, which provides a subset of the
113REM Win32 API.
114REM
115REM DLL_FILE_NAME
116REM DLL_PDB_FILE_NAME
117REM LIB_FILE_NAME
118REM EXE_FILE_NAME
119REM EXE_PDB_FILE_NAME
120REM
121REM When set, these values will override the associated target file name used
122REM for the build.
123REM
124SETLOCAL
125
126REM SET __ECHO=ECHO
127REM SET __ECHO2=ECHO
128REM SET __ECHO3=ECHO
129IF NOT DEFINED _AECHO (SET _AECHO=REM)
130IF NOT DEFINED _CECHO (SET _CECHO=REM)
131IF NOT DEFINED _CECHO2 (SET _CECHO2=REM)
132IF NOT DEFINED _CECHO3 (SET _CECHO3=REM)
133IF NOT DEFINED _VECHO (SET _VECHO=REM)
134
135SET REDIRECT=^>
136IF DEFINED __ECHO SET REDIRECT=^^^>
137
138%_AECHO% Running %0 %*
139
140REM SET DFLAGS=/L
141
142%_VECHO% DFlags = '%DFLAGS%'
143
144SET FFLAGS=/V /F /G /H /I /R /Y /Z
145
146%_VECHO% FFlags = '%FFLAGS%'
147
148SET ROOT=%~dp0\..
149SET ROOT=%ROOT:\\=\%
150
151%_VECHO% Root = '%ROOT%'
152
153REM
154REM NOTE: The first and only argument to this batch file should be the output
155REM directory where the platform-specific binary directories should be
156REM created.
157REM
158SET BINARYDIRECTORY=%1
159
160IF NOT DEFINED BINARYDIRECTORY (
161 GOTO usage
162)
163
164%_VECHO% BinaryDirectory = '%BINARYDIRECTORY%'
165
166SET DUMMY=%2
167
168IF DEFINED DUMMY (
169 GOTO usage
170)
171
172REM
173REM NOTE: From this point, we need a clean error level. Reset it now.
174REM
175CALL :fn_ResetErrorLevel
176
177REM
178REM NOTE: Change the current directory to the root of the source tree, saving
179REM the current directory on the directory stack.
180REM
181%_CECHO2% PUSHD "%ROOT%"
182%__ECHO2% PUSHD "%ROOT%"
183
184IF ERRORLEVEL 1 (
185 ECHO Could not change directory to "%ROOT%".
186 GOTO errors
187)
188
189REM
190REM NOTE: This batch file requires the ComSpec environment variable to be set,
191REM typically to something like "C:\Windows\System32\cmd.exe".
192REM
193IF NOT DEFINED ComSpec (
194 ECHO The ComSpec environment variable must be defined.
195 GOTO errors
196)
197
198REM
199REM NOTE: This batch file requires the VcInstallDir environment variable to be
200REM set. Typically, this means this batch file needs to be run from an
201REM MSVC command prompt.
202REM
203IF NOT DEFINED VCINSTALLDIR (
204 ECHO The VCINSTALLDIR environment variable must be defined.
205 GOTO errors
206)
207
208REM
209REM NOTE: If the list of platforms is not already set, use the default list.
210REM
211IF NOT DEFINED PLATFORMS (
212 SET PLATFORMS=x86 x86_amd64 x86_arm
213)
214
215%_VECHO% Platforms = '%PLATFORMS%'
216
217REM
218REM NOTE: If the list of configurations is not already set, use the default
219REM list.
220REM
221IF NOT DEFINED CONFIGURATIONS (
222 SET CONFIGURATIONS=Debug Retail
223)
224
225%_VECHO% Configurations = '%CONFIGURATIONS%'
226
227REM
228REM NOTE: If the command used to invoke NMAKE is not already set, use the
229REM default.
230REM
231IF 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
244REM
245REM NOTE: Setup environment variables to translate between the MSVC platform
246REM names and the names to be used for the platform-specific binary
247REM directories.
248REM
249SET amd64_NAME=x64
250SET arm_NAME=ARM
251SET x64_NAME=x64
252SET x86_NAME=x86
253SET x86_amd64_NAME=x64
254SET x86_arm_NAME=ARM
255SET 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
265REM
266REM NOTE: Check for the external tools needed during the build process ^(i.e.
267REM those that do not get compiled as part of the build process itself^)
268REM along the PATH.
269REM
270IF DEFINED TCLSH_CMD (
271 SET TCLSH_FILE=%TCLSH_CMD%
272) ELSE (
273 SET TCLSH_FILE=tclsh.exe
274)
275
276FOR %%T IN (%TCLSH_FILE%) DO (
277 SET %%T_PATH=%%~dp$PATH:T
278)
279
280REM
281REM NOTE: A Tcl shell executable is required during the SQLite build process
282REM unless a pre-existing amalgamation file is used.
283REM
284IF 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
289REM
290REM NOTE: Setup the default names for the build targets we are creating. Any
291REM ^(or all^) of these may end up being overridden.
292REM
293IF NOT DEFINED DLL_FILE_NAME (
294 SET DLL_FILE_NAME=sqlite3.dll
295)
296
297IF NOT DEFINED DLL_PDB_FILE_NAME (
298 SET DLL_PDB_FILE_NAME=sqlite3.pdb
299)
300
301IF NOT DEFINED LIB_FILE_NAME (
302 SET LIB_FILE_NAME=sqlite3.lib
303)
304
305IF NOT DEFINED EXE_FILE_NAME (
306 SET EXE_FILE_NAME=sqlite3.exe
307)
308
309IF NOT DEFINED EXE_PDB_FILE_NAME (
310 SET EXE_PDB_FILE_NAME=sqlite3sh.pdb
311)
312
313REM
314REM NOTE: Set the TOOLPATH variable to contain all the directories where the
315REM external tools were found in the search above.
316REM
317CALL :fn_CopyVariable %TCLSH_FILE%_PATH TOOLPATH
318
319%_VECHO% ToolPath = '%TOOLPATH%'
320
321REM
322REM NOTE: Setting the Windows SDK library path is only required for MSVC
323REM 2012, 2013, and 2015.
324REM
325CALL :fn_UnsetVariable SET_NSDKLIBPATH
326
327REM
328REM NOTE: Setting the Universal CRT library path is only required for MSVC
329REM 2015.
330REM
331CALL :fn_UnsetVariable SET_NUCRTLIBPATH
332
333REM
334REM NOTE: Check for MSVC 2012, 2013, and 2015 specially because the Windows
335REM SDK directory handling is slightly different for those versions.
336REM
337IF "%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
371REM
372REM NOTE: This is the name of the sub-directory where the UCRT libraries may
373REM be found. It is only used when compiling against the UCRT.
374REM
375IF DEFINED UCRTVersion (
376 SET NUCRTVER=%UCRTVersion%
377) ELSE (
378 SET NUCRTVER=10.0.10586.0
379)
380
381REM
382REM NOTE: This is the name of the sub-directory where the Windows 10.0 SDK
383REM libraries may be found. It is only used when compiling with the
384REM Windows 10.0 SDK.
385REM
386IF DEFINED WindowsSDKLibVersion (
387 SET WIN10SDKVER=%WindowsSDKLibVersion:\=%
388) ELSE (
389 SET WIN10SDKVER=%NUCRTVER%
390)
391
392REM
393REM NOTE: Check if this is the Windows Phone SDK. If so, a different batch
394REM file is necessary to setup the build environment. Since the variable
395REM values involved here may contain parenthesis, using GOTO instead of
396REM an IF block is required.
397REM
398IF DEFINED WindowsPhoneKitDir GOTO set_vcvarsall_phone
399SET VCVARSALL=%VCINSTALLDIR%\vcvarsall.bat
400GOTO set_vcvarsall_done
401:set_vcvarsall_phone
402SET VCVARSALL=%VCINSTALLDIR%\WPSDK\WP80\vcvarsphoneall.bat
403:set_vcvarsall_done
404SET VCVARSALL=%VCVARSALL:\\=\%
405
406REM
407REM NOTE: This is the outer loop. There should be exactly one iteration per
408REM platform.
409REM
410FOR %%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
752REM
753REM NOTE: Restore the saved current directory from the directory stack.
754REM
755%_CECHO2% POPD
756%__ECHO2% POPD
757
758IF ERRORLEVEL 1 (
759 ECHO Could not restore directory.
760 GOTO errors
761)
762
763REM
764REM NOTE: If we get to this point, we have succeeded.
765REM
766GOTO 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%