From 11fed22dc70a33b50e4aeede0ed7b1ff10364d2b Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sat, 28 Dec 2019 14:54:46 -0800 Subject: [PATCH] Visual Studio Projects: Do parallel builds for multiple projects when VS > 2008 --- build_vstudio.bat | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/build_vstudio.bat b/build_vstudio.bat index fa86dbea..5b7f4669 100644 --- a/build_vstudio.bat +++ b/build_vstudio.bat @@ -1,4 +1,4 @@ -::@echo off +@echo off :: Rebuild all of SIMH simulators using Visual Studio :: :: If this procedure is not invoked from a Developer command prompt @@ -11,7 +11,7 @@ :: to build the simh projects. :: :: A single argument to this procedure may be the word Debug, which -:: will cause Debug binaries to be build rather than the Release +:: will cause Debug binaries to be built rather than the Release :: binaries which is the default. :: :: The default is to build all simulators mentioned in the simh solution. @@ -26,12 +26,16 @@ :: Initialize target variables set _BUILD_CONFIG=Release set _BUILD_PROJECTS= +set _REBUILD_PROJECTS= set _BUILD_PROJECT_DIR=%~dp0\Visual Studio Projects\ :_CheckArg if "%1" == "" goto _DoneArgs if /i "%1" == "Debug" set _BUILD_CONFIG=Debug& shift & goto _CheckArg if /i "%1" == "Release" set _BUILD_CONFIG=Release& shift & goto _CheckArg -if exist "%_BUILD_PROJECT_DIR%%1.vcproj" set _BUILD_PROJECTS=%_BUILD_PROJECTS%;%1& shift & goto _CheckArg +call :GetFileName "%_BUILD_PROJECT_DIR%%1.vcproj" _BUILD_PROJECT +if exist "%_BUILD_PROJECT_DIR%%1.vcproj" set _BUILD_PROJECTS=%_BUILD_PROJECTS%;%_BUILD_PROJECT% +if exist "%_BUILD_PROJECT_DIR%%1.vcproj" set _REBUILD_PROJECTS=%_REBUILD_PROJECTS%;%_BUILD_PROJECT%:Rebuild +if exist "%_BUILD_PROJECT_DIR%%1.vcproj" shift & goto _CheckArg echo ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR echo ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR echo ** @@ -140,33 +144,33 @@ set _Numeric_TMP_= set _Numeric_Test_= exit /B 0 +:GetFileName +set %2=%~n1 +exit /B 0 + :GotVC +set _BUILD_PARALLEL=8 +if %_BUILD_PARALLEL% GTR %NUMBER_OF_PROCESSORS% set _BUILD_PARALLEL=%NUMBER_OF_PROCESSORS% SET _X_SLN_VERSION= for /F "usebackq tokens=8" %%a in (`findstr /C:"Microsoft Visual Studio Solution File, Format Version" "%_BUILD_PROJECT_DIR%Simh.sln"`) do SET _X_SLN_VERSION=%%a if not "%_VC_VER%" == "9" goto _DoMSBuild -if "%_BUILD_PROJECTS%" == "" vcbuild /M4 /useenv /rebuild "%_BUILD_PROJECT_DIR%Simh.sln" "%_BUILD_CONFIG%|Win32" & goto :EOF +if "%_BUILD_PROJECTS%" == "" vcbuild /nologo /M%_BUILD_PARALLEL% /useenv /rebuild "%_BUILD_PROJECT_DIR%Simh.sln" "%_BUILD_CONFIG%|Win32" & goto :EOF set _BUILD_PROJECTS=%_BUILD_PROJECTS:~1% :_NextProject set _BUILD_PROJECT= for /f "tokens=1* delims=;" %%a in ("%_BUILD_PROJECTS%") do set _BUILD_PROJECT=%%a& set _BUILD_PROJECTS=%%b if "%_BUILD_PROJECT%" == "" goto :EOF -echo +echo. echo Building %_BUILD_PROJECT% -vcbuild /useenv /rebuild "%_BUILD_PROJECT_DIR%%_BUILD_PROJECT%.vcproj" "%_BUILD_CONFIG%|Win32" +vcbuild /nologo /useenv /rebuild "%_BUILD_PROJECT_DIR%%_BUILD_PROJECT%.vcproj" "%_BUILD_CONFIG%|Win32" goto _NextProject :_DoMSBuild if "%_X_SLN_VERSION%" == "10.00" echo Converting the VS2008 projects to VS%_VC_VER%, this will take several (3-5) minutes & DevEnv /Upgrade "%_BUILD_PROJECT_DIR%Simh.sln" -if "%_BUILD_PROJECTS%" == "" MSBuild "%_BUILD_PROJECT_DIR%Simh.sln" /maxCpuCount:4 /Target:Rebuild /Property:Configuration=%_BUILD_CONFIG% /Property:Platform=Win32 & goto :EOF +if "%_BUILD_PROJECTS%" == "" MSBuild /nologo "%_BUILD_PROJECT_DIR%Simh.sln" /maxCpuCount:%_BUILD_PARALLEL% /Target:Rebuild /Property:Configuration=%_BUILD_CONFIG% /Property:Platform=Win32 & goto :EOF set _BUILD_PROJECTS=%_BUILD_PROJECTS:~1% -:_NextXProject -set _BUILD_PROJECT= -for /f "tokens=1* delims=;" %%a in ("%_BUILD_PROJECTS%") do set _BUILD_PROJECT=%%a& set _BUILD_PROJECTS=%%b -if "%_BUILD_PROJECT%" == "" goto :EOF -echo -echo Building %_BUILD_PROJECT% -MSBuild "%_BUILD_PROJECT_DIR%%_BUILD_PROJECT%.vcxproj" /Target:Rebuild /Property:Configuration=%_BUILD_CONFIG% /Property:Platform=Win32 -goto _NextXProject +set _REBUILD_PROJECTS=%_REBUILD_PROJECTS:~1% +MSBuild /nologo "%_BUILD_PROJECT_DIR%Simh.sln" /maxCpuCount:%_BUILD_PARALLEL% /Target:%_REBUILD_PROJECTS% /Property:Configuration=%_BUILD_CONFIG% /Property:Platform=Win32 & goto :EOF