]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add tool to build the core DLL for multiple platforms using MSVC.
authormistachkin <mistachkin@noemail.net>
Fri, 27 Jul 2012 07:13:25 +0000 (07:13 +0000)
committermistachkin <mistachkin@noemail.net>
Fri, 27 Jul 2012 07:13:25 +0000 (07:13 +0000)
FossilOrigin-Name: e42f5812f142522852f6dc72430bc7afdd6f2ed3

Makefile.msc
manifest
manifest.uuid
tool/build-all-msvc.bat [new file with mode: 0755]

index 03872d7de8774048e38b266a107eb58596128499..8e1a36cf8cd367cda8c06b945627b03796753953 100644 (file)
@@ -30,6 +30,11 @@ USE_NATIVE_LIBPATHS = 0
 #
 FOR_WINRT = 0
 
+# Set this non-0 to skip attempting to look for and/or link with the Tcl
+# runtime library.
+#
+NO_TCL = 0
+
 # Set this to non-0 to create and use PDBs.
 #
 SYMBOLS = 1
@@ -345,8 +350,10 @@ LDFLAGS = /DEBUG
 !ENDIF
 
 # Start with the Tcl related linker options.
+!IF $(NO_TCL)==0
 LTLIBPATHS = /LIBPATH:$(TCLLIBDIR)
 LTLIBS = $(LIBTCL)
+!ENDIF
 
 # If ICU support is enabled, add the linker options for it.
 !IF $(USE_ICU)!=0
index 3444e28ebb37d7aa6fdc98ab3cdf6fb5714f7847..569844a12f48024470c0043bc858b12b8234d6e7 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,9 +1,9 @@
-C Add\stool\sto\sgenerate\sa\sVSIX\spackage\susable\sby\sVisual\sStudio\s2012\sRC.
-D 2012-07-27T02:36:06.349
+C Add\stool\sto\sbuild\sthe\score\sDLL\sfor\smultiple\splatforms\susing\sMSVC.
+D 2012-07-27T07:13:25.700
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
-F Makefile.msc a2a8fcd4104a67e037351323c88e0e4822596926
+F Makefile.msc d598bf4a464d2e9ecbeeea809969c2ac3bf97359
 F Makefile.vxworks 879f034a64062a364b21000266bbd5bc6e0c19b9
 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6
 F VERSION a71848df48082f1d6585d4b0819d530fc455485d
@@ -966,6 +966,7 @@ F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31
 F test/win32lock.test b2a539e85ae6b2d78475e016a9636b4451dc7fb9
 F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688
 F test/zerodamage.test 0de750389990b1078bab203c712dc3fefd1d8b82
+F tool/build-all-msvc.bat fe0f031dce6881469b0949283a3cfa8a93032eca x
 F tool/build-shell.sh b64a481901fc9ffe5ca8812a2a9255b6cfb77381
 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
 F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2
@@ -1007,7 +1008,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/win/sqlite.vsix 84163b633f01f35cb47495c05dd2b640159677ff
-P d8da26f1f43610ac83af2a5d0e170be5abaf7aaa
-R e89b8d51f4ab3734c03bdfc7ca67399b
+P 8b90e0c4dbcedaf3e61c5d49452997705be1ef98
+R 352e3b46f2ff977e05b0828462f57f7b
 U mistachkin
-Z ca7c7ef3778a69af10a33d78de2dc884
+Z 1ba4e6125d90314090d1c67374bcfabc
index 364fa66bed8563c7db9713a0f9d2bfd35c5869f2..73ae6a4e9471daa862d31ebce5d0983a89b79d89 100644 (file)
@@ -1 +1 @@
-8b90e0c4dbcedaf3e61c5d49452997705be1ef98
\ No newline at end of file
+e42f5812f142522852f6dc72430bc7afdd6f2ed3
\ No newline at end of file
diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat
new file mode 100755 (executable)
index 0000000..c5c10d0
--- /dev/null
@@ -0,0 +1,331 @@
+@ECHO OFF\r
+\r
+::\r
+:: build-all-msvc.bat --\r
+::\r
+:: Multi-Platform Build Tool for MSVC\r
+::\r
+\r
+SETLOCAL\r
+\r
+REM SET __ECHO=ECHO\r
+REM SET __ECHO2=ECHO\r
+IF NOT DEFINED _AECHO (SET _AECHO=REM)\r
+IF NOT DEFINED _CECHO (SET _CECHO=REM)\r
+IF NOT DEFINED _VECHO (SET _VECHO=REM)\r
+\r
+%_AECHO% Running %0 %*\r
+\r
+REM SET DFLAGS=/L\r
+\r
+%_VECHO% DFlags = '%DFLAGS%'\r
+\r
+SET FFLAGS=/V /F /G /H /I /R /Y /Z\r
+\r
+%_VECHO% FFlags = '%FFLAGS%'\r
+\r
+SET ROOT=%~dp0\..\r
+SET ROOT=%ROOT:\\=\%\r
+\r
+%_VECHO% Root = '%ROOT%'\r
+\r
+REM\r
+REM NOTE: The first and only argument to this batch file should be the output\r
+REM       directory where the platform-specific binary directories should be\r
+REM       created.\r
+REM\r
+SET BINARYDIRECTORY=%1\r
+\r
+IF NOT DEFINED BINARYDIRECTORY (\r
+  GOTO usage\r
+)\r
+\r
+%_VECHO% BinaryDirectory = '%BINARYDIRECTORY%'\r
+\r
+SET DUMMY=%2\r
+\r
+IF DEFINED DUMMY (\r
+  GOTO usage\r
+)\r
+\r
+REM\r
+REM NOTE: From this point, we need a clean error level.  Reset it now.\r
+REM\r
+CALL :fn_ResetErrorLevel\r
+\r
+REM\r
+REM NOTE: Change the current directory to the root of the source tree, saving\r
+REM       the current directory on the directory stack.\r
+REM\r
+%__ECHO2% PUSHD "%ROOT%"\r
+\r
+IF ERRORLEVEL 1 (\r
+  ECHO Could not change directory to "%ROOT%".\r
+  GOTO errors\r
+)\r
+\r
+REM\r
+REM NOTE: This batch file requires the ComSpec environment variable to be set,\r
+REM       typically to something like "C:\Windows\System32\cmd.exe".\r
+REM\r
+IF NOT DEFINED ComSpec (\r
+  ECHO The ComSpec environment variable must be defined.\r
+  GOTO errors\r
+)\r
+\r
+REM\r
+REM NOTE: This batch file requires the VcInstallDir environment variable to be\r
+REM       set.  Tyipcally, this means this batch file needs to be run from an\r
+REM       MSVC command prompt.\r
+REM\r
+IF NOT DEFINED VCINSTALLDIR (\r
+  ECHO The VCINSTALLDIR environment variable must be defined.\r
+  GOTO errors\r
+)\r
+\r
+REM\r
+REM NOTE: If the list of platforms is not already set, use the default list.\r
+REM\r
+IF NOT DEFINED PLATFORMS (\r
+  SET PLATFORMS=x86 x86_amd64 x86_arm\r
+)\r
+\r
+%_VECHO% Platforms = '%PLATFORMS%'\r
+\r
+REM\r
+REM NOTE: Setup environment variables to translate between the MSVC platform\r
+REM       names and the names to be used for the platform-specific binary\r
+REM       directories.\r
+REM\r
+SET x86_NAME=x86\r
+SET x86_amd64_NAME=x64\r
+SET x86_arm_NAME=ARM\r
+\r
+%_VECHO% x86_Name = '%x86_NAME%'\r
+%_VECHO% x86_amd64_Name = '%x86_amd64_NAME%'\r
+%_VECHO% x86_arm_Name = '%x86_arm_NAME%'\r
+\r
+REM\r
+REM NOTE: Check for the external tools needed during the build process ^(i.e.\r
+REM       those that do not get compiled as part of the build process itself^)\r
+REM       along the PATH.\r
+REM\r
+FOR %%T IN (gawk.exe tclsh85.exe) DO (\r
+  SET %%T_PATH=%%~dp$PATH:T\r
+)\r
+\r
+REM\r
+REM NOTE: Set the TOOLPATH variable to contain all the directories where the\r
+REM       external tools were found in the search above.\r
+REM\r
+SET TOOLPATH=%gawk.exe_PATH%;%tclsh85.exe_PATH%\r
+\r
+%_VECHO% ToolPath = '%TOOLPATH%'\r
+\r
+REM\r
+REM NOTE: This is the outer loop.  There should be exactly one iteration per\r
+REM       platform.\r
+REM\r
+FOR %%P IN (%PLATFORMS%) DO (\r
+  REM\r
+  REM NOTE: Using the MSVC platform name, lookup the simpler platform name to\r
+  REM       be used for the name of the platform-specific binary directory via\r
+  REM       the environment variables setup earlier.\r
+  REM\r
+  CALL :fn_SetVariable %%P_NAME PLATFORMNAME\r
+\r
+  REM\r
+  REM NOTE: This is the inner loop.  There should be exactly one iteration.\r
+  REM       This loop is necessary because the PlatformName environment\r
+  REM       variable was set above and that value is needed by some of the\r
+  REM       commands contained in the inner loop.  If these commands were\r
+  REM       directly contained in the outer loop, the PlatformName environment\r
+  REM       variable would be stuck with its initial empty value instead.\r
+  REM\r
+  FOR /F "tokens=2* delims==" %%D IN ('SET PLATFORMNAME') DO (\r
+    REM\r
+    REM NOTE: Attempt to clean the environment of all variables used by MSVC\r
+    REM       and/or Visual Studio.  This block may need to be updated in the\r
+    REM       future to account for additional environment variables.\r
+    REM\r
+    CALL :fn_UnsetVariable DevEnvDir\r
+    CALL :fn_UnsetVariable Framework35Version\r
+    CALL :fn_UnsetVariable FrameworkDir\r
+    CALL :fn_UnsetVariable FrameworkDir32\r
+    CALL :fn_UnsetVariable FrameworkVersion\r
+    CALL :fn_UnsetVariable FrameworkVersion32\r
+    CALL :fn_UnsetVariable INCLUDE\r
+    CALL :fn_UnsetVariable LIB\r
+    CALL :fn_UnsetVariable LIBPATH\r
+    CALL :fn_UnsetVariable Platform\r
+    REM CALL :fn_UnsetVariable VCINSTALLDIR\r
+    CALL :fn_UnsetVariable VSINSTALLDIR\r
+    CALL :fn_UnsetVariable WindowsSdkDir\r
+\r
+    REM\r
+    REM NOTE: Reset the PATH here to the absolute bare minimum required.\r
+    REM\r
+    SET PATH=%TOOLPATH%;%SystemRoot%\System32;%SystemRoot%\r
+\r
+    %_VECHO% Path = '%PATH%'\r
+\r
+    REM\r
+    REM NOTE: Launch a nested command shell to perform the following steps:\r
+    REM\r
+    REM       1. Setup the MSVC environment for this platform using the\r
+    REM          official batch file.\r
+    REM\r
+    REM       2. Make sure that no stale build output files are present.\r
+    REM\r
+    REM       3. Build the "sqlite3.dll" and "sqlite3.lib" binaries for this\r
+    REM          platform.\r
+    REM\r
+    REM       4. Copy the "sqlite3.dll" and "sqlite3.lib" binaries for this\r
+    REM          platform to the platform-specific directory beneath the\r
+    REM          binary directory.\r
+    REM\r
+    "%ComSpec%" /C (\r
+      REM\r
+      REM NOTE: Attempt to setup the MSVC environment for this platform.\r
+      REM\r
+      %__ECHO% CALL "%VCINSTALLDIR%\vcvarsall.bat" %%P\r
+\r
+      IF ERRORLEVEL 1 (\r
+        ECHO Failed to call "%VCINSTALLDIR%\vcvarsall.bat" for platform %%P.\r
+        GOTO errors\r
+      )\r
+\r
+      REM\r
+      REM NOTE: If this batch file is not running in "what-if" mode, check to\r
+      REM       be sure we were actually able to setup the MSVC environment as\r
+      REM       current versions of their official batch file do not set the\r
+      REM       exit code upon failure.\r
+      REM\r
+      IF NOT DEFINED __ECHO (\r
+        IF NOT DEFINED WindowsSdkDir (\r
+          ECHO Cannot build, Windows SDK not found for platform %%P.\r
+          GOTO errors\r
+        )\r
+      )\r
+\r
+      REM\r
+      REM NOTE: Invoke NMAKE with the MSVC makefile to clean any stale build\r
+      REM       output from previous iterations of this loop and/or previous\r
+      REM       runs of this batch file, etc.\r
+      REM\r
+      %__ECHO% nmake -f Makefile.msc clean\r
+\r
+      IF ERRORLEVEL 1 (\r
+        ECHO Failed to clean for platform %%P.\r
+        GOTO errors\r
+      )\r
+\r
+      REM\r
+      REM NOTE: Invoke NMAKE with the MSVC makefile to build the "sqlite3.dll"\r
+      REM       binary.  The x86 compiler will be used to compile the native\r
+      REM       command line tools needed during the build process itself.\r
+      REM       Also, disable looking for and/or linking to the native Tcl\r
+      REM       runtime library.\r
+      REM\r
+      %__ECHO% nmake -f Makefile.msc sqlite3.dll "NCC=""%VCINSTALLDIR%\bin\cl.exe""" USE_NATIVE_LIBPATHS=1 NO_TCL=1 %NMAKE_ARGS%\r
+\r
+      IF ERRORLEVEL 1 (\r
+        ECHO Failed to build "sqlite3.dll" for platform %%P.\r
+        GOTO errors\r
+      )\r
+\r
+      REM\r
+      REM NOTE: Copy the "sqlite3.dll" file to the platform-specific directory\r
+      REM       beneath the binary directory.\r
+      REM\r
+      %__ECHO% XCOPY sqlite3.dll "%BINARYDIRECTORY%\%%D\" %FFLAGS% %DFLAGS%\r
+\r
+      IF ERRORLEVEL 1 (\r
+        ECHO Failed to copy "sqlite3.dll" to "%BINARYDIRECTORY%\%%D\".\r
+        GOTO errors\r
+      )\r
+\r
+      REM\r
+      REM NOTE: Copy the "sqlite3.lib" file to the platform-specific directory\r
+      REM       beneath the binary directory.\r
+      REM\r
+      %__ECHO% XCOPY sqlite3.lib "%BINARYDIRECTORY%\%%D\" %FFLAGS% %DFLAGS%\r
+\r
+      IF ERRORLEVEL 1 (\r
+        ECHO Failed to copy "sqlite3.lib" to "%BINARYDIRECTORY%\%%D\".\r
+        GOTO errors\r
+      )\r
+    )\r
+  )\r
+\r
+  REM\r
+  REM NOTE: Handle any errors generated during the nested command shell.\r
+  REM\r
+  IF ERRORLEVEL 1 (\r
+    GOTO errors\r
+  )\r
+)\r
+\r
+REM\r
+REM NOTE: Restore the saved current directory from the directory stack.\r
+REM\r
+%__ECHO2% POPD\r
+\r
+IF ERRORLEVEL 1 (\r
+  ECHO Could not restore directory.\r
+  GOTO errors\r
+)\r
+\r
+REM\r
+REM NOTE: If we get to this point, we have succeeded.\r
+REM\r
+GOTO no_errors\r
+\r
+:fn_ResetErrorLevel\r
+  VERIFY > NUL\r
+  GOTO :EOF\r
+\r
+:fn_SetErrorLevel\r
+  VERIFY MAYBE 2> NUL\r
+  GOTO :EOF\r
+\r
+:fn_SetVariable\r
+  SETLOCAL\r
+  IF NOT DEFINED %1 GOTO :EOF\r
+  IF "%2" == "" GOTO :EOF\r
+  SET __ECHO_CMD=ECHO %%%1%%\r
+  FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO (\r
+    SET VALUE=%%V\r
+  )\r
+  ENDLOCAL && SET %2=%VALUE%\r
+  GOTO :EOF\r
+\r
+:fn_UnsetVariable\r
+  IF NOT "%1" == "" (\r
+    SET %1=\r
+    CALL :fn_ResetErrorLevel\r
+  )\r
+  GOTO :EOF\r
+\r
+:usage\r
+  ECHO.\r
+  ECHO Usage: %~nx0 ^<binaryDirectory^>\r
+  ECHO.\r
+  GOTO errors\r
+\r
+:errors\r
+  CALL :fn_SetErrorLevel\r
+  ENDLOCAL\r
+  ECHO.\r
+  ECHO Failure, errors were encountered.\r
+  GOTO end_of_file\r
+\r
+:no_errors\r
+  CALL :fn_ResetErrorLevel\r
+  ENDLOCAL\r
+  ECHO.\r
+  ECHO Success, no errors were encountered.\r
+  GOTO end_of_file\r
+\r
+:end_of_file\r
+%__ECHO% EXIT /B %ERRORLEVEL%\r