1#!/bin/bash 2 3# Copyright 2020 The Amber Authors. 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17set -e # fail on error 18 19. /bin/using.sh # Declare the bash `using` function for configuring toolchains. 20 21set -x # show commands 22 23# Disable git's "detected dubious ownership" error - kokoro checks out the repo with a different 24# user, and we don't care about this warning. 25git config --global --add safe.directory '*' 26 27using cmake-3.17.2 28using ninja-1.10.0 29using python-3.12 30 31if [ ! -z "$COMPILER" ]; then 32 using "$COMPILER" 33fi 34 35# Possible configurations are: 36# DEBUG, RELEASE 37 38BUILD_TYPE="Debug" 39if [ $CONFIG = "RELEASE" ] 40then 41 BUILD_TYPE="RelWithDebInfo" 42fi 43 44DEPS_ARGS="" 45if [[ "$EXTRA_CONFIG" =~ "USE_CLSPV=TRUE" ]]; then 46 DEPS_ARGS+=" --with-clspv" 47fi 48if [[ "$EXTRA_CONFIG" =~ "USE_DXC=TRUE" ]]; then 49 DEPS_ARGS+=" --with-dxc" 50fi 51if [[ "$EXTRA_CONFIG" =~ "ENABLE_SWIFTSHADER=TRUE" ]]; then 52 DEPS_ARGS+=" --with-swiftshader" 53fi 54 55cd $ROOT_DIR 56./tools/git-sync-deps $DEPS_ARGS 57 58mkdir -p build 59cd $ROOT_DIR/build 60 61# Invoke the build. 62BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT} 63echo $(date): Starting build... 64cmake -GNinja -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ 65 -DAMBER_USE_LOCAL_VULKAN=1 \ 66 $EXTRA_CONFIG .. 67 68echo $(date): Build everything... 69ninja 70echo $(date): Build completed. 71 72echo $(date): Starting amber_unittests... 73./amber_unittests 74echo $(date): amber_unittests completed. 75 76# Swiftshader is only built with gcc, so only run the integration tests with gcc 77if [[ "$EXTRA_CONFIG" =~ "ENABLE_SWIFTSHADER=TRUE" ]]; then 78 OPTS= 79 if [[ $EXTRA_CONFIG =~ "USE_CLSPV=ON" ]]; then 80 OPTS="--use-opencl" 81 fi 82 if [[ "$EXTRA_CONFIG" =~ "USE_DXC=TRUE" ]]; then 83 OPTS+=" --use-dxc" 84 fi 85 86 echo $(date): Starting integration tests.. 87 export LD_LIBRARY_PATH=$ROOT_DIR/build/third_party/vulkan-loader/loader 88 export VK_LAYER_PATH=$ROOT_DIR/build/third_party/vulkan-validationlayers/layers 89 export VK_ICD_FILENAMES=$ROOT_DIR/build/Linux/vk_swiftshader_icd.json 90 cd $ROOT_DIR 91 python3 ./tests/run_tests.py --build-dir $ROOT_DIR/build --use-swiftshader $OPTS 92 echo $(date): integration tests completed. 93fi 94