1#!/bin/bash 2# Copyright (c) 2018 Google LLC. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16# MacOS Build Script. 17 18# Fail on any error. 19set -e 20# Display commands being run. 21set -x 22 23BUILD_ROOT=$PWD 24SRC=$PWD/github/SPIRV-Tools 25BUILD_TYPE=$1 26 27# This is required to run any git command in the docker since owner will 28# have changed between the clone environment, and the docker container. 29# Marking the root of the repo as safe for ownership changes. 30git config --global --add safe.directory $SRC 31 32# Get NINJA. 33wget -q https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-mac.zip 34unzip -q ninja-mac.zip 35chmod +x ninja 36export PATH="$PWD:$PATH" 37 38cd $SRC 39python3 utils/git-sync-deps --treeless 40 41mkdir build && cd $SRC/build 42 43# Invoke the build. 44BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT} 45echo $(date): Starting build... 46cmake \ 47 -GNinja \ 48 -DCMAKE_INSTALL_PREFIX=$KOKORO_ARTIFACTS_DIR/install \ 49 -DCMAKE_C_COMPILER=clang \ 50 -DCMAKE_CXX_COMPILER=clang++ \ 51 -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ 52 -DSPIRV_BUILD_FUZZER=ON \ 53 .. 54 55echo $(date): Build everything... 56ninja 57echo $(date): Build completed. 58 59echo $(date): Starting ctest... 60ctest -j4 --output-on-failure --timeout 300 61echo $(date): ctest completed. 62 63# Package the build. 64ninja install 65cd $KOKORO_ARTIFACTS_DIR 66tar czf install.tgz install 67 68