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
29
30if [ ! -z "$COMPILER" ]; then
31    using "$COMPILER"
32fi
33
34# Possible configurations are:
35# DEBUG, RELEASE
36
37BUILD_TYPE="Debug"
38if [ $CONFIG = "RELEASE" ]
39then
40  BUILD_TYPE="RelWithDebInfo"
41fi
42
43# Make a directory for Dawn dependencies
44mkdir -p $ROOT_DIR/build/out/dawn-deps && cd $ROOT_DIR/build/out/dawn-deps
45
46# Get depot tools
47git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
48export PATH="$PWD/depot_tools:$PATH"
49
50# Clone the repo as "dawn"
51git clone https://dawn.googlesource.com/dawn dawn && cd dawn
52DAWN=$PWD
53
54# Bootstrap the gclient configuration
55cp scripts/standalone.gclient .gclient
56
57# Fetch external dependencies and toolchains with gclient
58gclient sync
59
60# Generate build files
61mkdir -p out/Release
62touch out/Release/args.gn
63gn gen out/Release
64
65# build dawn
66ninja -C out/Release
67
68cd $ROOT_DIR
69./tools/git-sync-deps
70
71cd $ROOT_DIR/build
72
73# Invoke the build.
74BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT}
75echo $(date): Starting build...
76
77cmake -GNinja ..\
78 -DCMAKE_BUILD_TYPE=$BUILD_TYPE\
79 -DDawn_INCLUDE_DIR=$DAWN/src/include\
80 -DDawn_GEN_INCLUDE_DIR=$DAWN/out/Release/gen/src/include\
81 -DDawn_LIBRARY_DIR=$DAWN/out/Release
82
83echo $(date): Build everything...
84ninja
85echo $(date): Build completed.
86
87echo $(date): Starting amber_unittests...
88./amber_unittests
89echo $(date): amber_unittests completed.
90