mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 1 | @ECHO OFF
|
| 2 |
|
| 3 | ::
|
| 4 | :: build-all-msvc.bat --
|
| 5 | ::
|
| 6 | :: Multi-Platform Build Tool for MSVC
|
| 7 | ::
|
| 8 |
|
mistachkin | 7c5dbdf | 2012-10-19 00:23:31 +0000 | [diff] [blame] | 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 There are several environment variables that may be set to modify the
|
| 32 | REM behavior of this batch script and its associated Makefile. The list of
|
| 33 | REM platforms to build may be overriden by using the PLATFORMS environment
|
| 34 | REM variable, which should contain a list of platforms ^(e.g. x86 x86_amd64
|
| 35 | REM x86_arm^). All platforms must be supported by the version of Visual Studio
|
| 36 | REM being used. The list of configurations to build may be overridden by
|
| 37 | REM setting the CONFIGURATIONS environment variable, which should contain a
|
| 38 | REM list of configurations to build ^(e.g. Debug Retail^). Neither of these
|
| 39 | REM variable values may contain any double quotes, surrounding or embedded.
|
| 40 | REM Finally, the NCRTLIBPATH and NSDKLIBPATH environment variables may be set
|
| 41 | REM to specify the location of the CRT and SDK, respectively, needed to compile
|
| 42 | REM executables native to the architecture of the build machine during any
|
| 43 | REM cross-compilation that may be necessary, depending on the platforms to be
|
| 44 | REM built. These values in these two variables should be surrounded by double
|
| 45 | REM quotes if they contain spaces.
|
| 46 | REM
|
| 47 | REM Please note that the SQLite build process performed by the Makefile
|
| 48 | REM associated with this batch script requires both Gawk ^(gawk.exe^) and Tcl
|
| 49 | REM 8.5 ^(tclsh85.exe^) to be present in a directory contained in the PATH
|
| 50 | REM environment variable unless a pre-existing amalgamation file is used.
|
| 51 | REM
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 52 | SETLOCAL
|
| 53 |
|
| 54 | REM SET __ECHO=ECHO
|
| 55 | REM SET __ECHO2=ECHO
|
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 56 | REM SET __ECHO3=ECHO
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 57 | IF NOT DEFINED _AECHO (SET _AECHO=REM)
|
| 58 | IF NOT DEFINED _CECHO (SET _CECHO=REM)
|
| 59 | IF NOT DEFINED _VECHO (SET _VECHO=REM)
|
| 60 |
|
| 61 | %_AECHO% Running %0 %*
|
| 62 |
|
| 63 | REM SET DFLAGS=/L
|
| 64 |
|
| 65 | %_VECHO% DFlags = '%DFLAGS%'
|
| 66 |
|
| 67 | SET FFLAGS=/V /F /G /H /I /R /Y /Z
|
| 68 |
|
| 69 | %_VECHO% FFlags = '%FFLAGS%'
|
| 70 |
|
| 71 | SET ROOT=%~dp0\..
|
| 72 | SET ROOT=%ROOT:\\=\%
|
| 73 |
|
| 74 | %_VECHO% Root = '%ROOT%'
|
| 75 |
|
| 76 | REM
|
| 77 | REM NOTE: The first and only argument to this batch file should be the output
|
| 78 | REM directory where the platform-specific binary directories should be
|
| 79 | REM created.
|
| 80 | REM
|
| 81 | SET BINARYDIRECTORY=%1
|
| 82 |
|
| 83 | IF NOT DEFINED BINARYDIRECTORY (
|
| 84 | GOTO usage
|
| 85 | )
|
| 86 |
|
| 87 | %_VECHO% BinaryDirectory = '%BINARYDIRECTORY%'
|
| 88 |
|
| 89 | SET DUMMY=%2
|
| 90 |
|
| 91 | IF DEFINED DUMMY (
|
| 92 | GOTO usage
|
| 93 | )
|
| 94 |
|
| 95 | REM
|
| 96 | REM NOTE: From this point, we need a clean error level. Reset it now.
|
| 97 | REM
|
| 98 | CALL :fn_ResetErrorLevel
|
| 99 |
|
| 100 | REM
|
| 101 | REM NOTE: Change the current directory to the root of the source tree, saving
|
| 102 | REM the current directory on the directory stack.
|
| 103 | REM
|
| 104 | %__ECHO2% PUSHD "%ROOT%"
|
| 105 |
|
| 106 | IF ERRORLEVEL 1 (
|
| 107 | ECHO Could not change directory to "%ROOT%".
|
| 108 | GOTO errors
|
| 109 | )
|
| 110 |
|
| 111 | REM
|
| 112 | REM NOTE: This batch file requires the ComSpec environment variable to be set,
|
| 113 | REM typically to something like "C:\Windows\System32\cmd.exe".
|
| 114 | REM
|
| 115 | IF NOT DEFINED ComSpec (
|
| 116 | ECHO The ComSpec environment variable must be defined.
|
| 117 | GOTO errors
|
| 118 | )
|
| 119 |
|
| 120 | REM
|
| 121 | REM NOTE: This batch file requires the VcInstallDir environment variable to be
|
| 122 | REM set. Tyipcally, this means this batch file needs to be run from an
|
| 123 | REM MSVC command prompt.
|
| 124 | REM
|
| 125 | IF NOT DEFINED VCINSTALLDIR (
|
| 126 | ECHO The VCINSTALLDIR environment variable must be defined.
|
| 127 | GOTO errors
|
| 128 | )
|
| 129 |
|
| 130 | REM
|
| 131 | REM NOTE: If the list of platforms is not already set, use the default list.
|
| 132 | REM
|
| 133 | IF NOT DEFINED PLATFORMS (
|
| 134 | SET PLATFORMS=x86 x86_amd64 x86_arm
|
| 135 | )
|
| 136 |
|
| 137 | %_VECHO% Platforms = '%PLATFORMS%'
|
| 138 |
|
| 139 | REM
|
mistachkin | 7c5dbdf | 2012-10-19 00:23:31 +0000 | [diff] [blame] | 140 | REM NOTE: If the list of configurations is not already set, use the default
|
| 141 | REM list.
|
| 142 | REM
|
| 143 | IF NOT DEFINED CONFIGURATIONS (
|
| 144 | SET CONFIGURATIONS=Debug Retail
|
| 145 | )
|
| 146 |
|
| 147 | %_VECHO% Configurations = '%CONFIGURATIONS%'
|
| 148 |
|
| 149 | REM
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 150 | REM NOTE: Setup environment variables to translate between the MSVC platform
|
| 151 | REM names and the names to be used for the platform-specific binary
|
| 152 | REM directories.
|
| 153 | REM
|
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 154 | SET amd64_NAME=x64
|
| 155 | SET arm_NAME=ARM
|
| 156 | SET x64_NAME=x64
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 157 | SET x86_NAME=x86
|
| 158 | SET x86_amd64_NAME=x64
|
| 159 | SET x86_arm_NAME=ARM
|
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 160 | SET x86_x64_NAME=x64
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 161 |
|
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 162 | %_VECHO% amd64_Name = '%amd64_NAME%'
|
| 163 | %_VECHO% arm_Name = '%arm_NAME%'
|
| 164 | %_VECHO% x64_Name = '%x64_NAME%'
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 165 | %_VECHO% x86_Name = '%x86_NAME%'
|
| 166 | %_VECHO% x86_amd64_Name = '%x86_amd64_NAME%'
|
| 167 | %_VECHO% x86_arm_Name = '%x86_arm_NAME%'
|
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 168 | %_VECHO% x86_x64_Name = '%x86_x64_NAME%'
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 169 |
|
| 170 | REM
|
| 171 | REM NOTE: Check for the external tools needed during the build process ^(i.e.
|
| 172 | REM those that do not get compiled as part of the build process itself^)
|
| 173 | REM along the PATH.
|
| 174 | REM
|
| 175 | FOR %%T IN (gawk.exe tclsh85.exe) DO (
|
| 176 | SET %%T_PATH=%%~dp$PATH:T
|
| 177 | )
|
| 178 |
|
| 179 | REM
|
mistachkin | 7c5dbdf | 2012-10-19 00:23:31 +0000 | [diff] [blame] | 180 | REM NOTE: The Gawk executable "gawk.exe" is required during the SQLite build
|
| 181 | REM process unless a pre-existing amalgamation file is used.
|
| 182 | REM
|
| 183 | IF NOT DEFINED gawk.exe_PATH (
|
| 184 | ECHO The Gawk executable "gawk.exe" is required to be in the PATH.
|
| 185 | GOTO errors
|
| 186 | )
|
| 187 |
|
| 188 | REM
|
| 189 | REM NOTE: The Tcl 8.5 executable "tclsh85.exe" is required during the SQLite
|
| 190 | REM build process unless a pre-existing amalgamation file is used.
|
| 191 | REM
|
| 192 | IF NOT DEFINED tclsh85.exe_PATH (
|
| 193 | ECHO The Tcl 8.5 executable "tclsh85.exe" is required to be in the PATH.
|
| 194 | GOTO errors
|
| 195 | )
|
| 196 |
|
| 197 | REM
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 198 | REM NOTE: Set the TOOLPATH variable to contain all the directories where the
|
| 199 | REM external tools were found in the search above.
|
| 200 | REM
|
| 201 | SET TOOLPATH=%gawk.exe_PATH%;%tclsh85.exe_PATH%
|
| 202 |
|
| 203 | %_VECHO% ToolPath = '%TOOLPATH%'
|
| 204 |
|
| 205 | REM
|
mistachkin | 5042054 | 2013-06-20 18:53:33 +0000 | [diff] [blame] | 206 | REM NOTE: Check for MSVC 2012/2013 because the Windows SDK directory handling
|
| 207 | REM is slightly different for those versions.
|
mistachkin | fd0ba2a | 2012-07-27 08:21:45 +0000 | [diff] [blame] | 208 | REM
|
| 209 | IF "%VisualStudioVersion%" == "11.0" (
|
mistachkin | 7c5dbdf | 2012-10-19 00:23:31 +0000 | [diff] [blame] | 210 | REM
|
| 211 | REM NOTE: If the Windows SDK library path has already been set, do not set
|
| 212 | REM it to something else later on.
|
| 213 | REM
|
| 214 | IF NOT DEFINED NSDKLIBPATH (
|
| 215 | SET SET_NSDKLIBPATH=1
|
| 216 | )
|
mistachkin | 5042054 | 2013-06-20 18:53:33 +0000 | [diff] [blame] | 217 | ) ELSE IF "%VisualStudioVersion%" == "12.0" (
|
| 218 | REM
|
| 219 | REM NOTE: If the Windows SDK library path has already been set, do not set
|
| 220 | REM it to something else later on.
|
| 221 | REM
|
| 222 | IF NOT DEFINED NSDKLIBPATH (
|
| 223 | SET SET_NSDKLIBPATH=1
|
| 224 | )
|
mistachkin | fd0ba2a | 2012-07-27 08:21:45 +0000 | [diff] [blame] | 225 | ) ELSE (
|
| 226 | CALL :fn_UnsetVariable SET_NSDKLIBPATH
|
| 227 | )
|
| 228 |
|
| 229 | REM
|
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 230 | REM NOTE: Check if this is the Windows Phone SDK. If so, a different batch
|
| 231 | REM file is necessary to setup the build environment. Since the variable
|
| 232 | REM values involved here may contain parenthesis, using GOTO instead of
|
| 233 | REM an IF block is required.
|
| 234 | REM
|
| 235 | IF DEFINED WindowsPhoneKitDir GOTO set_vcvarsall_phone
|
| 236 | SET VCVARSALL=%VCINSTALLDIR%\vcvarsall.bat
|
| 237 | GOTO set_vcvarsall_done
|
| 238 | :set_vcvarsall_phone
|
| 239 | SET VCVARSALL=%VCINSTALLDIR%\WPSDK\WP80\vcvarsphoneall.bat
|
| 240 | :set_vcvarsall_done
|
| 241 |
|
| 242 | REM
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 243 | REM NOTE: This is the outer loop. There should be exactly one iteration per
|
| 244 | REM platform.
|
| 245 | REM
|
| 246 | FOR %%P IN (%PLATFORMS%) DO (
|
| 247 | REM
|
| 248 | REM NOTE: Using the MSVC platform name, lookup the simpler platform name to
|
| 249 | REM be used for the name of the platform-specific binary directory via
|
| 250 | REM the environment variables setup earlier.
|
| 251 | REM
|
mistachkin | d744fcc | 2012-10-05 07:36:34 +0000 | [diff] [blame] | 252 | CALL :fn_CopyVariable %%P_NAME PLATFORMNAME
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 253 |
|
| 254 | REM
|
mistachkin | 293566e | 2013-10-31 06:39:15 +0000 | [diff] [blame] | 255 | REM NOTE: This is the second loop. There should be exactly one iteration.
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 256 | REM This loop is necessary because the PlatformName environment
|
| 257 | REM variable was set above and that value is needed by some of the
|
| 258 | REM commands contained in the inner loop. If these commands were
|
| 259 | REM directly contained in the outer loop, the PlatformName environment
|
| 260 | REM variable would be stuck with its initial empty value instead.
|
| 261 | REM
|
| 262 | FOR /F "tokens=2* delims==" %%D IN ('SET PLATFORMNAME') DO (
|
| 263 | REM
|
| 264 | REM NOTE: Attempt to clean the environment of all variables used by MSVC
|
| 265 | REM and/or Visual Studio. This block may need to be updated in the
|
| 266 | REM future to account for additional environment variables.
|
| 267 | REM
|
| 268 | CALL :fn_UnsetVariable DevEnvDir
|
mistachkin | fd0ba2a | 2012-07-27 08:21:45 +0000 | [diff] [blame] | 269 | CALL :fn_UnsetVariable ExtensionSdkDir
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 270 | CALL :fn_UnsetVariable Framework35Version
|
| 271 | CALL :fn_UnsetVariable FrameworkDir
|
| 272 | CALL :fn_UnsetVariable FrameworkDir32
|
| 273 | CALL :fn_UnsetVariable FrameworkVersion
|
| 274 | CALL :fn_UnsetVariable FrameworkVersion32
|
mistachkin | fd0ba2a | 2012-07-27 08:21:45 +0000 | [diff] [blame] | 275 | CALL :fn_UnsetVariable FSHARPINSTALLDIR
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 276 | CALL :fn_UnsetVariable INCLUDE
|
| 277 | CALL :fn_UnsetVariable LIB
|
| 278 | CALL :fn_UnsetVariable LIBPATH
|
| 279 | CALL :fn_UnsetVariable Platform
|
| 280 | REM CALL :fn_UnsetVariable VCINSTALLDIR
|
| 281 | CALL :fn_UnsetVariable VSINSTALLDIR
|
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 282 | CALL :fn_UnsetVariable WindowsPhoneKitDir
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 283 | CALL :fn_UnsetVariable WindowsSdkDir
|
mistachkin | fd0ba2a | 2012-07-27 08:21:45 +0000 | [diff] [blame] | 284 | CALL :fn_UnsetVariable WindowsSdkDir_35
|
| 285 | CALL :fn_UnsetVariable WindowsSdkDir_old
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 286 |
|
| 287 | REM
|
| 288 | REM NOTE: Reset the PATH here to the absolute bare minimum required.
|
| 289 | REM
|
| 290 | SET PATH=%TOOLPATH%;%SystemRoot%\System32;%SystemRoot%
|
| 291 |
|
mistachkin | 293566e | 2013-10-31 06:39:15 +0000 | [diff] [blame] | 292 | REM
|
| 293 | REM NOTE: This is the inner loop. There are normally two iterations, one
|
| 294 | REM for each supported build configuration, e.g. Debug or Retail.
|
| 295 | REM
|
mistachkin | 7c5dbdf | 2012-10-19 00:23:31 +0000 | [diff] [blame] | 296 | FOR %%B IN (%CONFIGURATIONS%) DO (
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 297 | REM
|
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 298 | REM NOTE: When preparing the debug build, set the DEBUG and MEMDEBUG
|
| 299 | REM environment variables to be picked up by the MSVC makefile
|
| 300 | REM itself.
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 301 | REM
|
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 302 | IF /I "%%B" == "Debug" (
|
| 303 | SET DEBUG=2
|
| 304 | SET MEMDEBUG=1
|
mistachkin | 0b5ae72 | 2012-07-27 23:03:47 +0000 | [diff] [blame] | 305 | ) ELSE (
|
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 306 | CALL :fn_UnsetVariable DEBUG
|
| 307 | CALL :fn_UnsetVariable MEMDEBUG
|
| 308 | )
|
| 309 |
|
| 310 | REM
|
| 311 | REM NOTE: Launch a nested command shell to perform the following steps:
|
| 312 | REM
|
| 313 | REM 1. Setup the MSVC environment for this platform using the
|
| 314 | REM official batch file.
|
| 315 | REM
|
| 316 | REM 2. Make sure that no stale build output files are present.
|
| 317 | REM
|
| 318 | REM 3. Build the "sqlite3.dll" and "sqlite3.lib" binaries for this
|
| 319 | REM platform.
|
| 320 | REM
|
| 321 | REM 4. Copy the "sqlite3.dll" and "sqlite3.lib" binaries for this
|
| 322 | REM platform to the platform-specific directory beneath the
|
| 323 | REM binary directory.
|
| 324 | REM
|
mistachkin | 293566e | 2013-10-31 06:39:15 +0000 | [diff] [blame] | 325 | REM 5. Unless prevented from doing so, copy the "sqlite3.pdb"
|
| 326 | REM symbols file for this platform to the platform-specific
|
| 327 | REM directory beneath the binary directory.
|
| 328 | REM
|
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 329 | "%ComSpec%" /C (
|
mistachkin | 0b5ae72 | 2012-07-27 23:03:47 +0000 | [diff] [blame] | 330 | REM
|
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 331 | REM NOTE: Attempt to setup the MSVC environment for this platform.
|
mistachkin | 0b5ae72 | 2012-07-27 23:03:47 +0000 | [diff] [blame] | 332 | REM
|
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 333 | %__ECHO3% CALL "%VCVARSALL%" %%P
|
mistachkin | 391b364 | 2012-07-31 00:43:31 +0000 | [diff] [blame] | 334 |
|
| 335 | IF ERRORLEVEL 1 (
|
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 336 | ECHO Failed to call "%VCVARSALL%" for platform %%P.
|
mistachkin | 391b364 | 2012-07-31 00:43:31 +0000 | [diff] [blame] | 337 | GOTO errors
|
| 338 | )
|
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 339 |
|
| 340 | REM
|
| 341 | REM NOTE: If this batch file is not running in "what-if" mode, check to
|
| 342 | REM be sure we were actually able to setup the MSVC environment
|
| 343 | REM as current versions of their official batch file do not set
|
| 344 | REM the exit code upon failure.
|
| 345 | REM
|
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 346 | IF NOT DEFINED __ECHO3 (
|
| 347 | IF NOT DEFINED WindowsPhoneKitDir (
|
| 348 | IF NOT DEFINED WindowsSdkDir (
|
| 349 | ECHO Cannot build, Windows SDK not found for platform %%P.
|
| 350 | GOTO errors
|
| 351 | )
|
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 352 | )
|
| 353 | )
|
| 354 |
|
| 355 | REM
|
mistachkin | 293566e | 2013-10-31 06:39:15 +0000 | [diff] [blame] | 356 | REM NOTE: When using MSVC 2012 and/or 2013, the native SDK path cannot
|
| 357 | REM simply use the "lib" sub-directory beneath the location
|
| 358 | REM specified in the WindowsSdkDir environment variable because
|
| 359 | REM that location does not actually contain the necessary library
|
| 360 | REM files for x86. This must be done for each iteration because
|
| 361 | REM it relies upon the WindowsSdkDir environment variable being
|
| 362 | REM set by the batch file used to setup the MSVC environment.
|
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 363 | REM
|
| 364 | IF DEFINED SET_NSDKLIBPATH (
|
mistachkin | 293566e | 2013-10-31 06:39:15 +0000 | [diff] [blame] | 365 | REM
|
| 366 | REM NOTE: The Windows Phone SDK has a slightly different directory
|
| 367 | REM structure and must be handled specially here.
|
| 368 | REM
|
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 369 | IF DEFINED WindowsPhoneKitDir (
|
| 370 | CALL :fn_CopyVariable WindowsPhoneKitDir NSDKLIBPATH
|
| 371 | CALL :fn_AppendVariable NSDKLIBPATH \lib\x86
|
| 372 | ) ELSE IF DEFINED WindowsSdkDir (
|
| 373 | CALL :fn_CopyVariable WindowsSdkDir NSDKLIBPATH
|
mistachkin | 5042054 | 2013-06-20 18:53:33 +0000 | [diff] [blame] | 374 |
|
mistachkin | 293566e | 2013-10-31 06:39:15 +0000 | [diff] [blame] | 375 | REM
|
| 376 | REM NOTE: The Windows 8.1 SDK has a slightly different directory
|
| 377 | REM naming convention. Currently, this tool assumes that
|
| 378 | REM the Windows 8.1 SDK should only be used with MSVC 2013.
|
| 379 | REM
|
mistachkin | 5042054 | 2013-06-20 18:53:33 +0000 | [diff] [blame] | 380 | IF "%VisualStudioVersion%" == "12.0" (
|
| 381 | CALL :fn_AppendVariable NSDKLIBPATH \lib\winv6.3\um\x86
|
| 382 | ) ELSE (
|
| 383 | CALL :fn_AppendVariable NSDKLIBPATH \lib\win8\um\x86
|
| 384 | )
|
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 385 | )
|
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 386 | )
|
| 387 |
|
| 388 | REM
|
| 389 | REM NOTE: Unless prevented from doing so, invoke NMAKE with the MSVC
|
| 390 | REM makefile to clean any stale build output from previous
|
| 391 | REM iterations of this loop and/or previous runs of this batch
|
| 392 | REM file, etc.
|
| 393 | REM
|
| 394 | IF NOT DEFINED NOCLEAN (
|
| 395 | %__ECHO% nmake -f Makefile.msc clean
|
| 396 |
|
| 397 | IF ERRORLEVEL 1 (
|
| 398 | ECHO Failed to clean for platform %%P.
|
| 399 | GOTO errors
|
| 400 | )
|
| 401 | ) ELSE (
|
| 402 | REM
|
| 403 | REM NOTE: Even when the cleaning step has been disabled, we still
|
| 404 | REM need to remove the build output for the files we are
|
| 405 | REM specifically wanting to build for each platform.
|
| 406 | REM
|
mistachkin | 7530508 | 2013-06-07 22:12:20 +0000 | [diff] [blame] | 407 | %__ECHO% DEL /Q *.lo sqlite3.dll sqlite3.lib sqlite3.pdb
|
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 408 | )
|
| 409 |
|
| 410 | REM
|
| 411 | REM NOTE: Call NMAKE with the MSVC makefile to build the "sqlite3.dll"
|
| 412 | REM binary. The x86 compiler will be used to compile the native
|
| 413 | REM command line tools needed during the build process itself.
|
| 414 | REM Also, disable looking for and/or linking to the native Tcl
|
| 415 | REM runtime library.
|
| 416 | REM
|
| 417 | %__ECHO% nmake -f Makefile.msc sqlite3.dll XCOMPILE=1 USE_NATIVE_LIBPATHS=1 NO_TCL=1 %NMAKE_ARGS%
|
| 418 |
|
| 419 | IF ERRORLEVEL 1 (
|
| 420 | ECHO Failed to build %%B "sqlite3.dll" for platform %%P.
|
| 421 | GOTO errors
|
| 422 | )
|
| 423 |
|
| 424 | REM
|
| 425 | REM NOTE: Copy the "sqlite3.dll" file to the appropriate directory for
|
| 426 | REM the build and platform beneath the binary directory.
|
| 427 | REM
|
| 428 | %__ECHO% XCOPY sqlite3.dll "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS%
|
| 429 |
|
| 430 | IF ERRORLEVEL 1 (
|
| 431 | ECHO Failed to copy "sqlite3.dll" to "%BINARYDIRECTORY%\%%B\%%D\".
|
| 432 | GOTO errors
|
| 433 | )
|
| 434 |
|
| 435 | REM
|
| 436 | REM NOTE: Copy the "sqlite3.lib" file to the appropriate directory for
|
| 437 | REM the build and platform beneath the binary directory.
|
| 438 | REM
|
| 439 | %__ECHO% XCOPY sqlite3.lib "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS%
|
| 440 |
|
| 441 | IF ERRORLEVEL 1 (
|
| 442 | ECHO Failed to copy "sqlite3.lib" to "%BINARYDIRECTORY%\%%B\%%D\".
|
| 443 | GOTO errors
|
| 444 | )
|
| 445 |
|
| 446 | REM
|
| 447 | REM NOTE: Copy the "sqlite3.pdb" file to the appropriate directory for
|
| 448 | REM the build and platform beneath the binary directory unless we
|
| 449 | REM are prevented from doing so.
|
| 450 | REM
|
| 451 | IF NOT DEFINED NOSYMBOLS (
|
| 452 | %__ECHO% XCOPY sqlite3.pdb "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS%
|
| 453 |
|
| 454 | IF ERRORLEVEL 1 (
|
| 455 | ECHO Failed to copy "sqlite3.pdb" to "%BINARYDIRECTORY%\%%B\%%D\".
|
| 456 | GOTO errors
|
| 457 | )
|
| 458 | )
|
mistachkin | 391b364 | 2012-07-31 00:43:31 +0000 | [diff] [blame] | 459 | )
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 460 | )
|
| 461 | )
|
| 462 |
|
| 463 | REM
|
| 464 | REM NOTE: Handle any errors generated during the nested command shell.
|
| 465 | REM
|
| 466 | IF ERRORLEVEL 1 (
|
| 467 | GOTO errors
|
| 468 | )
|
| 469 | )
|
| 470 |
|
| 471 | REM
|
| 472 | REM NOTE: Restore the saved current directory from the directory stack.
|
| 473 | REM
|
| 474 | %__ECHO2% POPD
|
| 475 |
|
| 476 | IF ERRORLEVEL 1 (
|
| 477 | ECHO Could not restore directory.
|
| 478 | GOTO errors
|
| 479 | )
|
| 480 |
|
| 481 | REM
|
| 482 | REM NOTE: If we get to this point, we have succeeded.
|
| 483 | REM
|
| 484 | GOTO no_errors
|
| 485 |
|
| 486 | :fn_ResetErrorLevel
|
| 487 | VERIFY > NUL
|
| 488 | GOTO :EOF
|
| 489 |
|
| 490 | :fn_SetErrorLevel
|
| 491 | VERIFY MAYBE 2> NUL
|
| 492 | GOTO :EOF
|
| 493 |
|
mistachkin | d744fcc | 2012-10-05 07:36:34 +0000 | [diff] [blame] | 494 | :fn_CopyVariable
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 495 | IF NOT DEFINED %1 GOTO :EOF
|
| 496 | IF "%2" == "" GOTO :EOF
|
mistachkin | f201496 | 2013-11-22 00:49:43 +0000 | [diff] [blame] | 497 | SETLOCAL
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 498 | SET __ECHO_CMD=ECHO %%%1%%
|
| 499 | FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO (
|
| 500 | SET VALUE=%%V
|
| 501 | )
|
| 502 | ENDLOCAL && SET %2=%VALUE%
|
| 503 | GOTO :EOF
|
| 504 |
|
| 505 | :fn_UnsetVariable
|
| 506 | IF NOT "%1" == "" (
|
| 507 | SET %1=
|
| 508 | CALL :fn_ResetErrorLevel
|
| 509 | )
|
| 510 | GOTO :EOF
|
| 511 |
|
mistachkin | fd0ba2a | 2012-07-27 08:21:45 +0000 | [diff] [blame] | 512 | :fn_AppendVariable
|
| 513 | SET __ECHO_CMD=ECHO %%%1%%
|
| 514 | IF DEFINED %1 (
|
| 515 | FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO (
|
| 516 | SET %1=%%V%~2
|
| 517 | )
|
| 518 | ) ELSE (
|
| 519 | SET %1=%~2
|
| 520 | )
|
| 521 | SET __ECHO_CMD=
|
| 522 | CALL :fn_ResetErrorLevel
|
| 523 | GOTO :EOF
|
| 524 |
|
mistachkin | 31856a3 | 2012-07-27 07:13:25 +0000 | [diff] [blame] | 525 | :usage
|
| 526 | ECHO.
|
| 527 | ECHO Usage: %~nx0 ^<binaryDirectory^>
|
| 528 | ECHO.
|
| 529 | GOTO errors
|
| 530 |
|
| 531 | :errors
|
| 532 | CALL :fn_SetErrorLevel
|
| 533 | ENDLOCAL
|
| 534 | ECHO.
|
| 535 | ECHO Failure, errors were encountered.
|
| 536 | GOTO end_of_file
|
| 537 |
|
| 538 | :no_errors
|
| 539 | CALL :fn_ResetErrorLevel
|
| 540 | ENDLOCAL
|
| 541 | ECHO.
|
| 542 | ECHO Success, no errors were encountered.
|
| 543 | GOTO end_of_file
|
| 544 |
|
| 545 | :end_of_file
|
| 546 | %__ECHO% EXIT /B %ERRORLEVEL%
|