diff --git a/kokoro/linux/build.sh b/kokoro/linux/build.sh new file mode 100755 index 0000000000..ee79ab87e0 --- /dev/null +++ b/kokoro/linux/build.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Copyright 2021 The Tint Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e # Fail on any error. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" +ROOT_DIR="$( cd "${SCRIPT_DIR}/../.." >/dev/null 2>&1 && pwd )" + +docker run --rm -i \ + --volume "${ROOT_DIR}:${ROOT_DIR}" \ + --volume "${KOKORO_ARTIFACTS_DIR}:/mnt/artifacts" \ + --workdir "${ROOT_DIR}" \ + --env BUILD_TYPE=$BUILD_TYPE \ + --env BUILD_SYSTEM=$BUILD_SYSTEM \ + --env BUILD_SANITIZER=$BUILD_SANITIZER \ + --env BUILD_TOOLCHAIN=$BUILD_TOOLCHAIN \ + --entrypoint "${SCRIPT_DIR}/docker.sh" \ + "gcr.io/shaderc-build/radial-build:latest" diff --git a/kokoro/linux/cmake-clang-debug-asan/build.sh b/kokoro/linux/cmake-clang-debug-asan/build.sh new file mode 100755 index 0000000000..55487701f9 --- /dev/null +++ b/kokoro/linux/cmake-clang-debug-asan/build.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Copyright 2021 The Tint Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e # Fail on any error. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" + +export BUILD_SYSTEM=cmake +export BUILD_TOOLCHAIN=clang +export BUILD_TYPE=Debug +export BUILD_SANITIZER=asan + +${SCRIPT_DIR}/../build.sh diff --git a/kokoro/linux/cmake-clang-debug-asan/presubmit.cfg b/kokoro/linux/cmake-clang-debug-asan/presubmit.cfg new file mode 100644 index 0000000000..bf23a27de1 --- /dev/null +++ b/kokoro/linux/cmake-clang-debug-asan/presubmit.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "tint/kokoro/linux/cmake-clang-debug-asan/build.sh" diff --git a/kokoro/linux/cmake-clang-debug/build.sh b/kokoro/linux/cmake-clang-debug/build.sh new file mode 100755 index 0000000000..fa4fb4cf39 --- /dev/null +++ b/kokoro/linux/cmake-clang-debug/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Copyright 2021 The Tint Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e # Fail on any error. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" + +export BUILD_SYSTEM=cmake +export BUILD_TOOLCHAIN=clang +export BUILD_TYPE=Debug + +${SCRIPT_DIR}/../build.sh diff --git a/kokoro/linux/cmake-clang-debug/presubmit.cfg b/kokoro/linux/cmake-clang-debug/presubmit.cfg new file mode 100644 index 0000000000..0cc8654394 --- /dev/null +++ b/kokoro/linux/cmake-clang-debug/presubmit.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "tint/kokoro/linux/cmake-clang-debug/build.sh" diff --git a/kokoro/linux/cmake-clang-release-asan/build.sh b/kokoro/linux/cmake-clang-release-asan/build.sh new file mode 100755 index 0000000000..5799514d22 --- /dev/null +++ b/kokoro/linux/cmake-clang-release-asan/build.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Copyright 2021 The Tint Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e # Fail on any error. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" + +export BUILD_SYSTEM=cmake +export BUILD_TOOLCHAIN=clang +export BUILD_TYPE=RelWithDebInfo +export BUILD_SANITIZER=asan + +${SCRIPT_DIR}/../build.sh diff --git a/kokoro/linux/cmake-clang-release-asan/presubmit.cfg b/kokoro/linux/cmake-clang-release-asan/presubmit.cfg new file mode 100644 index 0000000000..460c9270cd --- /dev/null +++ b/kokoro/linux/cmake-clang-release-asan/presubmit.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "tint/kokoro/linux/cmake-clang-release-asan/build.sh" diff --git a/kokoro/linux/cmake-clang-release/build.sh b/kokoro/linux/cmake-clang-release/build.sh new file mode 100755 index 0000000000..b889c81cbd --- /dev/null +++ b/kokoro/linux/cmake-clang-release/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Copyright 2021 The Tint Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e # Fail on any error. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" + +export BUILD_SYSTEM=cmake +export BUILD_TOOLCHAIN=clang +export BUILD_TYPE=RelWithDebInfo + +${SCRIPT_DIR}/../build.sh diff --git a/kokoro/linux/cmake-clang-release/presubmit.cfg b/kokoro/linux/cmake-clang-release/presubmit.cfg new file mode 100644 index 0000000000..ccc9651b67 --- /dev/null +++ b/kokoro/linux/cmake-clang-release/presubmit.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "tint/kokoro/linux/cmake-clang-release/build.sh" diff --git a/kokoro/linux/cmake-gcc-debug/build.sh b/kokoro/linux/cmake-gcc-debug/build.sh new file mode 100755 index 0000000000..2bd68bd1e1 --- /dev/null +++ b/kokoro/linux/cmake-gcc-debug/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Copyright 2021 The Tint Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e # Fail on any error. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" + +export BUILD_SYSTEM=cmake +export BUILD_TOOLCHAIN=gcc +export BUILD_TYPE=Debug + +${SCRIPT_DIR}/../build.sh diff --git a/kokoro/linux/cmake-gcc-debug/presubmit.cfg b/kokoro/linux/cmake-gcc-debug/presubmit.cfg new file mode 100644 index 0000000000..eb1d4d8f3d --- /dev/null +++ b/kokoro/linux/cmake-gcc-debug/presubmit.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "tint/kokoro/linux/cmake-gcc-debug/build.sh" diff --git a/kokoro/linux/cmake-gcc-release/build.sh b/kokoro/linux/cmake-gcc-release/build.sh new file mode 100755 index 0000000000..1bdee7ce8a --- /dev/null +++ b/kokoro/linux/cmake-gcc-release/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Copyright 2021 The Tint Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e # Fail on any error. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" + +export BUILD_SYSTEM=cmake +export BUILD_TOOLCHAIN=gcc +export BUILD_TYPE=RelWithDebInfo + +${SCRIPT_DIR}/../build.sh diff --git a/kokoro/linux/cmake-gcc-release/presubmit.cfg b/kokoro/linux/cmake-gcc-release/presubmit.cfg new file mode 100644 index 0000000000..95a6cfcd89 --- /dev/null +++ b/kokoro/linux/cmake-gcc-release/presubmit.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "tint/kokoro/linux/cmake-gcc-release/build.sh" diff --git a/kokoro/linux/docker.sh b/kokoro/linux/docker.sh new file mode 100755 index 0000000000..d02b6e3b91 --- /dev/null +++ b/kokoro/linux/docker.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +# Copyright 2021 The Tint Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e # Fail on any error. + +function show_cmds { set -x; } +function hide_cmds { { set +x; } 2>/dev/null; } +function status { + echo "" + echo "*****************************************************************" + echo "* $@" + echo "*****************************************************************" + echo "" +} + +. /bin/using.sh # Declare the bash `using` function for configuring toolchains. + +ORIGINAL_SRC_DIR="$(pwd)" + +status "Cloning to clean source directory" +# We do this so that the docker script can be tested in a local development +# checkout, without having the build litter the local checkout with artifacts +SRC_DIR=/tmp/tint-src +mkdir -p ${SRC_DIR} +cd ${SRC_DIR} +git clone ${ORIGINAL_SRC_DIR} . + +status "Fetching depot_tools" +# TODO(bclayton): Add depot_tools to the docker image +mkdir -p /tmp/depot_tools +curl https://storage.googleapis.com/chrome-infra/depot_tools.zip -o /tmp/depot_tools.zip +unzip /tmp/depot_tools.zip -d /tmp/depot_tools +rm /tmp/depot_tools.zip +export PATH="/tmp/depot_tools:$PATH" + +status "Fetching dependencies" +cp standalone.gclient .gclient +gclient sync + +status "Configuring build system" +if [ "$BUILD_SYSTEM" == "cmake" ]; then + using cmake-3.17.2 + + BUILD_DIR=/tmp/tint-build + mkdir -p ${BUILD_DIR} + + COMMON_CMAKE_FLAGS="" + COMMON_CMAKE_FLAGS+=" -DCMAKE_BUILD_TYPE=${BUILD_TYPE}" + + if [ "$BUILD_TOOLCHAIN" == "clang" ]; then + using clang-10.0.0 + elif [ "$BUILD_TOOLCHAIN" == "gcc" ]; then + using gcc-9 + fi + + if [ "$BUILD_SANITIZER" == "asan" ]; then + COMMON_CMAKE_FLAGS+=" -DTINT_ENABLE_ASAN=1" + fi + + cd ${BUILD_DIR} + + status "Building tint" + show_cmds + cmake ${SRC_DIR} ${CMAKE_FLAGS} ${COMMON_CMAKE_FLAGS} + make --jobs=$(nproc) + hide_cmds + + status "Running tint_unittests" + show_cmds + ./tint_unittests + hide_cmds + + status "Testing test/test-all.sh" + show_cmds + ${SRC_DIR}/test/test-all.sh "${BUILD_DIR}/tint" + hide_cmds + +else + status "Unsupported build system: $BUILD_SYSTEM" + exit 1 +fi + +status "Done"