Visual Studio Projects: Do parallel builds for multiple projects when VS > 2008

This commit is contained in:
Mark Pizzolato 2019-12-28 14:54:46 -08:00
parent 5213e1125d
commit 11fed22dc7

View file

@ -1,4 +1,4 @@
::@echo off @echo off
:: Rebuild all of SIMH simulators using Visual Studio :: Rebuild all of SIMH simulators using Visual Studio
:: ::
:: If this procedure is not invoked from a Developer command prompt :: If this procedure is not invoked from a Developer command prompt
@ -11,7 +11,7 @@
:: to build the simh projects. :: to build the simh projects.
:: ::
:: A single argument to this procedure may be the word Debug, which :: 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. :: binaries which is the default.
:: ::
:: The default is to build all simulators mentioned in the simh solution. :: The default is to build all simulators mentioned in the simh solution.
@ -26,12 +26,16 @@
:: Initialize target variables :: Initialize target variables
set _BUILD_CONFIG=Release set _BUILD_CONFIG=Release
set _BUILD_PROJECTS= set _BUILD_PROJECTS=
set _REBUILD_PROJECTS=
set _BUILD_PROJECT_DIR=%~dp0\Visual Studio Projects\ set _BUILD_PROJECT_DIR=%~dp0\Visual Studio Projects\
:_CheckArg :_CheckArg
if "%1" == "" goto _DoneArgs if "%1" == "" goto _DoneArgs
if /i "%1" == "Debug" set _BUILD_CONFIG=Debug& shift & goto _CheckArg if /i "%1" == "Debug" set _BUILD_CONFIG=Debug& shift & goto _CheckArg
if /i "%1" == "Release" set _BUILD_CONFIG=Release& 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 ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR echo ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR
echo ** echo **
@ -140,33 +144,33 @@ set _Numeric_TMP_=
set _Numeric_Test_= set _Numeric_Test_=
exit /B 0 exit /B 0
:GetFileName
set %2=%~n1
exit /B 0
:GotVC :GotVC
set _BUILD_PARALLEL=8
if %_BUILD_PARALLEL% GTR %NUMBER_OF_PROCESSORS% set _BUILD_PARALLEL=%NUMBER_OF_PROCESSORS%
SET _X_SLN_VERSION= 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 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 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% set _BUILD_PROJECTS=%_BUILD_PROJECTS:~1%
:_NextProject :_NextProject
set _BUILD_PROJECT= set _BUILD_PROJECT=
for /f "tokens=1* delims=;" %%a in ("%_BUILD_PROJECTS%") do set _BUILD_PROJECT=%%a& set _BUILD_PROJECTS=%%b for /f "tokens=1* delims=;" %%a in ("%_BUILD_PROJECTS%") do set _BUILD_PROJECT=%%a& set _BUILD_PROJECTS=%%b
if "%_BUILD_PROJECT%" == "" goto :EOF if "%_BUILD_PROJECT%" == "" goto :EOF
echo echo.
echo Building %_BUILD_PROJECT% 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 goto _NextProject
:_DoMSBuild :_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 "%_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% set _BUILD_PROJECTS=%_BUILD_PROJECTS:~1%
:_NextXProject set _REBUILD_PROJECTS=%_REBUILD_PROJECTS:~1%
set _BUILD_PROJECT= MSBuild /nologo "%_BUILD_PROJECT_DIR%Simh.sln" /maxCpuCount:%_BUILD_PARALLEL% /Target:%_REBUILD_PROJECTS% /Property:Configuration=%_BUILD_CONFIG% /Property:Platform=Win32 & goto :EOF
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