| 1 |
@echo off |
| 2 |
|
| 3 |
setlocal |
| 4 |
|
| 5 |
echo Disk info before building: |
| 6 |
call :ShowDiskInfo |
| 7 |
|
| 8 |
if "%GITHUB_WORKFLOW%" == "" (set RUNNING_LOCALLY=1) |
| 9 |
|
| 10 |
if "%TARGET%" == "" ( |
| 11 |
if "%1" == "" ( |
| 12 |
set TARGET=release |
| 13 |
) else ( |
| 14 |
set TARGET=%1 |
| 15 |
) |
| 16 |
) |
| 17 |
|
| 18 |
set BUILD_DEBUG= |
| 19 |
set BUILD_RELEASE= |
| 20 |
set INSTALL= |
| 21 |
set BUILD_RELEASE_VARIANTS= |
| 22 |
|
| 23 |
if "%TARGET%" == "presubmit" ( |
| 24 |
set BUILD_RELEASE=1 |
| 25 |
) |
| 26 |
|
| 27 |
if "%TARGET%" == "continuous" ( |
| 28 |
set BUILD_DEBUG=1 |
| 29 |
set BUILD_RELEASE=1 |
| 30 |
set INSTALL=--target install |
| 31 |
set CREATE_ARCHIVE=1 |
| 32 |
) |
| 33 |
|
| 34 |
if "%TARGET%" == "release" ( |
| 35 |
set BUILD_DEBUG=1 |
| 36 |
set BUILD_RELEASE=1 |
| 37 |
set INSTALL=--target install |
| 38 |
set BUILD_RELEASE_VARIANTS=1 |
| 39 |
set CREATE_ARCHIVE=1 |
| 40 |
) |
| 41 |
|
| 42 |
set VISUAL_STUDIO_VERSION="Enterprise" |
| 43 |
if "%RUNNING_LOCALLY%" == "1" ( |
| 44 |
set VISUAL_STUDIO_VERSION="Community" |
| 45 |
set "PATH=%PATH%;C:\Program Files\7-Zip" |
| 46 |
) |
| 47 |
|
| 48 |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\%VISUAL_STUDIO_VERSION%\VC\Auxiliary\Build\vcvars64.bat" |
| 49 |
if errorlevel 1 exit /b %errorlevel% |
| 50 |
|
| 51 |
msbuild /version |
| 52 |
cmake --version |
| 53 |
|
| 54 |
:: Important: build debug builds first, when disk space is plentiful. Debug builds require |
| 55 |
:: significantly more temporary space. |
| 56 |
if "%BUILD_DEBUG%" == "1" ( |
| 57 |
:: MTd |
| 58 |
call :BuildVariant mtd "-DUSE_STATIC_CRT=ON" Debug || exit /b |
| 59 |
|
| 60 |
if "%BUILD_RELEASE_VARIANTS%" == "1" ( |
| 61 |
:: MDd |
| 62 |
call :BuildVariant mdd "-DUSE_STATIC_CRT=OFF" Debug || exit /b |
| 63 |
) |
| 64 |
) |
| 65 |
|
| 66 |
if "%BUILD_RELEASE%" == "1" ( |
| 67 |
:: /MT |
| 68 |
call :BuildVariant mt "-DUSE_STATIC_CRT=ON" Release || exit /b |
| 69 |
|
| 70 |
if "%BUILD_RELEASE_VARIANTS%" == "1" ( |
| 71 |
:: /MD |
| 72 |
call :BuildVariant md "-DUSE_STATIC_CRT=OFF" Release || exit /b |
| 73 |
) |
| 74 |
) |
| 75 |
|
| 76 |
if "%CREATE_ARCHIVE%" == "1" ( |
| 77 |
:: Use the /MT version as the "base" install. |
| 78 |
move out\mt out\install |
| 79 |
mkdir out\install\lib\x86_64\mt\ |
| 80 |
move out\install\lib\x86_64\*.lib out\install\lib\x86_64\mt\ |
| 81 |
|
| 82 |
xcopy out\md\lib\x86_64\*.lib out\install\lib\x86_64\md\ |
| 83 |
xcopy out\mtd\lib\x86_64\*.lib out\install\lib\x86_64\mtd\ |
| 84 |
xcopy out\mdd\lib\x86_64\*.lib out\install\lib\x86_64\mdd\ |
| 85 |
) |
| 86 |
|
| 87 |
:: Create an archive. |
| 88 |
if "%CREATE_ARCHIVE%" == "1" ( |
| 89 |
cd out\install |
| 90 |
7z a -ttar -so ..\..\filament-release.tar * | 7z a -si ..\filament-windows.tgz |
| 91 |
) |
| 92 |
|
| 93 |
exit /b 0 |
| 94 |
|
| 95 |
:BuildVariant |
| 96 |
set variant=%~1 |
| 97 |
set flag=%~2 |
| 98 |
set config=%~3 |
| 99 |
|
| 100 |
echo Disk info before building variant: %variant% |
| 101 |
call :ShowDiskInfo |
| 102 |
|
| 103 |
mkdir out\cmake-%variant% |
| 104 |
cd out\cmake-%variant% |
| 105 |
if errorlevel 1 exit /b %errorlevel% |
| 106 |
|
| 107 |
cmake ..\.. ^ |
| 108 |
-G "Visual Studio 16 2019" ^ |
| 109 |
-A x64 ^ |
| 110 |
%flag% ^ |
| 111 |
-DCMAKE_INSTALL_PREFIX=..\%variant% ^ |
| 112 |
-DFILAMENT_WINDOWS_CI_BUILD:BOOL=ON ^ |
| 113 |
-DFILAMENT_SUPPORTS_VULKAN=ON ^ |
| 114 |
|| exit /b |
| 115 |
cmake --build . %INSTALL% --config %config% -- /m || exit /b |
| 116 |
|
| 117 |
echo Disk info after building variant: %variant% |
| 118 |
call :ShowDiskInfo |
| 119 |
|
| 120 |
cd ..\.. |
| 121 |
|
| 122 |
:: Delete the cmake build folder, otherwise we run out of disk space on CI when |
| 123 |
:: building multiple variants. |
| 124 |
rd /s /q out\cmake-%variant% |
| 125 |
exit /b 0 |
| 126 |
|
| 127 |
:: Helps debugging GitHub builds that run out of space |
| 128 |
:ShowDiskInfo |
| 129 |
echo ======================================================= |
| 130 |
wmic logicaldisk get size,freespace,caption |
| 131 |
echo ======================================================= |
| 132 |
exit /b 0 |