11#! /bin/bash
22
33set -e # Fail on any error.
4- set -x # Display commands being run.
54
6- BUILD_ROOT= $PWD
5+ ROOT_DIR= ` pwd `
76SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " > /dev/null 2>&1 && pwd ) "
8- UBUNTU_VERSION=` cat /etc/os-release | grep -oP " Ubuntu \K([0-9]+\.[0-9]+)" `
97
10- cd github/marl
11-
12- git submodule update --init
13-
14- # Always update gcc so we get a newer standard library.
15- sudo add-apt-repository ppa:ubuntu-toolchain-r/test
16- sudo apt-get update
17- sudo apt-get install -y gcc-9-multilib g++-9-multilib linux-libc-dev:i386
18- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100 --slave /usr/bin/g++ g++ /usr/bin/g++-9
19- sudo update-alternatives --set gcc " /usr/bin/gcc-9"
20-
21- if [ " $BUILD_SYSTEM " == " cmake" ]; then
22- mkdir build
23- cd build
24-
25- if [ " $BUILD_TOOLCHAIN " == " clang" ]; then
26- # Download clang tar
27- CLANG_TAR=" /tmp/clang-8.tar.xz"
28- curl -L " https://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-${UBUNTU_VERSION} .tar.xz" > ${CLANG_TAR}
29-
30- # Verify clang tar
31- sudo apt-get install pgpgpg
32- gpg --import " ${SCRIPT_DIR} /clang-8.pubkey.asc"
33- gpg --verify " ${SCRIPT_DIR} /clang-8-ubuntu-${UBUNTU_VERSION} .sig" ${CLANG_TAR}
34- if [ $? -ne 0 ]; then
35- echo " clang download failed PGP check"
36- exit 1
37- fi
38-
39- # Untar into tmp
40- CLANG_DIR=/tmp/clang-8
41- mkdir ${CLANG_DIR}
42- tar -xf ${CLANG_TAR} -C ${CLANG_DIR}
43-
44- # Use clang as compiler
45- export CC=" ${CLANG_DIR} /clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-${UBUNTU_VERSION} /bin/clang"
46- export CXX=" ${CLANG_DIR} /clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-${UBUNTU_VERSION} /bin/clang++"
47- fi
48-
49- extra_cmake_flags=" "
50- if [ " $BUILD_TARGET_ARCH " == " x86" ]; then
51- extra_cmake_flags=" -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_C_FLAGS=-m32 -DCMAKE_ASM_FLAGS=-m32"
52- fi
53-
54- build_and_run () {
55- cmake .. ${extra_cmake_flags} \
56- -DMARL_BUILD_EXAMPLES=1 \
57- -DMARL_BUILD_TESTS=1 \
58- -DMARL_BUILD_BENCHMARKS=1 \
59- -DMARL_WARNINGS_AS_ERRORS=1 \
60- $1
61-
62- make --jobs=$( nproc)
63-
64- ./marl-unittests
65- ./fractal
66- ./hello_task
67- ./primes > /dev/null
68- ./tasks_in_tasks
69- }
70-
71- if [ " $BUILD_SANITIZER " == " asan" ]; then
72- build_and_run " -DMARL_ASAN=1"
73- elif [ " $BUILD_SANITIZER " == " msan" ]; then
74- build_and_run " -DMARL_MSAN=1"
75- elif [ " $BUILD_SANITIZER " == " tsan" ]; then
76- build_and_run " -DMARL_TSAN=1"
77- else
78- build_and_run
79- fi
80- elif [ " $BUILD_SYSTEM " == " bazel" ]; then
81- # Get bazel
82- curl -L -k -O -s https://github.com/bazelbuild/bazel/releases/download/0.29.1/bazel-0.29.1-installer-linux-x86_64.sh
83- mkdir $BUILD_ROOT /bazel
84- bash bazel-0.29.1-installer-linux-x86_64.sh --prefix=$BUILD_ROOT /bazel
85- rm bazel-0.29.1-installer-linux-x86_64.sh
86- # Build and run
87- $BUILD_ROOT /bazel/bin/bazel test //:tests --test_output=all
88- $BUILD_ROOT /bazel/bin/bazel run //examples:fractal
89- $BUILD_ROOT /bazel/bin/bazel run //examples:primes > /dev/null
90- else
91- echo " Unknown build system: $BUILD_SYSTEM "
92- exit 1
93- fi
8+ docker run --rm -i \
9+ --volume " ${ROOT_DIR} :${ROOT_DIR} " \
10+ --volume " ${KOKORO_ARTIFACTS_DIR} :/mnt/artifacts" \
11+ --workdir " ${ROOT_DIR} " \
12+ --env BUILD_SYSTEM=$BUILD_SYSTEM \
13+ --env BUILD_TOOLCHAIN=$BUILD_TOOLCHAIN \
14+ --env BUILD_TARGET_ARCH=$BUILD_TARGET_ARCH \
15+ --env BUILD_SANITIZER=$BUILD_SANITIZER \
16+ --entrypoint " ${SCRIPT_DIR} /presubmit-docker.sh" \
17+ " gcr.io/shaderc-build/radial-build:latest"
0 commit comments