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