1#!/bin/bash 2# 3# Copyright 2020 The Hafnium Authors. 4# 5# Use of this source code is governed by a BSD-style 6# license that can be found in the LICENSE file or at 7# https://opensource.org/licenses/BSD-3-Clause. 8 9# Fail on any error. 10set -e 11# Fail on any part of a pipeline failing. 12set -o pipefail 13# Treat unset variables as an error. 14set -u 15# Display commands being run. 16set -x 17 18TIMEOUT=(timeout --foreground) 19# Set path to prebuilts used in the build. 20UNAME_S=$(uname -s | tr '[:upper:]' '[:lower:]') 21UNAME_M=$(uname -m) 22 23if [ $UNAME_M == "x86_64" ] 24then 25 UNAME_M=x64 26fi 27 28export PREBUILTS="$PWD/prebuilts/${UNAME_S}-${UNAME_M}" 29 30# Find out where libc++.so.1 resides so that LD_LIBRARY_PATH is adjusted to 31# the right toolchain lib path. This is required by unit tests. 32# Do an explicit search because the libs path is different from older toolchains 33# (e.g. LLVM/clang 12) to newer toolchains (e.g. clang 15). 34LLVM_LIB_PATH=$(clang -print-file-name="libc++.so.1") 35export LD_LIBRARY_PATH=$(dirname ${LLVM_LIB_PATH}) 36 37# Set output and log directories. 38PROJECT="${PROJECT:-reference}" 39OUT="out/${PROJECT}" 40# Use the gn args command to search the value of enable_assertions in the 41# args.gn config file. Use grep to take the value from within the quotes. 42ENABLE_ASSERTIONS_BUILD=$(${PREBUILTS}/gn/gn args out/reference \ 43 --list=enable_assertions --short \ 44 | grep -oP '(?<=").*(?=")') 45if [ "$ENABLE_ASSERTIONS_BUILD" == "1" ] 46then 47 BUILD_TYPE="debug" 48else 49 BUILD_TYPE="release" 50fi 51LOG_DIR_BASE="${OUT}/kokoro_log/${BUILD_TYPE}" 52