Index: ninja.bat |
=================================================================== |
--- ninja.bat (revision 133516) |
+++ ninja.bat (working copy) |
@@ -25,18 +25,33 @@ |
) |
:done_dash_c |
+:: Try running the compiler. If it fails, then we assume we need to set up the |
+:: environment for the compiler. |
+:: TODO(scottmg): We should also try to detect if we have the right version |
+:: of the compiler too (i.e. If generation specified 2010, but we're running |
+:: from a 2008 command prompt). |
+cl 2>nul >nul |
+if not errorlevel 1 goto no_set_env |
+ |
if not exist "%cd_path%\set_environment.bat" ( |
echo ninja.bat: set_environment.bat not found in '%cd_path%'. Is -C arg correct? |
goto :EOF |
) |
call "%cd_path%\set_environment.bat" |
+:: Export only the path changes out of the script. |
+endlocal & set PATH=%PATH% & set INCLUDE=%INCLUDE% & set LIBPATH=%LIBPATH% & set LIB=%LIB% |
+ |
+:: To pair with below when we don't skip this block. |
+setlocal |
+ |
:: Add python to the path, many gyp rules assume it's there. |
:: Add ninja directory to the path (to find ninja and ninja-deplist-helper). |
-:: Then, export only the path changes out of the script so that next time we |
-:: just run ninja directly (otherwise, this script adds about 500-800ms to |
+:: Put it at the front so that ninja.exe is found before this wrapper so that |
+:: next time we just run it directly (otherwise, this script adds 500-800ms to |
:: ninja invocations). |
-endlocal & set PATH=%~dp0python_bin;%~dp0ninja-win;%PATH% & set INCLUDE=%INCLUDE% & set LIBPATH=%LIBPATH% & set LIB=%LIB% |
+:no_set_env |
+endlocal & set PATH=%~dp0python_bin;%~dp0ninja-win;%PATH% |
:: Now run the actual build. |
ninja.exe %* |