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