• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright 2018 The Amber Authors.
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
16set -e  # fail on error
17set -x  # show commands
18
19BUILD_ROOT=$PWD
20SRC=$PWD/github/amber
21BUILD_TYPE=$1
22shift
23EXTRA_CONFIG=$@
24
25# Get ninja
26wget -q https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-mac.zip
27unzip -q ninja-mac.zip
28chmod +x ninja
29export PATH="$PWD:$PATH"
30
31# Get Cmake (required for Kokoro Apple Silicon images)
32CMAKE_VER=3.30.2
33wget -q https://github.com/Kitware/CMake/releases/download/v$CMAKE_VER/cmake-$CMAKE_VER-macos-universal.tar.gz
34tar xf cmake-$CMAKE_VER-macos-universal.tar.gz
35chmod +x cmake-$CMAKE_VER-macos-universal/CMake.app/Contents/bin/*
36export PATH="$PWD/cmake-$CMAKE_VER-macos-universal/CMake.app/Contents/bin:$PATH"
37
38echo $(date): $(cmake --version)
39
40DEPS_ARGS=""
41if [[ "$EXTRA_CONFIG" =~ "ENABLE_SWIFTSHADER=TRUE" ]]; then
42  DEPS_ARGS+=" --with-swiftshader"
43fi
44
45cd $SRC
46./tools/git-sync-deps $DEPS_ARGS
47
48mkdir build && cd $SRC/build
49
50CMAKE_C_CXX_COMPILER="-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++"
51
52# Invoke the build.
53BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT}
54echo $(date): Starting build...
55cmake -GNinja -DCMAKE_BUILD_TYPE=$BUILD_TYPE $CMAKE_C_CXX_COMPILER \
56  -DAMBER_USE_LOCAL_VULKAN=1 \
57  -DAMBER_ENABLE_SWIFTSHADER=1 \
58  ..
59
60echo $(date): Build everything...
61ninja
62echo $(date): Build completed.
63
64echo $(date): Starting amber_unittests...
65./amber_unittests
66echo $(date): amber_unittests completed.
67
68# Tests currently fail on Debug build on the bots
69if [[ "$EXTRA_CONFIG" =~ "ENABLE_SWIFTSHADER=TRUE" ]]; then
70  echo $(date): Starting integration tests..
71  export LD_LIBRARY_PATH=build/third_party/vulkan-loader/loader
72  export VK_LAYER_PATH=build/third_party/vulkan-validationlayers/layers
73  export VK_ICD_FILENAMES=build/Darwin/vk_swiftshader_icd.json
74  cd $SRC
75  ./tests/run_tests.py --build-dir $SRC/build --use-swiftshader
76  echo $(date): integration tests completed.
77fi
78