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 19set BUILD_ROOT=%cd% 20set SRC=%cd%\github\SPIRV-Tools 21set BUILD_TYPE=%1 22set VS_VERSION=%2 23 24:: Force usage of python 3.6 25set PATH=C:\python36;"C:\Program Files\cmake-3.23.1-windows-x86_64\bin";%PATH% 26 27:: ######################################### 28:: set up msvc build env 29:: ######################################### 30if %VS_VERSION% == 2017 ( 31 call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 32 echo "Using VS 2017..." 33 34 :: RE2 does not support VS2017, we we must disable tests. 35 set BUILD_TESTS=NO 36) else if %VS_VERSION% == 2019 ( 37 call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 38 echo "Using VS 2019..." 39) 40 41cd %SRC% 42python utils/git-sync-deps --treeless 43 44mkdir build 45cd build 46 47:: ######################################### 48:: Start building. 49:: ######################################### 50echo "Starting build... %DATE% %TIME%" 51if "%KOKORO_GITHUB_COMMIT%." == "." ( 52 set BUILD_SHA=%KOKORO_GITHUB_PULL_REQUEST_COMMIT% 53) else ( 54 set BUILD_SHA=%KOKORO_GITHUB_COMMIT% 55) 56 57set 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 58 59:: Build spirv-fuzz 60set CMAKE_FLAGS=%CMAKE_FLAGS% -DSPIRV_BUILD_FUZZER=ON 61 62if "%BUILD_TESTS%" == "NO" ( 63 set CMAKE_FLAGS=-DSPIRV_SKIP_TESTS=ON %CMAKE_FLAGS% 64) 65 66cmake %CMAKE_FLAGS% .. 67 68if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% 69 70echo "Build everything... %DATE% %TIME%" 71ninja 72if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% 73echo "Build Completed %DATE% %TIME%" 74 75:: This lets us use !ERRORLEVEL! inside an IF ... () and get the actual error at that point. 76setlocal ENABLEDELAYEDEXPANSION 77 78:: ################################################ 79:: Run the tests 80:: ################################################ 81if "%BUILD_TESTS%" NEQ "NO" ( 82 echo "Running Tests... %DATE% %TIME%" 83 ctest -C %BUILD_TYPE% --output-on-failure --timeout 300 84 if !ERRORLEVEL! NEQ 0 exit /b !ERRORLEVEL! 85 echo "Tests Completed %DATE% %TIME%" 86) 87 88:: ################################################ 89:: Install and package. 90:: ################################################ 91ninja install 92cd %KOKORO_ARTIFACTS_DIR% 93zip -r install.zip install 94 95:: Clean up some directories. 96rm -rf %SRC%\build 97rm -rf %SRC%\external 98 99exit /b 0 100