1fd4e5da5Sopenharmony_ci:: Copyright (c) 2018 Google LLC. 2fd4e5da5Sopenharmony_ci:: 3fd4e5da5Sopenharmony_ci:: Licensed under the Apache License, Version 2.0 (the "License"); 4fd4e5da5Sopenharmony_ci:: you may not use this file except in compliance with the License. 5fd4e5da5Sopenharmony_ci:: You may obtain a copy of the License at 6fd4e5da5Sopenharmony_ci:: 7fd4e5da5Sopenharmony_ci:: http://www.apache.org/licenses/LICENSE-2.0 8fd4e5da5Sopenharmony_ci:: 9fd4e5da5Sopenharmony_ci:: Unless required by applicable law or agreed to in writing, software 10fd4e5da5Sopenharmony_ci:: distributed under the License is distributed on an "AS IS" BASIS, 11fd4e5da5Sopenharmony_ci:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12fd4e5da5Sopenharmony_ci:: See the License for the specific language governing permissions and 13fd4e5da5Sopenharmony_ci:: limitations under the License. 14fd4e5da5Sopenharmony_ci:: 15fd4e5da5Sopenharmony_ci:: Windows Build Script. 16fd4e5da5Sopenharmony_ci 17fd4e5da5Sopenharmony_ci@echo on 18fd4e5da5Sopenharmony_ci 19fd4e5da5Sopenharmony_ciset BUILD_ROOT=%cd% 20fd4e5da5Sopenharmony_ciset SRC=%cd%\github\SPIRV-Tools 21fd4e5da5Sopenharmony_ciset BUILD_TYPE=%1 22fd4e5da5Sopenharmony_ciset VS_VERSION=%2 23fd4e5da5Sopenharmony_ci 24fd4e5da5Sopenharmony_ci:: Force usage of python 3.6 25fd4e5da5Sopenharmony_ciset PATH=C:\python36;"C:\Program Files\cmake-3.23.1-windows-x86_64\bin";%PATH% 26fd4e5da5Sopenharmony_ci 27fd4e5da5Sopenharmony_ci:: ######################################### 28fd4e5da5Sopenharmony_ci:: set up msvc build env 29fd4e5da5Sopenharmony_ci:: ######################################### 30fd4e5da5Sopenharmony_ciif %VS_VERSION% == 2017 ( 31fd4e5da5Sopenharmony_ci call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 32fd4e5da5Sopenharmony_ci echo "Using VS 2017..." 33fd4e5da5Sopenharmony_ci 34fd4e5da5Sopenharmony_ci :: RE2 does not support VS2017, we we must disable tests. 35fd4e5da5Sopenharmony_ci set BUILD_TESTS=NO 36fd4e5da5Sopenharmony_ci) else if %VS_VERSION% == 2019 ( 37fd4e5da5Sopenharmony_ci call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 38fd4e5da5Sopenharmony_ci echo "Using VS 2019..." 39fd4e5da5Sopenharmony_ci) 40fd4e5da5Sopenharmony_ci 41fd4e5da5Sopenharmony_cicd %SRC% 42fd4e5da5Sopenharmony_cipython utils/git-sync-deps --treeless 43fd4e5da5Sopenharmony_ci 44fd4e5da5Sopenharmony_cimkdir build 45fd4e5da5Sopenharmony_cicd build 46fd4e5da5Sopenharmony_ci 47fd4e5da5Sopenharmony_ci:: ######################################### 48fd4e5da5Sopenharmony_ci:: Start building. 49fd4e5da5Sopenharmony_ci:: ######################################### 50fd4e5da5Sopenharmony_ciecho "Starting build... %DATE% %TIME%" 51fd4e5da5Sopenharmony_ciif "%KOKORO_GITHUB_COMMIT%." == "." ( 52fd4e5da5Sopenharmony_ci set BUILD_SHA=%KOKORO_GITHUB_PULL_REQUEST_COMMIT% 53fd4e5da5Sopenharmony_ci) else ( 54fd4e5da5Sopenharmony_ci set BUILD_SHA=%KOKORO_GITHUB_COMMIT% 55fd4e5da5Sopenharmony_ci) 56fd4e5da5Sopenharmony_ci 57fd4e5da5Sopenharmony_ciset 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 58fd4e5da5Sopenharmony_ci 59fd4e5da5Sopenharmony_ci:: Build spirv-fuzz 60fd4e5da5Sopenharmony_ciset CMAKE_FLAGS=%CMAKE_FLAGS% -DSPIRV_BUILD_FUZZER=ON 61fd4e5da5Sopenharmony_ci 62fd4e5da5Sopenharmony_ciif "%BUILD_TESTS%" == "NO" ( 63fd4e5da5Sopenharmony_ci set CMAKE_FLAGS=-DSPIRV_SKIP_TESTS=ON %CMAKE_FLAGS% 64fd4e5da5Sopenharmony_ci) 65fd4e5da5Sopenharmony_ci 66fd4e5da5Sopenharmony_cicmake %CMAKE_FLAGS% .. 67fd4e5da5Sopenharmony_ci 68fd4e5da5Sopenharmony_ciif %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% 69fd4e5da5Sopenharmony_ci 70fd4e5da5Sopenharmony_ciecho "Build everything... %DATE% %TIME%" 71fd4e5da5Sopenharmony_cininja 72fd4e5da5Sopenharmony_ciif %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% 73fd4e5da5Sopenharmony_ciecho "Build Completed %DATE% %TIME%" 74fd4e5da5Sopenharmony_ci 75fd4e5da5Sopenharmony_ci:: This lets us use !ERRORLEVEL! inside an IF ... () and get the actual error at that point. 76fd4e5da5Sopenharmony_cisetlocal ENABLEDELAYEDEXPANSION 77fd4e5da5Sopenharmony_ci 78fd4e5da5Sopenharmony_ci:: ################################################ 79fd4e5da5Sopenharmony_ci:: Run the tests 80fd4e5da5Sopenharmony_ci:: ################################################ 81fd4e5da5Sopenharmony_ciif "%BUILD_TESTS%" NEQ "NO" ( 82fd4e5da5Sopenharmony_ci echo "Running Tests... %DATE% %TIME%" 83fd4e5da5Sopenharmony_ci ctest -C %BUILD_TYPE% --output-on-failure --timeout 300 84fd4e5da5Sopenharmony_ci if !ERRORLEVEL! NEQ 0 exit /b !ERRORLEVEL! 85fd4e5da5Sopenharmony_ci echo "Tests Completed %DATE% %TIME%" 86fd4e5da5Sopenharmony_ci) 87fd4e5da5Sopenharmony_ci 88fd4e5da5Sopenharmony_ci:: ################################################ 89fd4e5da5Sopenharmony_ci:: Install and package. 90fd4e5da5Sopenharmony_ci:: ################################################ 91fd4e5da5Sopenharmony_cininja install 92fd4e5da5Sopenharmony_cicd %KOKORO_ARTIFACTS_DIR% 93fd4e5da5Sopenharmony_cizip -r install.zip install 94fd4e5da5Sopenharmony_ci 95fd4e5da5Sopenharmony_ci:: Clean up some directories. 96fd4e5da5Sopenharmony_cirm -rf %SRC%\build 97fd4e5da5Sopenharmony_cirm -rf %SRC%\external 98fd4e5da5Sopenharmony_ci 99fd4e5da5Sopenharmony_ciexit /b 0 100