update all msbuild.bat files to use a common script

This commit is contained in:
Brian Gladman 2018-09-05 15:52:38 +01:00
parent 5d7800703c
commit 0da9962426
3 changed files with 91 additions and 36 deletions

View File

@ -3,39 +3,60 @@ rem %1 = architecture
rem %2 = library type (LIB|DLL) rem %2 = library type (LIB|DLL)
rem %3 = platform (Win32|x64) rem %3 = platform (Win32|x64)
rem %4 = configuration (Release|Debug) rem %4 = configuration (Release|Debug)
rem %5 = build tests (|+tests) rem %5 = Windows SDK Version
rem %6 = build tests (|+tests)
rem Visual Studio version (2013, 2015 or 2017)
set vs_version=2013
rem find the MSBUILD installation directory
if "%vs_version%" EQU "2013" (
set msbdir="C:\Program Files (x86)\MSBuild\12.0\Bin"
) else if "%vs_version%" EQU "2015" (
set msbdir="C:\Program Files (x86)\MSBuild\14.0\Bin"
) else if "%vs_version%" EQU "2017" (
set vsw_exe="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
for /f "usebackq tokens=*" %%i in (`%vsw_exe% -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set InstallDir=%%i
)
if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (
set msbdir="%InstallDir%\MSBuild\15.0\Bin"
)
) else (
echo "Visual Studio %vs_version% is not supported" & exit /b %errorlevel%
)
if "%4" NEQ "" if "%3" NEQ "" if "%2" NEQ "" if "%1" NEQ "" goto cont if "%4" NEQ "" if "%3" NEQ "" if "%2" NEQ "" if "%1" NEQ "" goto cont
call :get_architectures - call :get_architectures -
echo usage: msbuild architecture=^<%architectures:|=^|%^> library_type=^<LIB^|DLL^> platform=^<Win32^|x64^> configuration=^<Release^|Debug^> echo usage: msbuild architecture=^<%architectures:|=^|%^> library_type=^<LIB^|DLL^> platform=^<Win32^|x64^> configuration=^<Release^|Debug^> [Windows_SDK_Version=^<n^>] [+tests]
goto :eof goto :eof
:cont :cont
rem example use: msbuild sandybridge_ivybridge dll x64 release rem example use: msbuild sandybridge_ivybridge dll x64 release
if not exist "lib_mpir_%1" (call :get_architectures & call :seterr & echo ERROR: architecture is one of %architectures% ^(not "%1"^) & exit /b %errorlevel%) if not exist "lib_mpir_%1" (call :get_architectures & call :seterr & echo ERROR: architecture is one of ^(%architectures%^) ^(not %1^) & exit /b %errorlevel%)
if /i "%2" EQU "DLL" (set libp=dll) else (if /i "%2" EQU "LIB" (set libp=lib) else ((call :seterr & echo ERROR: library type is "lib" or "dll" ^(not "%2"^) & exit /b %errorlevel%))) if /i "%2" EQU "DLL" (set libp=dll) else (if /i "%2" EQU "LIB" (set libp=lib) else ((call :seterr & echo ERROR: library type is "lib" or "dll" ^(not "%2"^) & exit /b %errorlevel%)))
if /i "%3" EQU "x64" (set plat=x64) else (if /i "%3" EQU "Win32" (set plat=win32) else (call :seterr & echo ERROR: platform is "Win32" or "x64" ^(not "%3"^) & exit /b %errorlevel%)) if /i "%3" EQU "x64" (set plat=x64) else (if /i "%3" EQU "Win32" (set plat=win32) else (call :seterr & echo ERROR: platform is "Win32" or "x64" ^(not "%3"^) & exit /b %errorlevel%))
if /i "%4" EQU "Debug" (set conf=Debug) else (if /i "%4" EQU "Release" (set conf=Release) else (call :seterr & echo ERROR: configuration is "Release" or "Debug" ^(not "%4"^) & exit /b %errorlevel%)) if /i "%4" EQU "Debug" (set conf=Debug) else (if /i "%4" EQU "Release" (set conf=Release) else (call :seterr & echo ERROR: configuration is "Release" or "Debug" ^(not "%4"^) & exit /b %errorlevel%))
if /i "%5" NEQ "" if "%5" EQU "+tests" (set run_tests=y) else (set win_sdk=%5)
if /i "%6" NEQ "" if "%6" EQU "+tests" (set run_tests=y)
set src=%libp%_mpir_%1 set src=%libp%_mpir_%1
rem This is the directory where Microsoft MSBUILD is installed
set msbdir="C:\Program Files (x86)\MSBuild\14.0\Bin"
rem This is the Visual Studio build directory (within the MPIR directory) rem This is the Visual Studio build directory (within the MPIR directory)
set srcdir="." set srcdir=.
%msbdir%\msbuild.exe /p:Platform=%plat% /p:Configuration=%conf% %srcdir%\%src%\%src%.vcxproj echo %msbdir%\msbuild.exe /p:Platform=%plat% /p:Configuration=%conf% /p:"Windows%20SDK%20Version=%win_sdk%" %srcdir%\%src%\%src%.vcxproj
%msbdir%\msbuild.exe /p:Platform=%plat% /p:Configuration=%conf% /p:"Windows%20SDK%20Version=%win_sdk%" %srcdir%\%src%\%src%.vcxproj
if /i "%libp%" == "LIB" ( if /i "%libp%" == "LIB" (
%msbdir%\msbuild.exe /p:Platform=%plat% /p:Configuration=%conf% %srcdir%\lib_mpir_cxx\lib_mpir_cxx.vcxproj %msbdir%\msbuild.exe /p:Platform=%plat% /p:Configuration=%conf% /p:"Windows%20SDK%20Version=%win_sdk%" %srcdir%\lib_mpir_cxx\lib_mpir_cxx.vcxproj
) )
if /i "%5" EQU "+tests" ( if /i "%run_tests%" NEQ "" (
for /d %%d in (.\mpir-tests\*) do ( for /d %%d in (.\mpir-tests\*) do (
for %%f in (%%d\*.vcxproj) do ( for %%f in (%%d\*.vcxproj) do (
%msbdir%\msbuild.exe /property:SolutionDir=..\..\ /property:OutDir=..\..\%plat%\%conf%\ /p:Platform=%plat% /p:Configuration=%conf% %%f %msbdir%\msbuild.exe /property:SolutionDir=..\..\ /property:OutDir=..\..\%plat%\%conf%\ /p:Platform=%plat% /p:Configuration=%conf% /p:"Windows%20SDK%20Version=%win_sdk%" %%f
) )
) )
) )
@ -46,10 +67,12 @@ for /d %%a in (lib_mpir_*) do (call :add_architecture %%a %1)
goto :eof goto :eof
:add_architecture :add_architecture
for /f "tokens=3,* delims=_" %%a in ("%1") do set arch=%%a set xx=%1
set arch=%xx:~9%
if /i "%arch%" EQU "cxx" goto :eof
if _%2_ == __ ( if _%2_ == __ (
set "delim= or " set "delim= "
set arch=^"%arch%^" set arch=%arch%
) else ( ) else (
set delim=^| set delim=^|
) )

View File

@ -3,39 +3,60 @@ rem %1 = architecture
rem %2 = library type (LIB|DLL) rem %2 = library type (LIB|DLL)
rem %3 = platform (Win32|x64) rem %3 = platform (Win32|x64)
rem %4 = configuration (Release|Debug) rem %4 = configuration (Release|Debug)
rem %5 = build tests (|+tests) rem %5 = Windows SDK Version
rem %6 = build tests (|+tests)
rem Visual Studio version (2013, 2015 or 2017)
set vs_version=2015
rem find the MSBUILD installation directory
if "%vs_version%" EQU "2013" (
set msbdir="C:\Program Files (x86)\MSBuild\12.0\Bin"
) else if "%vs_version%" EQU "2015" (
set msbdir="C:\Program Files (x86)\MSBuild\14.0\Bin"
) else if "%vs_version%" EQU "2017" (
set vsw_exe="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
for /f "usebackq tokens=*" %%i in (`%vsw_exe% -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set InstallDir=%%i
)
if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (
set msbdir="%InstallDir%\MSBuild\15.0\Bin"
)
) else (
echo "Visual Studio %vs_version% is not supported" & exit /b %errorlevel%
)
if "%4" NEQ "" if "%3" NEQ "" if "%2" NEQ "" if "%1" NEQ "" goto cont if "%4" NEQ "" if "%3" NEQ "" if "%2" NEQ "" if "%1" NEQ "" goto cont
call :get_architectures - call :get_architectures -
echo usage: msbuild architecture=^<%architectures:|=^|%^> library_type=^<LIB^|DLL^> platform=^<Win32^|x64^> configuration=^<Release^|Debug^> echo usage: msbuild architecture=^<%architectures:|=^|%^> library_type=^<LIB^|DLL^> platform=^<Win32^|x64^> configuration=^<Release^|Debug^> [Windows_SDK_Version=^<n^>] [+tests]
goto :eof goto :eof
:cont :cont
rem example use: msbuild sandybridge_ivybridge dll x64 release rem example use: msbuild sandybridge_ivybridge dll x64 release
if not exist "lib_mpir_%1" (call :get_architectures & call :seterr & echo ERROR: architecture is one of %architectures% ^(not "%1"^) & exit /b %errorlevel%) if not exist "lib_mpir_%1" (call :get_architectures & call :seterr & echo ERROR: architecture is one of ^(%architectures%^) ^(not %1^) & exit /b %errorlevel%)
if /i "%2" EQU "DLL" (set libp=dll) else (if /i "%2" EQU "LIB" (set libp=lib) else ((call :seterr & echo ERROR: library type is "lib" or "dll" ^(not "%2"^) & exit /b %errorlevel%))) if /i "%2" EQU "DLL" (set libp=dll) else (if /i "%2" EQU "LIB" (set libp=lib) else ((call :seterr & echo ERROR: library type is "lib" or "dll" ^(not "%2"^) & exit /b %errorlevel%)))
if /i "%3" EQU "x64" (set plat=x64) else (if /i "%3" EQU "Win32" (set plat=win32) else (call :seterr & echo ERROR: platform is "Win32" or "x64" ^(not "%3"^) & exit /b %errorlevel%)) if /i "%3" EQU "x64" (set plat=x64) else (if /i "%3" EQU "Win32" (set plat=win32) else (call :seterr & echo ERROR: platform is "Win32" or "x64" ^(not "%3"^) & exit /b %errorlevel%))
if /i "%4" EQU "Debug" (set conf=Debug) else (if /i "%4" EQU "Release" (set conf=Release) else (call :seterr & echo ERROR: configuration is "Release" or "Debug" ^(not "%4"^) & exit /b %errorlevel%)) if /i "%4" EQU "Debug" (set conf=Debug) else (if /i "%4" EQU "Release" (set conf=Release) else (call :seterr & echo ERROR: configuration is "Release" or "Debug" ^(not "%4"^) & exit /b %errorlevel%))
if /i "%5" NEQ "" if "%5" EQU "+tests" (set run_tests=y) else (set win_sdk=%5)
if /i "%6" NEQ "" if "%6" EQU "+tests" (set run_tests=y)
set src=%libp%_mpir_%1 set src=%libp%_mpir_%1
rem This is the directory where Microsoft MSBUILD is installed
set msbdir="C:\Program Files (x86)\MSBuild\14.0\Bin"
rem This is the Visual Studio build directory (within the MPIR directory) rem This is the Visual Studio build directory (within the MPIR directory)
set srcdir="." set srcdir=.
%msbdir%\msbuild.exe /p:Platform=%plat% /p:Configuration=%conf% %srcdir%\%src%\%src%.vcxproj echo %msbdir%\msbuild.exe /p:Platform=%plat% /p:Configuration=%conf% /p:"Windows%20SDK%20Version=%win_sdk%" %srcdir%\%src%\%src%.vcxproj
%msbdir%\msbuild.exe /p:Platform=%plat% /p:Configuration=%conf% /p:"Windows%20SDK%20Version=%win_sdk%" %srcdir%\%src%\%src%.vcxproj
if /i "%libp%" == "LIB" ( if /i "%libp%" == "LIB" (
%msbdir%\msbuild.exe /p:Platform=%plat% /p:Configuration=%conf% %srcdir%\lib_mpir_cxx\lib_mpir_cxx.vcxproj %msbdir%\msbuild.exe /p:Platform=%plat% /p:Configuration=%conf% /p:"Windows%20SDK%20Version=%win_sdk%" %srcdir%\lib_mpir_cxx\lib_mpir_cxx.vcxproj
) )
if /i "%5" EQU "+tests" ( if /i "%run_tests%" NEQ "" (
for /d %%d in (.\mpir-tests\*) do ( for /d %%d in (.\mpir-tests\*) do (
for %%f in (%%d\*.vcxproj) do ( for %%f in (%%d\*.vcxproj) do (
%msbdir%\msbuild.exe /property:SolutionDir=..\..\ /property:OutDir=..\..\%plat%\%conf%\ /p:Platform=%plat% /p:Configuration=%conf% %%f %msbdir%\msbuild.exe /property:SolutionDir=..\..\ /property:OutDir=..\..\%plat%\%conf%\ /p:Platform=%plat% /p:Configuration=%conf% /p:"Windows%20SDK%20Version=%win_sdk%" %%f
) )
) )
) )
@ -46,10 +67,12 @@ for /d %%a in (lib_mpir_*) do (call :add_architecture %%a %1)
goto :eof goto :eof
:add_architecture :add_architecture
for /f "tokens=3,* delims=_" %%a in ("%1") do set arch=%%a set xx=%1
set arch=%xx:~9%
if /i "%arch%" EQU "cxx" goto :eof
if _%2_ == __ ( if _%2_ == __ (
set "delim= or " set "delim= "
set arch=^"%arch%^" set arch=%arch%
) else ( ) else (
set delim=^| set delim=^|
) )

View File

@ -6,16 +6,25 @@ rem %4 = configuration (Release|Debug)
rem %5 = Windows SDK Version rem %5 = Windows SDK Version
rem %6 = build tests (|+tests) rem %6 = build tests (|+tests)
set vsw_exe="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" rem Visual Studio version (2013, 2015 or 2017)
set vs_version=2017
rem This is the directory where Microsoft MSBUILD is installed rem find the MSBUILD installation directory
for /f "usebackq tokens=*" %%i in (`%vsw_exe% -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do ( if "%vs_version%" EQU "2013" (
set msbdir="C:\Program Files (x86)\MSBuild\12.0\Bin"
) else if "%vs_version%" EQU "2015" (
set msbdir="C:\Program Files (x86)\MSBuild\14.0\Bin"
) else if "%vs_version%" EQU "2017" (
set vsw_exe="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
for /f "usebackq tokens=*" %%i in (`%vsw_exe% -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set InstallDir=%%i set InstallDir=%%i
) )
if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (
if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" ( set msbdir="%InstallDir%\MSBuild\15.0\Bin"
set msbdir="%InstallDir%\MSBuild\15.0\Bin" )
) ) else (
echo "Visual Studio %vs_version% is not supported" & exit /b %errorlevel%
)
if "%4" NEQ "" if "%3" NEQ "" if "%2" NEQ "" if "%1" NEQ "" goto cont if "%4" NEQ "" if "%3" NEQ "" if "%2" NEQ "" if "%1" NEQ "" goto cont
call :get_architectures - call :get_architectures -