From a09767b230e858f5fdb331532d3a73ef5f7137c2 Mon Sep 17 00:00:00 2001
From: mistachkin <mistachkin@noemail.net>
Date: Mon, 24 Aug 2015 17:18:43 +0000
Subject: [PATCH] Enhancements to the batch build tool for MSVC.

FossilOrigin-Name: a1ae20cd97456a1126cfa1a9bedce0bac0940ad6
---
 manifest                | 14 +++++++-------
 manifest.uuid           |  2 +-
 tool/build-all-msvc.bat | 30 +++++++++++++++++++++++++-----
 3 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/manifest b/manifest
index 9b3d236121..bc1fdc39c8 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Disallow\sthe\suse\sof\sCOLLATE\sclauses\sand\sthe\sASC\sand\sDESC\skeywords\swithin\nforeign\skey\sconstraints\sand\sin\sthe\sargument\slist\sto\scommon\stable\sexpressions.
-D 2015-08-24T15:39:42.405
+C Enhancements\sto\sthe\sbatch\sbuild\stool\sfor\sMSVC.
+D 2015-08-24T17:18:43.705
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in e2218eb228374422969de7b1680eda6864affcef
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -1323,7 +1323,7 @@ F test/without_rowid6.test db0dbf03c49030aa3c1ba5f618620334bd2baf5f
 F test/wordcount.c 9915e06cb33d8ca8109b8700791afe80d305afda
 F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa
 F test/zerodamage.test cf6748bad89553cc1632be51a6f54e487e4039ac
-F tool/build-all-msvc.bat 60dbf6021d3de0a98575f6dfe4e12bd80b3edcf0 x
+F tool/build-all-msvc.bat 761d8c82a1a529261291812732a853a1b4256d85 x
 F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367
 F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2
 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
@@ -1379,7 +1379,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 196d66d34d9783622e6f2f79eafea1488fc6f5cf
-R 2a74528f51d8172b5387a3b7f110bb2b
-U drh
-Z ffc4f8e604c67b08cae8ed1eda808a43
+P 83cbc4d8761498647794affffa961a4fca311be7
+R 854ee56e3c07dedcc4aa69e0f36f6060
+U mistachkin
+Z 2aa32a441452e19f6c0e00af3c0b6972
diff --git a/manifest.uuid b/manifest.uuid
index 9ca8f1fa75..fbc4c6a88f 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-83cbc4d8761498647794affffa961a4fca311be7
\ No newline at end of file
+a1ae20cd97456a1126cfa1a9bedce0bac0940ad6
\ No newline at end of file
diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat
index 25435838a3..4842dc4074 100755
--- a/tool/build-all-msvc.bat
+++ b/tool/build-all-msvc.bat
@@ -312,12 +312,26 @@ IF "%VisualStudioVersion%" == "11.0" (
   )
 )
 
+REM
+REM NOTE: This is the name of the sub-directory where the UCRT libraries may
+REM       be found.  It is only used when compiling against the UCRT.
+REM
+IF DEFINED UCRTVersion (
+  SET NUCRTVER=%UCRTVersion%
+) ELSE (
+  SET NUCRTVER=10.0.10240.0
+)
+
 REM
 REM NOTE: This is the name of the sub-directory where the Windows 10.0 SDK
 REM       libraries may be found.  It is only used when compiling with the
 REM       Windows 10.0 SDK.
 REM
-SET WIN10LIBDIR=10.0.10240.0
+IF DEFINED WindowsSDKLibVersion (
+  SET WIN10SDKVER=%WindowsSDKLibVersion:\=%
+) ELSE (
+  SET WIN10SDKVER=%NUCRTVER%
+)
 
 REM
 REM NOTE: Check if this is the Windows Phone SDK.  If so, a different batch
@@ -361,6 +375,7 @@ FOR %%P IN (%PLATFORMS%) DO (
     REM
     CALL :fn_UnsetVariable CommandPromptType
     CALL :fn_UnsetVariable DevEnvDir
+    CALL :fn_UnsetVariable DNX_HOME
     CALL :fn_UnsetVariable ExtensionSdkDir
     CALL :fn_UnsetVariable Framework35Version
     CALL :fn_UnsetVariable Framework40Version
@@ -372,14 +387,19 @@ FOR %%P IN (%PLATFORMS%) DO (
     CALL :fn_UnsetVariable INCLUDE
     CALL :fn_UnsetVariable LIB
     CALL :fn_UnsetVariable LIBPATH
+    CALL :fn_UnsetVariable NETFXSDKDir
     CALL :fn_UnsetVariable Platform
+    CALL :fn_UnsetVariable UCRTVersion
     CALL :fn_UnsetVariable UniversalCRTSdkDir
     REM CALL :fn_UnsetVariable VCINSTALLDIR
     CALL :fn_UnsetVariable VSINSTALLDIR
+    CALL :fn_UnsetVariable WindowsLibPath
     CALL :fn_UnsetVariable WindowsPhoneKitDir
     CALL :fn_UnsetVariable WindowsSdkDir
     CALL :fn_UnsetVariable WindowsSdkDir_35
     CALL :fn_UnsetVariable WindowsSdkDir_old
+    CALL :fn_UnsetVariable WindowsSDKLibVersion
+    CALL :fn_UnsetVariable WindowsSDKVersion
     CALL :fn_UnsetVariable WindowsSDK_ExecutablePath_x86
     CALL :fn_UnsetVariable WindowsSDK_ExecutablePath_x64
 
@@ -489,9 +509,9 @@ FOR %%P IN (%PLATFORMS%) DO (
             REM       different directory naming conventions.
             REM
             IF DEFINED USE_WINV100_NSDKLIBPATH (
-              CALL :fn_AppendVariable NSDKLIBPATH \..\10\lib\%WIN10LIBDIR%\um\x86
-              CALL :fn_CopyVariable UniversalCRTSdkDir PSDKLIBPATH
-              CALL :fn_AppendVariable PSDKLIBPATH Lib\%WIN10LIBDIR%\um\%%D
+              CALL :fn_AppendVariable NSDKLIBPATH \..\10\lib\%WIN10SDKVER%\um\x86
+              CALL :fn_CopyVariable WindowsSdkDir PSDKLIBPATH
+              CALL :fn_AppendVariable PSDKLIBPATH lib\%WIN10SDKVER%\um\%%D
             ) ELSE IF DEFINED USE_WINV63_NSDKLIBPATH (
               CALL :fn_AppendVariable NSDKLIBPATH \lib\winv6.3\um\x86
             ) ELSE IF "%VisualStudioVersion%" == "12.0" (
@@ -514,7 +534,7 @@ FOR %%P IN (%PLATFORMS%) DO (
         IF DEFINED SET_NUCRTLIBPATH (
           IF DEFINED UniversalCRTSdkDir (
             CALL :fn_CopyVariable UniversalCRTSdkDir NUCRTLIBPATH
-            CALL :fn_AppendVariable NUCRTLIBPATH \lib\%WIN10LIBDIR%\ucrt\x86
+            CALL :fn_AppendVariable NUCRTLIBPATH \lib\%NUCRTVER%\ucrt\x86
           )
         )