Mark Young | e8c0364 | 2016-01-28 14:39:19 -0700 | [diff] [blame] | 1 | echo off |
| 2 | REM |
Karl Schultz | 4e01ddc | 2016-03-22 12:05:31 -0600 | [diff] [blame] | 3 | REM This Windows batch file builds this repository for the following targets: |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 4 | REM 64/32-bit Release/Debug |
Karl Schultz | 4e01ddc | 2016-03-22 12:05:31 -0600 | [diff] [blame] | 5 | REM It uses CMake to genererate the project files and then invokes msbuild |
| 6 | REM to build them. |
| 7 | REM The update_external_sources.bat batch file must be executed before running |
| 8 | REM this batch file |
Mark Young | e8c0364 | 2016-01-28 14:39:19 -0700 | [diff] [blame] | 9 | REM |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 10 | REM Arguments: |
| 11 | REM None: Runs CMake and builds all 4 combinations |
| 12 | REM Argument contains: |
| 13 | REM cmake (case insensitive): Deletes build and build32 and runs just CMake on both |
| 14 | REM 32: Deletes build32, runs CMake and builds 32-bit versions |
| 15 | REM 64: Deletes build, runs CMake and builds 64-bit versions |
| 16 | REM Example: |
| 17 | REM build_windows_targets.bat 64 |
| 18 | REM deletes build, creates build, runs CMake and compiles 64-bit Debug and Release. |
| 19 | |
| 20 | set do_cmake=0 |
| 21 | set do_32=1 |
| 22 | set do_64=1 |
| 23 | if "%1"=="" goto no_args |
| 24 | set do_cmake=0 |
| 25 | set do_32=0 |
| 26 | set do_64=0 |
| 27 | for %%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 |
| 33 | if %do_cmake%==0 ( |
| 34 | if %do_32%==0 ( |
| 35 | if %do_64%==0 ( |
| 36 | echo No valid parameters specified. |
Jeff Juliano | b544c47 | 2016-09-02 08:24:25 -0400 | [diff] [blame] | 37 | exit /b 1 |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 38 | ) |
| 39 | ) |
| 40 | ) |
Mark Young | e8c0364 | 2016-01-28 14:39:19 -0700 | [diff] [blame] | 41 | |
| 42 | REM Determine the appropriate CMake strings for the current version of Visual Studio |
| 43 | echo Determining VS version |
Mark Lobodzinski | 48bfaae | 2016-11-18 14:12:01 -0700 | [diff] [blame] | 44 | python .\scripts\determine_vs_version.py > vsversion.tmp |
Mark Young | e8c0364 | 2016-01-28 14:39:19 -0700 | [diff] [blame] | 45 | set /p VS_VERSION=< vsversion.tmp |
| 46 | echo Detected Visual Studio Version as %VS_VERSION% |
Mark Young | e8c0364 | 2016-01-28 14:39:19 -0700 | [diff] [blame] | 47 | del /Q /F vsversion.tmp |
| 48 | |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 49 | if %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 Young | e8c0364 | 2016-01-28 14:39:19 -0700 | [diff] [blame] | 63 | |
| 64 | REM ******************************************* |
Karl Schultz | 4e01ddc | 2016-03-22 12:05:31 -0600 | [diff] [blame] | 65 | REM 64-bit build |
Mark Young | e8c0364 | 2016-01-28 14:39:19 -0700 | [diff] [blame] | 66 | REM ******************************************* |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 67 | if %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 Stroyan | 10444e0 | 2016-09-21 11:19:07 -0600 | [diff] [blame] | 74 | msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug /maxcpucount /verbosity:quiet |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 75 | if errorlevel 1 ( |
| 76 | echo. |
| 77 | echo 64-bit Debug build failed! |
| 78 | popd |
Jeff Juliano | b544c47 | 2016-09-02 08:24:25 -0400 | [diff] [blame] | 79 | exit /b 1 |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 80 | ) |
Mark Young | e8c0364 | 2016-01-28 14:39:19 -0700 | [diff] [blame] | 81 | |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 82 | echo Building 64-bit Release |
Mike Stroyan | 10444e0 | 2016-09-21 11:19:07 -0600 | [diff] [blame] | 83 | msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release /maxcpucount /verbosity:quiet |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 84 | if errorlevel 1 ( |
| 85 | echo. |
| 86 | echo 64-bit Release build failed! |
| 87 | popd |
Jeff Juliano | b544c47 | 2016-09-02 08:24:25 -0400 | [diff] [blame] | 88 | exit /b 1 |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 89 | ) |
| 90 | popd |
| 91 | ) |
Mark Young | e8c0364 | 2016-01-28 14:39:19 -0700 | [diff] [blame] | 92 | |
| 93 | REM ******************************************* |
Karl Schultz | 4e01ddc | 2016-03-22 12:05:31 -0600 | [diff] [blame] | 94 | REM 32-bit build |
Mark Young | e8c0364 | 2016-01-28 14:39:19 -0700 | [diff] [blame] | 95 | REM ******************************************* |
Mark Young | e8c0364 | 2016-01-28 14:39:19 -0700 | [diff] [blame] | 96 | |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 97 | if %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 Stroyan | 10444e0 | 2016-09-21 11:19:07 -0600 | [diff] [blame] | 104 | msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug /maxcpucount /verbosity:quiet |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 105 | if errorlevel 1 ( |
| 106 | echo. |
| 107 | echo 32-bit Debug build failed! |
| 108 | popd |
Jeff Juliano | b544c47 | 2016-09-02 08:24:25 -0400 | [diff] [blame] | 109 | exit /b 1 |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 110 | ) |
| 111 | |
| 112 | echo Building 32-bit Release |
Mike Stroyan | 10444e0 | 2016-09-21 11:19:07 -0600 | [diff] [blame] | 113 | msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release /maxcpucount /verbosity:quiet |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 114 | if errorlevel 1 ( |
| 115 | echo. |
| 116 | echo 32-bit Release build failed! |
| 117 | popd |
Jeff Juliano | b544c47 | 2016-09-02 08:24:25 -0400 | [diff] [blame] | 118 | exit /b 1 |
Karl Schultz | 683e1e8 | 2016-04-11 13:29:05 -0600 | [diff] [blame] | 119 | ) |
| 120 | popd |
| 121 | ) |
Jeff Juliano | b544c47 | 2016-09-02 08:24:25 -0400 | [diff] [blame] | 122 | exit /b 0 |