• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (c) 2021 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# Linux Build Script.
17
18# Fail on any error.
19set -e
20
21SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"
22ROOT_DIR="$( cd "${SCRIPT_DIR}/../../.." >/dev/null 2>&1 && pwd )"
23
24CONFIG=$1
25COMPILER=$2
26TOOL=$3
27BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT}
28
29# "--privileged" is required to run ptrace in the asan builds.
30docker run --rm -i \
31  --privileged \
32  --volume "${ROOT_DIR}:${ROOT_DIR}" \
33  --volume "${KOKORO_ARTIFACTS_DIR}:${KOKORO_ARTIFACTS_DIR}" \
34  --workdir "${ROOT_DIR}" \
35  --env SCRIPT_DIR=${SCRIPT_DIR} \
36  --env ROOT_DIR=${ROOT_DIR} \
37  --env CONFIG=${CONFIG} \
38  --env COMPILER=${COMPILER} \
39  --env TOOL=${TOOL} \
40  --env KOKORO_ARTIFACTS_DIR="${KOKORO_ARTIFACTS_DIR}" \
41  --env BUILD_SHA="${BUILD_SHA}" \
42  --entrypoint "${SCRIPT_DIR}/build-docker.sh" \
43  "gcr.io/shaderc-build/radial-build:latest"
44
45
46# chown the given directory to the current user, if it exists.
47# Docker creates files with the root user - this can upset the Kokoro artifact copier.
48function chown_dir() {
49  dir=$1
50  if [[ -d "$dir" ]]; then
51    sudo chown -R "$(id -u):$(id -g)" "$dir"
52  fi
53}
54
55chown_dir "${ROOT_DIR}/build"
56chown_dir "${ROOT_DIR}/external"
57