blob: c6e53e19799a6c81149df895052430b46a1d4292 [file] [log] [blame]
Mark Young1aacfe12016-01-28 14:39:19 -07001echo off
2REM
Karl Schultzc85cf402016-03-22 12:05:31 -06003REM This Windows batch file builds this repository for the following targets:
Karl Schultzd04d4472016-04-11 13:29:05 -06004REM 64/32-bit Release/Debug
Karl Schultzc85cf402016-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 Young1aacfe12016-01-28 14:39:19 -07009REM
Karl Schultzd04d4472016-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
Karl Schultz8e1425e2018-01-04 17:14:31 -070016REM debug (case insensitive): Builds just the debug config of a 32 and/or 64-bit build
17REM release (case insensitive): Builds just the release config of a 32 and/or 64-bit build
18REM Notes:
19REM cmake: When specified, generate the CMake build files only - don't compile
20REM 32/64: Specifying neither or both builds both
21REM debug/release: Specifying neither or both builds both
22REM Examples:
Karl Schultzd04d4472016-04-11 13:29:05 -060023REM build_windows_targets.bat 64
Karl Schultz8e1425e2018-01-04 17:14:31 -070024REM -- deletes build, creates build, runs CMake and compiles 64-bit Debug and Release.
25REM build_windows_targets.bat 64 debug
26REM -- deletes build, creates build, runs CMake and compiles 64-bit Debug.
Karl Schultzd04d4472016-04-11 13:29:05 -060027
Karl Schultz8e1425e2018-01-04 17:14:31 -070028set arg_cmake=0
29set arg_32=0
30set arg_64=0
31set arg_debug=0
32set arg_release=0
33
Karl Schultzd04d4472016-04-11 13:29:05 -060034set do_cmake=0
35set do_32=0
36set do_64=0
Karl Schultz8e1425e2018-01-04 17:14:31 -070037set do_debug=0
38set do_release=0
39
Karl Schultzd04d4472016-04-11 13:29:05 -060040for %%a in (%*) do (
Karl Schultz8e1425e2018-01-04 17:14:31 -070041 echo.%%a | %WINDIR%\system32\find.exe /I "cmake">Nul && (set arg_cmake=1)
42 echo.%%a | %WINDIR%\system32\find.exe "32">Nul && (set arg_32=1)
43 echo.%%a | %WINDIR%\system32\find.exe "64">Nul && (set arg_64=1)
44 echo.%%a | %WINDIR%\system32\find.exe /I "debug">Nul && (set arg_debug=1)
45 echo.%%a | %WINDIR%\system32\find.exe /I "release">Nul && (set arg_release=1)
Karl Schultzd04d4472016-04-11 13:29:05 -060046)
Karl Schultz8e1425e2018-01-04 17:14:31 -070047
48if %arg_32%==1 (
49 set do_32=1
50)
51if %arg_64%==1 (
52 set do_64=1
53)
54if %arg_32%==0 (
55 if %arg_64%==0 (
56 set do_32=1
57 set do_64=1
Karl Schultzd04d4472016-04-11 13:29:05 -060058 )
59)
Mark Young1aacfe12016-01-28 14:39:19 -070060
Karl Schultz8e1425e2018-01-04 17:14:31 -070061if %arg_debug%==1 (
62 set do_debug=1
63)
64if %arg_release%==1 (
65 set do_release=1
66)
67if %arg_debug%==0 (
68 if %arg_release%==0 (
69 set do_debug=1
70 set do_release=1
71 )
72)
73
74if %arg_cmake%==1 (
75 set do_cmake=1
76 set do_32=0
77 set do_64=0
78 set do_debug=0
79 set do_release=0
80)
81
Mark Young1aacfe12016-01-28 14:39:19 -070082REM Determine the appropriate CMake strings for the current version of Visual Studio
83echo Determining VS version
Mark Lobodzinski6cde2f02016-11-18 14:12:01 -070084python .\scripts\determine_vs_version.py > vsversion.tmp
Mark Young1aacfe12016-01-28 14:39:19 -070085set /p VS_VERSION=< vsversion.tmp
86echo Detected Visual Studio Version as %VS_VERSION%
Mark Young1aacfe12016-01-28 14:39:19 -070087del /Q /F vsversion.tmp
88
Karl Schultzd04d4472016-04-11 13:29:05 -060089if %do_cmake%==1 (
90 rmdir /Q /S build
91 rmdir /Q /S build32
92 mkdir build
93 pushd build
94 echo Generating 64-bit CMake files for Visual Studio %VS_VERSION%
95 cmake -G "Visual Studio %VS_VERSION% Win64" ..
96 popd
97 mkdir build32
98 pushd build32
99 echo Generating 32-bit CMake files for Visual Studio %VS_VERSION%
100 cmake -G "Visual Studio %VS_VERSION%" ..
101 popd
102)
Mark Young1aacfe12016-01-28 14:39:19 -0700103
104REM *******************************************
Karl Schultzc85cf402016-03-22 12:05:31 -0600105REM 64-bit build
Mark Young1aacfe12016-01-28 14:39:19 -0700106REM *******************************************
Karl Schultzd04d4472016-04-11 13:29:05 -0600107if %do_64%==1 (
108 rmdir /Q /S build
109 mkdir build
110 pushd build
111 echo Generating 64-bit CMake files for Visual Studio %VS_VERSION%
112 cmake -G "Visual Studio %VS_VERSION% Win64" ..
Karl Schultz8e1425e2018-01-04 17:14:31 -0700113 if %do_debug% equ 1 (
114 echo Building 64-bit Debug
115 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug /maxcpucount /verbosity:quiet
116 if errorlevel 1 (
117 echo.
118 echo 64-bit Debug build failed!
119 popd
120 exit /b 1
121 )
122 )
Mark Young1aacfe12016-01-28 14:39:19 -0700123
Karl Schultz8e1425e2018-01-04 17:14:31 -0700124 if %do_release%==1 (
125 echo Building 64-bit Release
126 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release /maxcpucount /verbosity:quiet
127 if errorlevel 1 (
128 echo.
129 echo 64-bit Release build failed!
130 popd
131 exit /b 1
132 )
133 )
Karl Schultzd04d4472016-04-11 13:29:05 -0600134 popd
135)
Mark Young1aacfe12016-01-28 14:39:19 -0700136
137REM *******************************************
Karl Schultzc85cf402016-03-22 12:05:31 -0600138REM 32-bit build
Mark Young1aacfe12016-01-28 14:39:19 -0700139REM *******************************************
Mark Young1aacfe12016-01-28 14:39:19 -0700140
Karl Schultzd04d4472016-04-11 13:29:05 -0600141if %do_32%==1 (
142 rmdir /Q /S build32
143 mkdir build32
144 pushd build32
145 echo Generating 32-bit CMake files for Visual Studio %VS_VERSION%
146 cmake -G "Visual Studio %VS_VERSION%" ..
Karl Schultz8e1425e2018-01-04 17:14:31 -0700147 if %do_debug%==1 (
148 echo Building 32-bit Debug
149 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug /maxcpucount /verbosity:quiet
150 if errorlevel 1 (
151 echo.
152 echo 32-bit Debug build failed!
153 popd
154 exit /b 1
155 )
156 )
157
158 if %do_release%==1 (
159 echo Building 32-bit Release
160 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release /maxcpucount /verbosity:quiet
161 if errorlevel 1 (
162 echo.
163 echo 32-bit Release build failed!
164 popd
165 exit /b 1
166 )
167 )
Karl Schultzd04d4472016-04-11 13:29:05 -0600168 popd
169)
Jeff Julianoa7aaf9f2016-09-02 08:24:25 -0400170exit /b 0