blob: faeab85b7c2471b87f80e615b2121a56012faf33 [file] [log] [blame]
Mark Younge8c03642016-01-28 14:39:19 -07001echo off
2REM
Karl Schultz4e01ddc2016-03-22 12:05:31 -06003REM This Windows batch file builds this repository for the following targets:
Karl Schultz683e1e82016-04-11 13:29:05 -06004REM 64/32-bit Release/Debug
Karl Schultz4e01ddc2016-03-22 12:05:31 -06005REM It uses CMake to genererate the project files and then invokes msbuild
6REM to build them.
7REM The update_external_sources.bat batch file must be executed before running
8REM this batch file
Mark Younge8c03642016-01-28 14:39:19 -07009REM
Karl Schultz683e1e82016-04-11 13:29:05 -060010REM Arguments:
11REM None: Runs CMake and builds all 4 combinations
12REM Argument contains:
13REM cmake (case insensitive): Deletes build and build32 and runs just CMake on both
14REM 32: Deletes build32, runs CMake and builds 32-bit versions
15REM 64: Deletes build, runs CMake and builds 64-bit versions
16REM Example:
17REM build_windows_targets.bat 64
18REM deletes build, creates build, runs CMake and compiles 64-bit Debug and Release.
19
20set do_cmake=0
21set do_32=1
22set do_64=1
23if "%1"=="" goto no_args
24set do_cmake=0
25set do_32=0
26set do_64=0
27for %%a in (%*) do (
28 echo.%%a | %WINDIR%\system32\find.exe /I "cmake">Nul && (set do_cmake=1)
29 echo.%%a | %WINDIR%\system32\find.exe "32">Nul && (set do_32=1)
30 echo.%%a | %WINDIR%\system32\find.exe "64">Nul && (set do_64=1)
31)
32:no_args
33if %do_cmake%==0 (
34 if %do_32%==0 (
35 if %do_64%==0 (
36 echo No valid parameters specified.
Jeff Julianob544c472016-09-02 08:24:25 -040037 exit /b 1
Karl Schultz683e1e82016-04-11 13:29:05 -060038 )
39 )
40)
Mark Younge8c03642016-01-28 14:39:19 -070041
42REM Determine the appropriate CMake strings for the current version of Visual Studio
43echo Determining VS version
Mark Lobodzinski48bfaae2016-11-18 14:12:01 -070044python .\scripts\determine_vs_version.py > vsversion.tmp
Mark Younge8c03642016-01-28 14:39:19 -070045set /p VS_VERSION=< vsversion.tmp
46echo Detected Visual Studio Version as %VS_VERSION%
Mark Younge8c03642016-01-28 14:39:19 -070047del /Q /F vsversion.tmp
48
Karl Schultz683e1e82016-04-11 13:29:05 -060049if %do_cmake%==1 (
50 rmdir /Q /S build
51 rmdir /Q /S build32
52 mkdir build
53 pushd build
54 echo Generating 64-bit CMake files for Visual Studio %VS_VERSION%
55 cmake -G "Visual Studio %VS_VERSION% Win64" ..
56 popd
57 mkdir build32
58 pushd build32
59 echo Generating 32-bit CMake files for Visual Studio %VS_VERSION%
60 cmake -G "Visual Studio %VS_VERSION%" ..
61 popd
62)
Mark Younge8c03642016-01-28 14:39:19 -070063
64REM *******************************************
Karl Schultz4e01ddc2016-03-22 12:05:31 -060065REM 64-bit build
Mark Younge8c03642016-01-28 14:39:19 -070066REM *******************************************
Karl Schultz683e1e82016-04-11 13:29:05 -060067if %do_64%==1 (
68 rmdir /Q /S build
69 mkdir build
70 pushd build
71 echo Generating 64-bit CMake files for Visual Studio %VS_VERSION%
72 cmake -G "Visual Studio %VS_VERSION% Win64" ..
73 echo Building 64-bit Debug
Mike Stroyan10444e02016-09-21 11:19:07 -060074 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug /maxcpucount /verbosity:quiet
Karl Schultz683e1e82016-04-11 13:29:05 -060075 if errorlevel 1 (
76 echo.
77 echo 64-bit Debug build failed!
78 popd
Jeff Julianob544c472016-09-02 08:24:25 -040079 exit /b 1
Karl Schultz683e1e82016-04-11 13:29:05 -060080 )
Mark Younge8c03642016-01-28 14:39:19 -070081
Karl Schultz683e1e82016-04-11 13:29:05 -060082 echo Building 64-bit Release
Mike Stroyan10444e02016-09-21 11:19:07 -060083 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release /maxcpucount /verbosity:quiet
Karl Schultz683e1e82016-04-11 13:29:05 -060084 if errorlevel 1 (
85 echo.
86 echo 64-bit Release build failed!
87 popd
Jeff Julianob544c472016-09-02 08:24:25 -040088 exit /b 1
Karl Schultz683e1e82016-04-11 13:29:05 -060089 )
90 popd
91)
Mark Younge8c03642016-01-28 14:39:19 -070092
93REM *******************************************
Karl Schultz4e01ddc2016-03-22 12:05:31 -060094REM 32-bit build
Mark Younge8c03642016-01-28 14:39:19 -070095REM *******************************************
Mark Younge8c03642016-01-28 14:39:19 -070096
Karl Schultz683e1e82016-04-11 13:29:05 -060097if %do_32%==1 (
98 rmdir /Q /S build32
99 mkdir build32
100 pushd build32
101 echo Generating 32-bit CMake files for Visual Studio %VS_VERSION%
102 cmake -G "Visual Studio %VS_VERSION%" ..
103 echo Building 32-bit Debug
Mike Stroyan10444e02016-09-21 11:19:07 -0600104 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug /maxcpucount /verbosity:quiet
Karl Schultz683e1e82016-04-11 13:29:05 -0600105 if errorlevel 1 (
106 echo.
107 echo 32-bit Debug build failed!
108 popd
Jeff Julianob544c472016-09-02 08:24:25 -0400109 exit /b 1
Karl Schultz683e1e82016-04-11 13:29:05 -0600110 )
111
112 echo Building 32-bit Release
Mike Stroyan10444e02016-09-21 11:19:07 -0600113 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release /maxcpucount /verbosity:quiet
Karl Schultz683e1e82016-04-11 13:29:05 -0600114 if errorlevel 1 (
115 echo.
116 echo 32-bit Release build failed!
117 popd
Jeff Julianob544c472016-09-02 08:24:25 -0400118 exit /b 1
Karl Schultz683e1e82016-04-11 13:29:05 -0600119 )
120 popd
121)
Jeff Julianob544c472016-09-02 08:24:25 -0400122exit /b 0