1#!/bin/bash 2 3# Copyright 2022 The SwiftShader Authors. All Rights Reserved. 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 any error. 18 19function show_cmds { set -x; } 20function hide_cmds { { set +x; } 2>/dev/null; } 21function task_begin { 22 TASK_NAME="$@" 23 SECONDS=0 24} 25function print_last_task_duration { 26 if [ ! -z "${TASK_NAME}" ]; then 27 echo "${TASK_NAME} completed in $(($SECONDS / 3600))h$((($SECONDS / 60) % 60))m$(($SECONDS % 60))s" 28 fi 29} 30function status { 31 echo "" 32 echo "" 33 print_last_task_duration 34 echo "" 35 echo "*****************************************************************" 36 echo "* $@" 37 echo "*****************************************************************" 38 echo "" 39 task_begin $@ 40} 41 42CLONE_SRC_DIR="$(pwd)" 43 44. /bin/using.sh # Declare the bash `using` function for configuring toolchains. 45 46using cmake-3.31.2 47using gcc-13 48 49status "Cloning to clean source directory at '${SRC_DIR}'" 50 51set -x 52# The source git repo was created in the host environment (outside 53# docker) and is owned by a different user than the one running 54# inside the docker container. Tell git to bypass the ownership 55# check: it's ok to read and operate on the repo. 56git config --global --add safe.directory '*' 57 58mkdir -p ${SRC_DIR} 59cd ${SRC_DIR} 60git clone ${CLONE_SRC_DIR} . 61set +x 62 63mkdir -p build && cd build 64 65if [[ -z "${REACTOR_BACKEND}" ]]; then 66 REACTOR_BACKEND="LLVM" 67fi 68 69# Lower the amount of debug info, to reduce Kokoro build times. 70SWIFTSHADER_LESS_DEBUG_INFO=1 71 72status "Generating CMake build files" 73cmake .. \ 74 "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" \ 75 "-DREACTOR_BACKEND=${REACTOR_BACKEND}" \ 76 "-DSWIFTSHADER_LLVM_VERSION=${LLVM_VERSION}" \ 77 "-DREACTOR_VERIFY_LLVM_IR=1" \ 78 "-DSWIFTSHADER_LESS_DEBUG_INFO=${SWIFTSHADER_LESS_DEBUG_INFO}" \ 79 "-DSWIFTSHADER_BUILD_BENCHMARKS=1" 80 81status "Building" 82cmake --build . -- -j $(nproc) 83 84status "Running unit tests" 85 86cd .. # Some tests must be run from project root 87 88build/ReactorUnitTests 89build/system-unittests 90build/vk-unittests 91 92status "Building and running rr::Print unit tests" 93 94cd build 95cmake .. "-DREACTOR_ENABLE_PRINT=1" 96cmake --build . --target ReactorUnitTests -- -j $(nproc) 97cmake .. "-DREACTOR_ENABLE_PRINT=0" 98cd .. 99build/ReactorUnitTests --gtest_filter=ReactorUnitTests.Print* 100 101status "Building and testing with REACTOR_EMIT_ASM_FILE" 102 103cd build 104cmake .. "-DREACTOR_EMIT_ASM_FILE=1" 105cmake --build . --target ReactorUnitTests -- -j $(nproc) 106cmake .. "-DREACTOR_EMIT_ASM_FILE=0" 107cd .. 108build/ReactorUnitTests --gtest_filter=ReactorUnitTests.EmitAsm 109 110#status "Building with REACTOR_EMIT_DEBUG_INFO" 111# 112#cd build 113#cmake .. "-DREACTOR_EMIT_DEBUG_INFO=1" 114#cmake --build . --target ReactorUnitTests -- -j $(nproc) 115#cmake .. "-DREACTOR_EMIT_DEBUG_INFO=0" 116#cd .. 117 118#status "Building with REACTOR_EMIT_PRINT_LOCATION" 119# 120#cd build 121#cmake .. "-DREACTOR_EMIT_PRINT_LOCATION=1" 122#cmake --build . --target ReactorUnitTests -- -j $(nproc) 123#cmake .. "-DREACTOR_EMIT_PRINT_LOCATION=0" 124#cd .. 125 126status "Done" 127