Sync with trunk revision r58045 to bring the corrections on configure.cmd and on...
[reactos.git] / configure.cmd
index c3fa0a6..b4b5908 100755 (executable)
@@ -1,5 +1,12 @@
 @echo off\r
 \r
+:: This is needed so as to avoid static expansion of environment variables\r
+:: inside if (...) conditionals.\r
+:: See http://stackoverflow.com/questions/305605/weird-scope-issue-in-bat-file\r
+:: for more explanation.\r
+:: Precisely needed for configuring Visual Studio Environment.\r
+setlocal enabledelayedexpansion\r
+\r
 :: Special case %1 = arm_hosttools %2 = vcvarsall.bat %3 = %CMAKE_GENERATOR%\r
 if /I "%1" == "arm_hosttools" (\r
     echo Configuring x86 host tools for ARM cross build\r
@@ -46,7 +53,7 @@ if defined ROS_ARCH (
     set USE_WDK_HEADERS=0\r
 \r
 ) else if defined VCINSTALLDIR (\r
-    :: VS command prompt does not put this in enviroment vars\r
+    :: VS command prompt does not put this in environment vars\r
     cl 2>&1 | find "x86" > NUL && set ARCH=i386\r
     cl 2>&1 | find "x64" > NUL && set ARCH=amd64\r
     cl 2>&1 | find "ARM" > NUL && set ARCH=arm\r
@@ -59,30 +66,30 @@ if defined ROS_ARCH (
         exit /b\r
     )\r
 \r
-    echo Detected Visual Studio Environment %BUILD_ENVIRONMENT%-%ARCH%\r
+    echo Detected Visual Studio Environment !BUILD_ENVIRONMENT!-!ARCH!\r
     if /I "%1" == "VSSolution" (\r
-        if "%BUILD_ENVIRONMENT%" == "VS8" (\r
-            if "%ARCH%" == "amd64" (\r
+        if "!BUILD_ENVIRONMENT!" == "VS8" (\r
+            if "!ARCH!" == "amd64" (\r
                 set CMAKE_GENERATOR="Visual Studio 8 2005 Win64"\r
             ) else (\r
                 set CMAKE_GENERATOR="Visual Studio 8 2005"\r
             )\r
-        ) else if "%BUILD_ENVIRONMENT%" == "VS9" (\r
-            if "%ARCH%" == "amd64" (\r
+        ) else if "!BUILD_ENVIRONMENT!" == "VS9" (\r
+            if "!ARCH!" == "amd64" (\r
                 set CMAKE_GENERATOR="Visual Studio 9 2008 Win64"\r
             ) else (\r
                 set CMAKE_GENERATOR="Visual Studio 9 2008"\r
             )\r
-        ) else if "%BUILD_ENVIRONMENT%" == "VS10" (\r
-            if "%ARCH%" == "amd64" (\r
+        ) else if "!BUILD_ENVIRONMENT!" == "VS10" (\r
+            if "!ARCH!" == "amd64" (\r
                 set CMAKE_GENERATOR="Visual Studio 10 Win64"\r
             ) else (\r
                 set CMAKE_GENERATOR="Visual Studio 10"\r
             )\r
-        ) else if "%BUILD_ENVIRONMENT%" == "VS11" (\r
-            if "%ARCH%" == "amd64" (\r
+        ) else if "!BUILD_ENVIRONMENT!" == "VS11" (\r
+            if "!ARCH!" == "amd64" (\r
                 set CMAKE_GENERATOR="Visual Studio 11 Win64"\r
-            ) else if "%ARCH%" == "arm" (\r
+            ) else if "!ARCH!" == "arm" (\r
                 set CMAKE_GENERATOR="Visual Studio 11 ARM"\r
             ) else (\r
                 set CMAKE_GENERATOR="Visual Studio 11"\r
@@ -111,7 +118,7 @@ if defined ROS_ARCH (
 \r
 :: Checkpoint\r
 if not defined ARCH (\r
-    echo unknown build architecture\r
+    echo Unknown build architecture\r
     exit /b\r
 )\r
 \r