Skip to content

Commit 0591f0e

Browse files
committed
Kokoro Ubuntu: Switch to docker image
`presubmit.sh` now runs presubmit-docker.sh using the new radial docker image which contains various toolchains. The `/bin/using.sh` bash script exports the `using` bash function which can be called to configure toolchains at specific versions.
1 parent bf9255d commit 0591f0e

File tree

3 files changed

+84
-87
lines changed

3 files changed

+84
-87
lines changed

examples/BUILD.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,13 @@ cc_binary(
4141
"//:marl",
4242
],
4343
)
44+
45+
cc_binary(
46+
name = "tasks_in_tasks",
47+
srcs = [
48+
"tasks_in_tasks.cpp",
49+
],
50+
deps = [
51+
"//:marl",
52+
],
53+
)

kokoro/ubuntu/presubmit-docker.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
3+
set -e # Fail on any error.
4+
5+
. /bin/using.sh # Declare the bash `using` function for configuring toolchains.
6+
7+
set -x # Display commands being run.
8+
9+
cd github/marl
10+
11+
git submodule update --init
12+
13+
using gcc-9 # Always update gcc so we get a newer standard library.
14+
15+
if [ "$BUILD_SYSTEM" == "cmake" ]; then
16+
using cmake-3.17.2
17+
18+
mkdir build
19+
cd build
20+
21+
if [ "$BUILD_TOOLCHAIN" == "clang" ]; then
22+
using clang-10.0.0
23+
fi
24+
25+
EXTRA_CMAKE_FLAGS=""
26+
if [ "$BUILD_TARGET_ARCH" == "x86" ]; then
27+
EXTRA_CMAKE_FLAGS="-DCMAKE_CXX_FLAGS=-m32 -DCMAKE_C_FLAGS=-m32 -DCMAKE_ASM_FLAGS=-m32"
28+
fi
29+
30+
if [ "$BUILD_SANITIZER" == "asan" ]; then
31+
EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DMARL_ASAN=1"
32+
elif [ "$BUILD_SANITIZER" == "msan" ]; then
33+
EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DMARL_MSAN=1"
34+
elif [ "$BUILD_SANITIZER" == "tsan" ]; then
35+
EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DMARL_TSAN=1"
36+
fi
37+
38+
cmake .. ${EXTRA_CMAKE_FLAGS} \
39+
-DMARL_BUILD_EXAMPLES=1 \
40+
-DMARL_BUILD_TESTS=1 \
41+
-DMARL_BUILD_BENCHMARKS=1 \
42+
-DMARL_WARNINGS_AS_ERRORS=1
43+
44+
make --jobs=$(nproc)
45+
46+
./marl-unittests
47+
./fractal
48+
./hello_task
49+
./primes > /dev/null
50+
./tasks_in_tasks
51+
52+
elif [ "$BUILD_SYSTEM" == "bazel" ]; then
53+
using bazel-3.1.0
54+
55+
bazel test //:tests --test_output=all
56+
bazel run //examples:fractal
57+
bazel run //examples:hello_task
58+
bazel run //examples:primes > /dev/null
59+
bazel run //examples:tasks_in_tasks
60+
else
61+
echo "Unknown build system: $BUILD_SYSTEM"
62+
exit 1
63+
fi

kokoro/ubuntu/presubmit.sh

Lines changed: 11 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,17 @@
11
#!/bin/bash
22

33
set -e # Fail on any error.
4-
set -x # Display commands being run.
54

6-
BUILD_ROOT=$PWD
5+
ROOT_DIR=`pwd`
76
SCRIPT_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

Comments
 (0)