@if not "%verboseBuild%"=="y" echo off rem Shave and a Haircut rem (c) 2019 Epic Games rem US Patent 6720962 rem Arg 1 is 'vs10', 'vs11', 'vs14', etc rem Arg 2 is 'release' or 'debug' rem Arg 3 is '32' or '64' rem Args 4 through 9 are passed directly to the nmake command. setlocal set scriptName=do-nmake set usage=n rem Get the Visual Studio version. rem rem Note that we cannot use the newer if / else statements here because we rem are dealing with pathnames which may have parentheses in them which rem make Miscrosoft's bug-ridden command parser barf. if /i not "%1"=="vs7" goto elseif1 set vsVersion=vs7 set varName=VS71COMNTOOLS set commonToolsDir=%VS71COMNTOOLS% set vcDir=%VS71COMNTOOLS:~0,-14%Vc7 set dllDir=%VS71COMNTOOLS:~0,-6%IDE goto endif1 :elseif1 if /i not "%1"=="vs8" goto elseif2 set vsVersion=vs8 set varName=VS80COMNTOOLS set commonToolsDir=%VS80COMNTOOLS% set vcDir=%VS80COMNTOOLS:~0,-14%VC set dllDir=%VS80COMNTOOLS:~0,-6%IDE goto endif1 :elseif2 if /i not "%1"=="vs10" goto elseif3 set vsVersion=vs10 set varName=VS100COMNTOOLS set commonToolsDir=%VS100COMNTOOLS% set vcDir=%VS100COMNTOOLS:~0,-14%VC set dllDir=%VS100COMNTOOLS:~0,-6%IDE goto endif1 :elseif3 if /i not "%1"=="vs11" goto elseif4 set vsVersion=vs11 set varName=VS110COMNTOOLS set commonToolsDir=%VS110COMNTOOLS% set vcDir=%VS110COMNTOOLS:~0,-14%VC set dllDir=%VS110COMNTOOLS:~0,-6%IDE goto endif1 :elseif4 if /i not "%1"=="vs14" goto else1 set vsVersion=vs14 set varName=VS140COMNTOOLS set commonToolsDir=%VS140COMNTOOLS% set vcDir=%VS140COMNTOOLS:~0,-14%VC set dllDir=%VS140COMNTOOLS:~0,-6%IDE goto endif1 :else1 if "%1"=="" ( set usage=y ) else ( echo %scriptName%: Error: Visual Studio version '%1' not supported. Must be 'vs7', 'vs8', 'vs10', 'vs11' or 'vs14'. goto error ) :endif1 rem Get the build flavour. if /i "%2"=="release" ( set flavour=release ) else if /i "%2"=="debug" ( set flavour=debug ) else ( if "%2"=="" ( set usage=y ) else ( echo %scriptName%: Error: Build flavour '%2' not recognized. Must be 'release' or 'debug'. goto error ) ) if "%3"=="32" ( set setupScript=vcvars32.bat ) else if "%3"=="64" ( if "%vsVersion%"=="vs7" ( echo %scriptName%: Error: Visual Studio 7 does not support 64-bit builds goto error ) set setupScript=x86_amd64\vcvarsx86_amd64.bat ) else if "%3"=="" ( set usage=y ) else ( echo %scriptName%: Error: target platform bit size '%3' is invalid goto error ) if "%usage%"=="y" ( echo %scriptName%: Error: Usage is: %scriptName% vs11/vs14 release/debug 64 [nmake arguments] goto error ) set binDir=%vcDir%\Bin set incDir=%vcDir%\Include;%vcDir%\PlatformSDK\Include set libDir=%vcDir%\Lib;%vcDir%\PlatformSDK\Lib set buildDir=%flavour%-%vsVersion% if exist "%commonToolsDir%" goto endif2 echo %scriptName%: Error: %varName% does not point to the Visual Studio Common Tools directory goto error :endif2 if exist "%binDir%\nmake.exe" goto endif3 echo %scriptName%: Error: cannot find NMAKE.EXE in '%binDir%'. goto error :endif3 if exist "%binDir%\%setupScript%" goto endif4 echo %scriptName%: Error: could not find %vsVersion% setup script '%binDir%\%setupScript%' goto error :endif4 call "%binDir%\%setupScript%" >NUL 2>&1 echo on nmake FLAVOUR=%flavour% VSVERSION=%vsVersion% %4 %5 %6 %7 %8 %9 >do-nmake.log 2>&1 @if not "%verboseBuild%"=="y" echo off if errorlevel 1 ( type do-nmake.log goto error ) if "%verboseBuild%"=="y" type do-nmake.log endlocal set result=0 goto done :error endlocal set result=1 :done if exist do-nmake.log del do-nmake.log