From 1c13ee29a955a5c7cbc325e8e406ea28693aa986 Mon Sep 17 00:00:00 2001 From: "skylined@chromium.org" Date: Mon, 8 Jun 2009 14:03:47 +0000 Subject: [PATCH] Automatic searching for vcvars.bat and report an error if the file cannot be found. This is needed if you do not have VS in your PATH on purpose and makes life easy if you do not have it there by accident. Review URL: http://codereview.chromium.org/112098 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@17854 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome-update.bat | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/chrome-update.bat b/chrome-update.bat index a2e6359f7..305e9db3e 100755 --- a/chrome-update.bat +++ b/chrome-update.bat @@ -2,9 +2,33 @@ :: This batch file assumes that the correct version of python can be found in :: the current directory, and that you have Visual Studio 8 installed in the -:: default location. +:: default location. It will try to find Visual Studio in the default +:: installation paths for x86 and x64 versions of windows as well as through +:: the PATH environment variable. setlocal -call vcvars32.bat +IF EXIST "%ProgramFiles(x86)%\Microsoft Visual Studio 8\VC\bin\vcvars32.bat" ( + CALL "%ProgramFiles(x86)%\Microsoft Visual Studio 8\VC\bin\vcvars32.bat" +) ELSE IF EXIST "%ProgramFiles%\Microsoft Visual Studio 8\VC\bin\vcvars32.bat" ( + CALL "%ProgramFiles%\Microsoft Visual Studio 8\VC\bin\vcvars32.bat" +) ELSE ( + :: See "HELP CALL" for information on how to use %~$PATH:1 to find a file in + :: the PATH. + CALL :FIND_IN_PATH "vcvars32.bat" +) +:: If vcvasr32.bat cannot be found or there was a problem, stop execution. +IF %ERRORLEVEL%==1 GOTO :EOF python "%~dp0chrome-update.py" %* +GOTO :EOF + +:FIND_IN_PATH + :: %~$PATH:1 works like "which" on linux; use it to see if the file exists and + :: call it if found. If it cannot be found print an error and set errorlevel + IF EXIST "%~$PATH:1" ( + CALL "%~$PATH:1" + ) ELSE ( + ECHO Cannot find vcvars32.bat! (Do you have Visual Studio in your PATH?) + SET ERRORLEVEL=1 + ) + GOTO :EOF