| 1 |
:: Copyright (c) 2018 Google LLC. |
| 2 |
:: |
| 3 |
:: Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
:: you may not use this file except in compliance with the License. |
| 5 |
:: You may obtain a copy of the License at |
| 6 |
:: |
| 7 |
:: http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
:: |
| 9 |
:: Unless required by applicable law or agreed to in writing, software |
| 10 |
:: distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
:: See the License for the specific language governing permissions and |
| 13 |
:: limitations under the License. |
| 14 |
:: |
| 15 |
:: Windows Build Script. |
| 16 |
|
| 17 |
@echo on |
| 18 |
|
| 19 |
set BUILD_ROOT=%cd% |
| 20 |
set SRC=%cd%\github\SPIRV-Tools |
| 21 |
set BUILD_TYPE=%1 |
| 22 |
set VS_VERSION=%2 |
| 23 |
|
| 24 |
:: Force usage of python 3.6 |
| 25 |
set PATH=C:\python36;%PATH% |
| 26 |
|
| 27 |
cd %SRC% |
| 28 |
git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers |
| 29 |
git clone https://github.com/google/googletest external/googletest |
| 30 |
cd external && cd googletest && git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31dc610fec7 && cd .. && cd .. |
| 31 |
git clone --depth=1 https://github.com/google/effcee external/effcee |
| 32 |
git clone --depth=1 https://github.com/google/re2 external/re2 |
| 33 |
git clone --depth=1 --branch v3.13.0 https://github.com/protocolbuffers/protobuf external/protobuf |
| 34 |
|
| 35 |
:: ######################################### |
| 36 |
:: set up msvc build env |
| 37 |
:: ######################################### |
| 38 |
if %VS_VERSION% == 2017 ( |
| 39 |
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 |
| 40 |
echo "Using VS 2017..." |
| 41 |
) else if %VS_VERSION% == 2015 ( |
| 42 |
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 |
| 43 |
echo "Using VS 2015..." |
| 44 |
) else if %VS_VERSION% == 2013 ( |
| 45 |
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64 |
| 46 |
echo "Using VS 2013..." |
| 47 |
) |
| 48 |
|
| 49 |
cd %SRC% |
| 50 |
mkdir build |
| 51 |
cd build |
| 52 |
|
| 53 |
:: ######################################### |
| 54 |
:: Start building. |
| 55 |
:: ######################################### |
| 56 |
echo "Starting build... %DATE% %TIME%" |
| 57 |
if "%KOKORO_GITHUB_COMMIT%." == "." ( |
| 58 |
set BUILD_SHA=%KOKORO_GITHUB_PULL_REQUEST_COMMIT% |
| 59 |
) else ( |
| 60 |
set BUILD_SHA=%KOKORO_GITHUB_COMMIT% |
| 61 |
) |
| 62 |
|
| 63 |
set CMAKE_FLAGS=-DCMAKE_INSTALL_PREFIX=%KOKORO_ARTIFACTS_DIR%\install -GNinja -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DRE2_BUILD_TESTING=OFF -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe |
| 64 |
|
| 65 |
:: Skip building tests for VS2013 |
| 66 |
if %VS_VERSION% == 2013 ( |
| 67 |
set CMAKE_FLAGS=%CMAKE_FLAGS% -DSPIRV_SKIP_TESTS=ON |
| 68 |
) |
| 69 |
|
| 70 |
:: Skip building spirv-fuzz for VS2013; it relies on protobufs which VS2013 cannot handle. |
| 71 |
if %VS_VERSION% NEQ 2013 ( |
| 72 |
set CMAKE_FLAGS=%CMAKE_FLAGS% -DSPIRV_BUILD_FUZZER=ON |
| 73 |
) |
| 74 |
|
| 75 |
cmake %CMAKE_FLAGS% .. |
| 76 |
|
| 77 |
if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% |
| 78 |
|
| 79 |
echo "Build everything... %DATE% %TIME%" |
| 80 |
ninja |
| 81 |
if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% |
| 82 |
echo "Build Completed %DATE% %TIME%" |
| 83 |
|
| 84 |
:: This lets us use !ERRORLEVEL! inside an IF ... () and get the actual error at that point. |
| 85 |
setlocal ENABLEDELAYEDEXPANSION |
| 86 |
|
| 87 |
:: ################################################ |
| 88 |
:: Run the tests (We no longer run tests on VS2013) |
| 89 |
:: ################################################ |
| 90 |
echo "Running Tests... %DATE% %TIME%" |
| 91 |
if %VS_VERSION% NEQ 2013 ( |
| 92 |
ctest -C %BUILD_TYPE% --output-on-failure --timeout 300 |
| 93 |
if !ERRORLEVEL! NEQ 0 exit /b !ERRORLEVEL! |
| 94 |
) |
| 95 |
echo "Tests Completed %DATE% %TIME%" |
| 96 |
|
| 97 |
:: ################################################ |
| 98 |
:: Install and package. |
| 99 |
:: ################################################ |
| 100 |
ninja install |
| 101 |
cd %KOKORO_ARTIFACTS_DIR% |
| 102 |
zip -r install.zip install |
| 103 |
|
| 104 |
:: Clean up some directories. |
| 105 |
rm -rf %SRC%\build |
| 106 |
rm -rf %SRC%\external |
| 107 |
|
| 108 |
exit /b 0 |
| 109 |
|