From 702341ae6e8cd32989384f2c25e483160aa9b310 Mon Sep 17 00:00:00 2001 From: Henrique de Lima Date: Mon, 10 Aug 2020 16:08:51 -0300 Subject: [PATCH] Making the windows build script a bit faster by verifying if the msvc environment was set up previously and only setting it up if it wasn't (#1346) --- projects/scripts/build-windows.bat | 49 +++++++++++++++--------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/projects/scripts/build-windows.bat b/projects/scripts/build-windows.bat index 017cc410..276572c2 100644 --- a/projects/scripts/build-windows.bat +++ b/projects/scripts/build-windows.bat @@ -22,15 +22,38 @@ REM verbose, sorry. REM To skip to the actual building part of the script, search for ":BUILD" +REM Checks if cl is available and skips to the argument loop if it is +REM (Prevents calling vcvarsall every time you run this script) +WHERE cl >nul 2>nul +IF %ERRORLEVEL% == 0 goto READ_ARGS +REM Activate the msvc build environment if cl isn't available yet +IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" ( + set VC_INIT="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" +) ELSE IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" ( + set VC_INIT="C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" +) ELSE IF EXIST "C:\Program Files (x86)\Microsoft Visual C++ Build Tools\vcbuildtools.bat" ( + set VC_INIT="C:\Program Files (x86)\Microsoft Visual C++ Build Tools\vcbuildtools.bat" +) ELSE ( + REM Initialize your vc environment here if the defaults don't work + REM set VC_INIT="C:\your\path\here\vcvarsall.bat" + REM And then remove/comment out the following two lines + echo "Couldn't find vcvarsall.bat or vcbuildtools.bat, please set it manually." + exit /B +) +echo Setting up the msvc build environment, this could take some time but the next builds should be faster +REM Remove everything after %TARGET_PLATFORM% if you want to see +REM the vcvarsall.bat or vcbuildtools.bat output +call %VC_INIT% %TARGET_PLATFORM% > NUL 2>&1 + +:READ_ARGS REM For the ! variable notation setlocal EnableDelayedExpansion REM For shifting, which the command line argument parsing needs setlocal EnableExtensions - :ARG_LOOP set ARG=%1 -if "!ARG!" == "" ( goto PREPARE ) +if "!ARG!" == "" ( goto BUILD ) IF NOT "x!ARG!" == "x!ARG:h=!" ( goto HELP ) @@ -91,28 +114,6 @@ echo Build in debug, run, don't print at all: build-windows.bat -drqq exit /B -:PREPARE -REM Activate the msvc build environment -IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" ( - set VC_INIT="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" -) ELSE IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" ( - set VC_INIT="C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" -) ELSE IF EXIST "C:\Program Files (x86)\Microsoft Visual C++ Build Tools\vcbuildtools.bat" ( - set VC_INIT="C:\Program Files (x86)\Microsoft Visual C++ Build Tools\vcbuildtools.bat" -) ELSE ( - REM Initialize your vc environment here if the defaults don't work - REM set VC_INIT="C:\your\path\here\vcvarsall.bat" - REM And then remove/comment out the following two lines - echo "Couldn't find vcvarsall.bat or vcbuildtools.bat, please set it manually." - exit /B -) -IF DEFINED VERBOSE ( - call !VC_INIT! !TARGET_PLATFORM! -) ELSE ( - call !VC_INIT! !TARGET_PLATFORM! > NUL 2>&1 -) - - :BUILD REM Directories set "ROOT_DIR=%CD%"