summaryrefslogtreecommitdiff
path: root/tool/build-all-msvc.bat
diff options
context:
space:
mode:
Diffstat (limited to 'tool/build-all-msvc.bat')
-rwxr-xr-xtool/build-all-msvc.bat320
1 files changed, 221 insertions, 99 deletions
diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat
index a2d7dae..758036f 100755
--- a/tool/build-all-msvc.bat
+++ b/tool/build-all-msvc.bat
@@ -6,10 +6,54 @@
:: Multi-Platform Build Tool for MSVC
::
+REM
+REM This batch script is used to build the SQLite DLL for multiple platforms
+REM and configurations using MSVC. The built SQLite DLLs, their associated
+REM import libraries, and optionally their symbols files, are placed within
+REM the directory specified on the command line, in sub-directories named for
+REM their respective platforms and configurations. This batch script must be
+REM run from inside a Visual Studio Command Prompt for the desired version of
+REM Visual Studio ^(the initial platform configured for the command prompt does
+REM not really matter^). Exactly one command line argument is required, the
+REM name of an existing directory to be used as the final destination directory
+REM for the generated output files, which will be placed in sub-directories
+REM created therein. Ideally, the directory specified should be empty.
+REM
+REM Example:
+REM
+REM CD /D C:\dev\sqlite\core
+REM tool\build-all-msvc.bat C:\Temp
+REM
+REM In the example above, "C:\dev\sqlite\core" represents the root of the
+REM source tree for SQLite and "C:\Temp" represents the final destination
+REM directory for the generated output files.
+REM
+REM There are several environment variables that may be set to modify the
+REM behavior of this batch script and its associated Makefile. The list of
+REM platforms to build may be overriden by using the PLATFORMS environment
+REM variable, which should contain a list of platforms ^(e.g. x86 x86_amd64
+REM x86_arm^). All platforms must be supported by the version of Visual Studio
+REM being used. The list of configurations to build may be overridden by
+REM setting the CONFIGURATIONS environment variable, which should contain a
+REM list of configurations to build ^(e.g. Debug Retail^). Neither of these
+REM variable values may contain any double quotes, surrounding or embedded.
+REM Finally, the NCRTLIBPATH and NSDKLIBPATH environment variables may be set
+REM to specify the location of the CRT and SDK, respectively, needed to compile
+REM executables native to the architecture of the build machine during any
+REM cross-compilation that may be necessary, depending on the platforms to be
+REM built. These values in these two variables should be surrounded by double
+REM quotes if they contain spaces.
+REM
+REM Please note that the SQLite build process performed by the Makefile
+REM associated with this batch script requires both Gawk ^(gawk.exe^) and Tcl
+REM 8.5 ^(tclsh85.exe^) to be present in a directory contained in the PATH
+REM environment variable unless a pre-existing amalgamation file is used.
+REM
SETLOCAL
REM SET __ECHO=ECHO
REM SET __ECHO2=ECHO
+REM SET __ECHO3=ECHO
IF NOT DEFINED _AECHO (SET _AECHO=REM)
IF NOT DEFINED _CECHO (SET _CECHO=REM)
IF NOT DEFINED _VECHO (SET _VECHO=REM)
@@ -93,17 +137,35 @@ IF NOT DEFINED PLATFORMS (
%_VECHO% Platforms = '%PLATFORMS%'
REM
+REM NOTE: If the list of configurations is not already set, use the default
+REM list.
+REM
+IF NOT DEFINED CONFIGURATIONS (
+ SET CONFIGURATIONS=Debug Retail
+)
+
+%_VECHO% Configurations = '%CONFIGURATIONS%'
+
+REM
REM NOTE: Setup environment variables to translate between the MSVC platform
REM names and the names to be used for the platform-specific binary
REM directories.
REM
+SET amd64_NAME=x64
+SET arm_NAME=ARM
+SET x64_NAME=x64
SET x86_NAME=x86
SET x86_amd64_NAME=x64
SET x86_arm_NAME=ARM
+SET x86_x64_NAME=x64
+%_VECHO% amd64_Name = '%amd64_NAME%'
+%_VECHO% arm_Name = '%arm_NAME%'
+%_VECHO% x64_Name = '%x64_NAME%'
%_VECHO% x86_Name = '%x86_NAME%'
%_VECHO% x86_amd64_Name = '%x86_amd64_NAME%'
%_VECHO% x86_arm_Name = '%x86_arm_NAME%'
+%_VECHO% x86_x64_Name = '%x86_x64_NAME%'
REM
REM NOTE: Check for the external tools needed during the build process ^(i.e.
@@ -115,6 +177,24 @@ FOR %%T IN (gawk.exe tclsh85.exe) DO (
)
REM
+REM NOTE: The Gawk executable "gawk.exe" is required during the SQLite build
+REM process unless a pre-existing amalgamation file is used.
+REM
+IF NOT DEFINED gawk.exe_PATH (
+ ECHO The Gawk executable "gawk.exe" is required to be in the PATH.
+ GOTO errors
+)
+
+REM
+REM NOTE: The Tcl 8.5 executable "tclsh85.exe" is required during the SQLite
+REM build process unless a pre-existing amalgamation file is used.
+REM
+IF NOT DEFINED tclsh85.exe_PATH (
+ ECHO The Tcl 8.5 executable "tclsh85.exe" is required to be in the PATH.
+ GOTO errors
+)
+
+REM
REM NOTE: Set the TOOLPATH variable to contain all the directories where the
REM external tools were found in the search above.
REM
@@ -127,12 +207,31 @@ REM NOTE: Check for MSVC 2012 because the Windows SDK directory handling is
REM slightly different for that version.
REM
IF "%VisualStudioVersion%" == "11.0" (
- SET SET_NSDKLIBPATH=1
+ REM
+ REM NOTE: If the Windows SDK library path has already been set, do not set
+ REM it to something else later on.
+ REM
+ IF NOT DEFINED NSDKLIBPATH (
+ SET SET_NSDKLIBPATH=1
+ )
) ELSE (
CALL :fn_UnsetVariable SET_NSDKLIBPATH
)
REM
+REM NOTE: Check if this is the Windows Phone SDK. If so, a different batch
+REM file is necessary to setup the build environment. Since the variable
+REM values involved here may contain parenthesis, using GOTO instead of
+REM an IF block is required.
+REM
+IF DEFINED WindowsPhoneKitDir GOTO set_vcvarsall_phone
+SET VCVARSALL=%VCINSTALLDIR%\vcvarsall.bat
+GOTO set_vcvarsall_done
+:set_vcvarsall_phone
+SET VCVARSALL=%VCINSTALLDIR%\WPSDK\WP80\vcvarsphoneall.bat
+:set_vcvarsall_done
+
+REM
REM NOTE: This is the outer loop. There should be exactly one iteration per
REM platform.
REM
@@ -142,7 +241,7 @@ FOR %%P IN (%PLATFORMS%) DO (
REM be used for the name of the platform-specific binary directory via
REM the environment variables setup earlier.
REM
- CALL :fn_SetVariable %%P_NAME PLATFORMNAME
+ CALL :fn_CopyVariable %%P_NAME PLATFORMNAME
REM
REM NOTE: This is the inner loop. There should be exactly one iteration.
@@ -172,6 +271,7 @@ FOR %%P IN (%PLATFORMS%) DO (
CALL :fn_UnsetVariable Platform
REM CALL :fn_UnsetVariable VCINSTALLDIR
CALL :fn_UnsetVariable VSINSTALLDIR
+ CALL :fn_UnsetVariable WindowsPhoneKitDir
CALL :fn_UnsetVariable WindowsSdkDir
CALL :fn_UnsetVariable WindowsSdkDir_35
CALL :fn_UnsetVariable WindowsSdkDir_old
@@ -181,129 +281,151 @@ FOR %%P IN (%PLATFORMS%) DO (
REM
SET PATH=%TOOLPATH%;%SystemRoot%\System32;%SystemRoot%
- REM
- REM NOTE: Launch a nested command shell to perform the following steps:
- REM
- REM 1. Setup the MSVC environment for this platform using the
- REM official batch file.
- REM
- REM 2. Make sure that no stale build output files are present.
- REM
- REM 3. Build the "sqlite3.dll" and "sqlite3.lib" binaries for this
- REM platform.
- REM
- REM 4. Copy the "sqlite3.dll" and "sqlite3.lib" binaries for this
- REM platform to the platform-specific directory beneath the
- REM binary directory.
- REM
- "%ComSpec%" /C (
+ FOR %%B IN (%CONFIGURATIONS%) DO (
REM
- REM NOTE: Attempt to setup the MSVC environment for this platform.
+ REM NOTE: When preparing the debug build, set the DEBUG and MEMDEBUG
+ REM environment variables to be picked up by the MSVC makefile
+ REM itself.
REM
- %__ECHO% CALL "%VCINSTALLDIR%\vcvarsall.bat" %%P
-
- IF ERRORLEVEL 1 (
- ECHO Failed to call "%VCINSTALLDIR%\vcvarsall.bat" for platform %%P.
- GOTO errors
+ IF /I "%%B" == "Debug" (
+ SET DEBUG=2
+ SET MEMDEBUG=1
+ ) ELSE (
+ CALL :fn_UnsetVariable DEBUG
+ CALL :fn_UnsetVariable MEMDEBUG
)
REM
- REM NOTE: If this batch file is not running in "what-if" mode, check to
- REM be sure we were actually able to setup the MSVC environment as
- REM current versions of their official batch file do not set the
- REM exit code upon failure.
+ REM NOTE: Launch a nested command shell to perform the following steps:
REM
- IF NOT DEFINED __ECHO (
- IF NOT DEFINED WindowsSdkDir (
- ECHO Cannot build, Windows SDK not found for platform %%P.
- GOTO errors
- )
- )
-
+ REM 1. Setup the MSVC environment for this platform using the
+ REM official batch file.
REM
- REM NOTE: When using MSVC 2012, the native SDK path cannot simply use
- REM the "lib" sub-directory beneath the location specified in the
- REM WindowsSdkDir environment variable because that location does
- REM not actually contain the necessary library files for x86.
- REM This must be done for each iteration because it relies upon
- REM the WindowsSdkDir environment variable being set by the batch
- REM file used to setup the MSVC environment.
+ REM 2. Make sure that no stale build output files are present.
REM
- IF DEFINED SET_NSDKLIBPATH (
- CALL :fn_SetVariable WindowsSdkDir NSDKLIBPATH
- CALL :fn_AppendVariable NSDKLIBPATH \lib\win8\um\x86
- )
-
+ REM 3. Build the "sqlite3.dll" and "sqlite3.lib" binaries for this
+ REM platform.
REM
- REM NOTE: Unless prevented from doing so, invoke NMAKE with the MSVC
- REM makefile to clean any stale build output from previous
- REM iterations of this loop and/or previous runs of this batch
- REM file, etc.
+ REM 4. Copy the "sqlite3.dll" and "sqlite3.lib" binaries for this
+ REM platform to the platform-specific directory beneath the
+ REM binary directory.
REM
- IF NOT DEFINED NOCLEAN (
- %__ECHO% nmake -f Makefile.msc clean
+ "%ComSpec%" /C (
+ REM
+ REM NOTE: Attempt to setup the MSVC environment for this platform.
+ REM
+ %__ECHO3% CALL "%VCVARSALL%" %%P
IF ERRORLEVEL 1 (
- ECHO Failed to clean for platform %%P.
+ ECHO Failed to call "%VCVARSALL%" for platform %%P.
GOTO errors
)
- ) ELSE (
+
REM
- REM NOTE: Even when the cleaning step has been disabled, we still need
- REM to remove the build output for the files we are specifically
- REM wanting to build for each platform.
+ REM NOTE: If this batch file is not running in "what-if" mode, check to
+ REM be sure we were actually able to setup the MSVC environment
+ REM as current versions of their official batch file do not set
+ REM the exit code upon failure.
REM
- %__ECHO% DEL /Q sqlite3.dll sqlite3.lib sqlite3.pdb
- )
+ IF NOT DEFINED __ECHO3 (
+ IF NOT DEFINED WindowsPhoneKitDir (
+ IF NOT DEFINED WindowsSdkDir (
+ ECHO Cannot build, Windows SDK not found for platform %%P.
+ GOTO errors
+ )
+ )
+ )
- REM
- REM NOTE: Invoke NMAKE with the MSVC makefile to build the "sqlite3.dll"
- REM binary. The x86 compiler will be used to compile the native
- REM command line tools needed during the build process itself.
- REM Also, disable looking for and/or linking to the native Tcl
- REM runtime library.
- REM
- %__ECHO% nmake -f Makefile.msc sqlite3.dll "NCC=""%VCINSTALLDIR%\bin\cl.exe""" USE_NATIVE_LIBPATHS=1 NO_TCL=1 %NMAKE_ARGS%
+ REM
+ REM NOTE: When using MSVC 2012, the native SDK path cannot simply use
+ REM the "lib" sub-directory beneath the location specified in the
+ REM WindowsSdkDir environment variable because that location does
+ REM not actually contain the necessary library files for x86.
+ REM This must be done for each iteration because it relies upon
+ REM the WindowsSdkDir environment variable being set by the batch
+ REM file used to setup the MSVC environment.
+ REM
+ IF DEFINED SET_NSDKLIBPATH (
+ IF DEFINED WindowsPhoneKitDir (
+ CALL :fn_CopyVariable WindowsPhoneKitDir NSDKLIBPATH
+ CALL :fn_AppendVariable NSDKLIBPATH \lib\x86
+ ) ELSE IF DEFINED WindowsSdkDir (
+ CALL :fn_CopyVariable WindowsSdkDir NSDKLIBPATH
+ CALL :fn_AppendVariable NSDKLIBPATH \lib\win8\um\x86
+ )
+ )
- IF ERRORLEVEL 1 (
- ECHO Failed to build "sqlite3.dll" for platform %%P.
- GOTO errors
- )
+ REM
+ REM NOTE: Unless prevented from doing so, invoke NMAKE with the MSVC
+ REM makefile to clean any stale build output from previous
+ REM iterations of this loop and/or previous runs of this batch
+ REM file, etc.
+ REM
+ IF NOT DEFINED NOCLEAN (
+ %__ECHO% nmake -f Makefile.msc clean
+
+ IF ERRORLEVEL 1 (
+ ECHO Failed to clean for platform %%P.
+ GOTO errors
+ )
+ ) ELSE (
+ REM
+ REM NOTE: Even when the cleaning step has been disabled, we still
+ REM need to remove the build output for the files we are
+ REM specifically wanting to build for each platform.
+ REM
+ %__ECHO% DEL /Q sqlite3.dll sqlite3.lib sqlite3.pdb
+ )
- REM
- REM NOTE: Copy the "sqlite3.dll" file to the platform-specific directory
- REM beneath the binary directory.
- REM
- %__ECHO% XCOPY sqlite3.dll "%BINARYDIRECTORY%\%%D\" %FFLAGS% %DFLAGS%
+ REM
+ REM NOTE: Call NMAKE with the MSVC makefile to build the "sqlite3.dll"
+ REM binary. The x86 compiler will be used to compile the native
+ REM command line tools needed during the build process itself.
+ REM Also, disable looking for and/or linking to the native Tcl
+ REM runtime library.
+ REM
+ %__ECHO% nmake -f Makefile.msc sqlite3.dll XCOMPILE=1 USE_NATIVE_LIBPATHS=1 NO_TCL=1 %NMAKE_ARGS%
- IF ERRORLEVEL 1 (
- ECHO Failed to copy "sqlite3.dll" to "%BINARYDIRECTORY%\%%D\".
- GOTO errors
- )
+ IF ERRORLEVEL 1 (
+ ECHO Failed to build %%B "sqlite3.dll" for platform %%P.
+ GOTO errors
+ )
- REM
- REM NOTE: Copy the "sqlite3.lib" file to the platform-specific directory
- REM beneath the binary directory.
- REM
- %__ECHO% XCOPY sqlite3.lib "%BINARYDIRECTORY%\%%D\" %FFLAGS% %DFLAGS%
+ REM
+ REM NOTE: Copy the "sqlite3.dll" file to the appropriate directory for
+ REM the build and platform beneath the binary directory.
+ REM
+ %__ECHO% XCOPY sqlite3.dll "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS%
- IF ERRORLEVEL 1 (
- ECHO Failed to copy "sqlite3.lib" to "%BINARYDIRECTORY%\%%D\".
- GOTO errors
- )
+ IF ERRORLEVEL 1 (
+ ECHO Failed to copy "sqlite3.dll" to "%BINARYDIRECTORY%\%%B\%%D\".
+ GOTO errors
+ )
- REM
- REM NOTE: Copy the "sqlite3.pdb" file to the platform-specific directory
- REM beneath the binary directory unless we are prevented from doing
- REM so.
- REM
- IF NOT DEFINED NOSYMBOLS (
- %__ECHO% XCOPY sqlite3.pdb "%BINARYDIRECTORY%\%%D\" %FFLAGS% %DFLAGS%
+ REM
+ REM NOTE: Copy the "sqlite3.lib" file to the appropriate directory for
+ REM the build and platform beneath the binary directory.
+ REM
+ %__ECHO% XCOPY sqlite3.lib "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS%
IF ERRORLEVEL 1 (
- ECHO Failed to copy "sqlite3.pdb" to "%BINARYDIRECTORY%\%%D\".
+ ECHO Failed to copy "sqlite3.lib" to "%BINARYDIRECTORY%\%%B\%%D\".
GOTO errors
)
+
+ REM
+ REM NOTE: Copy the "sqlite3.pdb" file to the appropriate directory for
+ REM the build and platform beneath the binary directory unless we
+ REM are prevented from doing so.
+ REM
+ IF NOT DEFINED NOSYMBOLS (
+ %__ECHO% XCOPY sqlite3.pdb "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS%
+
+ IF ERRORLEVEL 1 (
+ ECHO Failed to copy "sqlite3.pdb" to "%BINARYDIRECTORY%\%%B\%%D\".
+ GOTO errors
+ )
+ )
)
)
)
@@ -339,7 +461,7 @@ GOTO no_errors
VERIFY MAYBE 2> NUL
GOTO :EOF
-:fn_SetVariable
+:fn_CopyVariable
SETLOCAL
IF NOT DEFINED %1 GOTO :EOF
IF "%2" == "" GOTO :EOF