Commit 0ef1b2aa authored by scottmg@chromium.org's avatar scottmg@chromium.org

Don't set up environment for ninja if the compiler is already available

Previously when ninja.bat was run from a prompt that already had VS vars
available, it was adding them a second time. Depending on what else the user
had in the path, this could cause the path to become too long and so things at
the end wouldn't be found. To avoid this, check if the compiler is available
first, and don't run the environment set up in that case.

R=maruel@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10222010

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@133940 0039d316-1c4b-4281-b951-d872f2087c98
parent 63265df5
......@@ -25,18 +25,33 @@ for %%A in (%*) do (
)
: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 %*
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment