diff --git a/kokoro/android/build.sh b/kokoro/android/build.sh old mode 100644 new mode 100755 diff --git a/kokoro/check-format/build.sh b/kokoro/check-format/build.sh old mode 100644 new mode 100755 diff --git a/kokoro/linux-clang-debug/build.sh b/kokoro/linux-clang-debug/build.sh old mode 100644 new mode 100755 index ef50693ae..aa3867668 --- a/kokoro/linux-clang-debug/build.sh +++ b/kokoro/linux-clang-debug/build.sh @@ -17,4 +17,5 @@ set -e # fail on error set -x # display commands SCRIPT_DIR=`dirname "$BASH_SOURCE"` -source $SCRIPT_DIR/../scripts/linux/build.sh DEBUG clang -DAMBER_ENABLE_SWIFTSHADER=TRUE +source $SCRIPT_DIR/../scripts/linux/build.sh DEBUG "clang-10.0.0" \ + -DAMBER_ENABLE_SWIFTSHADER=TRUE diff --git a/kokoro/linux-clang-release/build.sh b/kokoro/linux-clang-release/build.sh old mode 100644 new mode 100755 index c3cb8dd42..79cb5fafd --- a/kokoro/linux-clang-release/build.sh +++ b/kokoro/linux-clang-release/build.sh @@ -17,6 +17,6 @@ set -e # fail on error set -x # display commands SCRIPT_DIR=`dirname "$BASH_SOURCE"` -source $SCRIPT_DIR/../scripts/linux/build.sh RELEASE clang \ - -DAMBER_ENABLE_SWIFTSHADER=TRUE \ - -DAMBER_USE_DXC=TRUE +source $SCRIPT_DIR/../scripts/linux/build.sh RELEASE "clang-10.0.0" \ + -DAMBER_ENABLE_SWIFTSHADER=TRUE \ + -DAMBER_USE_DXC=TRUE diff --git a/kokoro/linux-gcc-debug-dawn/build.sh b/kokoro/linux-gcc-debug-dawn/build.sh old mode 100644 new mode 100755 index 30c41810a..4f35b1303 --- a/kokoro/linux-gcc-debug-dawn/build.sh +++ b/kokoro/linux-gcc-debug-dawn/build.sh @@ -17,4 +17,4 @@ set -e # fail on error set -x # display commands SCRIPT_DIR=`dirname "$BASH_SOURCE"` -source $SCRIPT_DIR/../scripts/linux/build_dawn.sh DEBUG gcc +source $SCRIPT_DIR/../scripts/linux/build_dawn.sh DEBUG "gcc-9" diff --git a/kokoro/linux-gcc-debug/build.sh b/kokoro/linux-gcc-debug/build.sh old mode 100644 new mode 100755 index e512ed183..cf6f392b6 --- a/kokoro/linux-gcc-debug/build.sh +++ b/kokoro/linux-gcc-debug/build.sh @@ -17,4 +17,5 @@ set -e # fail on error set -x # display commands SCRIPT_DIR=`dirname "$BASH_SOURCE"` -source $SCRIPT_DIR/../scripts/linux/build.sh DEBUG gcc -DAMBER_ENABLE_SWIFTSHADER=TRUE +source $SCRIPT_DIR/../scripts/linux/build.sh DEBUG "gcc-9" \ + -DAMBER_ENABLE_SWIFTSHADER=TRUE diff --git a/kokoro/linux-gcc-release-clspv/build.sh b/kokoro/linux-gcc-release-clspv/build.sh old mode 100644 new mode 100755 index c0e4187e0..2a13327ee --- a/kokoro/linux-gcc-release-clspv/build.sh +++ b/kokoro/linux-gcc-release-clspv/build.sh @@ -17,4 +17,6 @@ set -e # fail on error set -x # display commands SCRIPT_DIR=`dirname "$BASH_SOURCE"` -source $SCRIPT_DIR/../scripts/linux/build.sh RELEASE gcc -DAMBER_USE_CLSPV=TRUE -DAMBER_ENABLE_SWIFTSHADER=TRUE +source $SCRIPT_DIR/../scripts/linux/build.sh RELEASE "gcc-9" \ + -DAMBER_USE_CLSPV=TRUE \ + -DAMBER_ENABLE_SWIFTSHADER=TRUE diff --git a/kokoro/linux-gcc-release/build.sh b/kokoro/linux-gcc-release/build.sh old mode 100644 new mode 100755 index 967e597b8..506b0c738 --- a/kokoro/linux-gcc-release/build.sh +++ b/kokoro/linux-gcc-release/build.sh @@ -17,6 +17,6 @@ set -e # fail on error set -x # display commands SCRIPT_DIR=`dirname "$BASH_SOURCE"` -source $SCRIPT_DIR/../scripts/linux/build.sh RELEASE gcc \ +source $SCRIPT_DIR/../scripts/linux/build.sh RELEASE "gcc-9" \ -DAMBER_ENABLE_SWIFTSHADER=TRUE \ -DAMBER_USE_DXC=TRUE diff --git a/kokoro/macos-clang-debug/build.sh b/kokoro/macos-clang-debug/build.sh old mode 100644 new mode 100755 diff --git a/kokoro/macos-clang-release/build.sh b/kokoro/macos-clang-release/build.sh old mode 100644 new mode 100755 diff --git a/kokoro/ndk-build/build.sh b/kokoro/ndk-build/build.sh old mode 100644 new mode 100755 diff --git a/kokoro/scripts/linux/build-docker.sh b/kokoro/scripts/linux/build-docker.sh new file mode 100755 index 000000000..06a648056 --- /dev/null +++ b/kokoro/scripts/linux/build-docker.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +# Copyright 2020 The Amber 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 error + +. /bin/using.sh # Declare the bash `using` function for configuring toolchains. + +set -x # show commands + +BUILD_TYPE="Debug" + +using cmake-3.17.2 +using ninja-1.10.0 + +if [ ! -z "$COMPILER" ]; then + using "$COMPILER" +fi + +# Possible configurations are: +# DEBUG, RELEASE + +if [ $CONFIG = "RELEASE" ] +then + BUILD_TYPE="RelWithDebInfo" +fi + +DEPS_ARGS="" +if [[ "$EXTRA_CONFIG" =~ "USE_CLSPV=TRUE" ]]; then + DEPS_ARGS+=" --with-clspv" +fi +if [[ "$EXTRA_CONFIG" =~ "USE_DXC=TRUE" ]]; then + DEPS_ARGS+=" --with-dxc" +fi +if [[ "$EXTRA_CONFIG" =~ "ENABLE_SWIFTSHADER=TRUE" ]]; then + DEPS_ARGS+=" --with-swiftshader" +fi + +cd $ROOT_DIR +./tools/git-sync-deps $DEPS_ARGS + +mkdir -p build +cd $ROOT_DIR/build + +# Invoke the build. +BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT} +echo $(date): Starting build... +cmake -GNinja -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ + -DAMBER_USE_LOCAL_VULKAN=1 \ + $EXTRA_CONFIG .. + +echo $(date): Build everything... +ninja +echo $(date): Build completed. + +echo $(date): Starting amber_unittests... +./amber_unittests +echo $(date): amber_unittests completed. + +# Swiftshader is only built with gcc, so only run the integration tests with gcc +if [[ "$EXTRA_CONFIG" =~ "ENABLE_SWIFTSHADER=TRUE" ]]; then + OPTS= + if [[ $EXTRA_CONFIG =~ "USE_CLSPV=ON" ]]; then + OPTS="--use-opencl" + fi + if [[ "$EXTRA_CONFIG" =~ "USE_DXC=TRUE" ]]; then + OPTS+=" --use-dxc" + fi + + echo $(date): Starting integration tests.. + export LD_LIBRARY_PATH=$ROOT_DIR/build/third_party/vulkan-loader/loader + export VK_LAYER_PATH=$ROOT_DIR/build/third_party/vulkan-validationlayers/layers + export VK_ICD_FILENAMES=$ROOT_DIR/build/Linux/vk_swiftshader_icd.json + cd $ROOT_DIR + python3 ./tests/run_tests.py --build-dir $ROOT_DIR/build --use-swiftshader $OPTS + echo $(date): integration tests completed. +fi diff --git a/kokoro/scripts/linux/build.sh b/kokoro/scripts/linux/build.sh old mode 100644 new mode 100755 index 96e959ec9..e48033d60 --- a/kokoro/scripts/linux/build.sh +++ b/kokoro/scripts/linux/build.sh @@ -1,5 +1,6 @@ #!/bin/bash -# Copyright 2018 The Amber Authors. + +# Copyright (C) 2020 The Amber Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,106 +13,29 @@ # 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. +# +# Linux Build Script. -set -e # fail on error -set -x # show commands - -BUILD_ROOT=$PWD -SRC=$PWD/github/amber -CONFIG=$1 -shift -COMPILER=$1 -shift -EXTRA_CONFIG=$@ - -BUILD_TYPE="Debug" - -# Always update gcc so we get a newer standard library. -sudo add-apt-repository ppa:ubuntu-toolchain-r/test -sudo apt-get -qq update -sudo aptitude install -y gcc-7 g++-7 -sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100 --slave /usr/bin/g++ g++ /usr/bin/g++-7 -sudo update-alternatives --set gcc "/usr/bin/gcc-7" - -CMAKE_C_CXX_COMPILER="" -if [ $COMPILER = "clang" ] -then - CMAKE_C_CXX_COMPILER="-DCMAKE_C_COMPILER=/usr/bin/clang-5.0 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-5.0" -else - CMAKE_C_CXX_COMPILER="-DCMAKE_C_COMPILER=/usr/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7" -fi - -# Possible configurations are: -# DEBUG, RELEASE - -if [ $CONFIG = "RELEASE" ] -then - BUILD_TYPE="RelWithDebInfo" -fi - -# removing the old version -echo y | sudo apt-get purge --auto-remove cmake - -# Update CMake -sudo apt purge -y --auto-remove cmake -wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add - -sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main' -sudo apt-get -qq update -sudo apt-get -qq install -y cmake - -echo $(date): $(cmake --version) - -# Get ninja -wget -q https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip -unzip -q ninja-linux.zip -export PATH="$PWD:$PATH" - -DEPS_ARGS="" -if [[ "$EXTRA_CONFIG" =~ "USE_CLSPV=TRUE" ]]; then - DEPS_ARGS+=" --with-clspv" -fi -if [[ "$EXTRA_CONFIG" =~ "USE_DXC=TRUE" ]]; then - DEPS_ARGS+=" --with-dxc" -fi -if [[ "$EXTRA_CONFIG" =~ "ENABLE_SWIFTSHADER=TRUE" ]]; then - DEPS_ARGS+=" --with-swiftshader" -fi - -cd $SRC -./tools/git-sync-deps $DEPS_ARGS - -mkdir build && cd $SRC/build - -# Invoke the build. -BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT} -echo $(date): Starting build... -cmake -GNinja -DCMAKE_BUILD_TYPE=$BUILD_TYPE $CMAKE_C_CXX_COMPILER \ - -DAMBER_USE_LOCAL_VULKAN=1 \ - $EXTRA_CONFIG .. - -echo $(date): Build everything... -ninja -echo $(date): Build completed. - -echo $(date): Starting amber_unittests... -./amber_unittests -echo $(date): amber_unittests completed. +set -e # Fail on any error. -# Swiftshader is only built with gcc, so only run the integration tests with gcc -if [[ "$EXTRA_CONFIG" =~ "ENABLE_SWIFTSHADER=TRUE" ]]; then - OPTS= - if [[ $EXTRA_CONFIG =~ "USE_CLSPV=ON" ]]; then - OPTS="--use-opencl" - fi - if [[ "$EXTRA_CONFIG" =~ "USE_DXC=TRUE" ]]; then - OPTS+=" --use-dxc" - fi +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" +ROOT_DIR="$( cd "${SCRIPT_DIR}/../../.." >/dev/null 2>&1 && pwd )" - echo $(date): Starting integration tests.. - export LD_LIBRARY_PATH=build/third_party/vulkan-loader/loader - export VK_LAYER_PATH=build/third_party/vulkan-validationlayers/layers - export VK_ICD_FILENAMES=build/Linux/vk_swiftshader_icd.json - cd $SRC - ./tests/run_tests.py --build-dir $SRC/build --use-swiftshader $OPTS - echo $(date): integration tests completed. -fi +CONFIG=$1 +COMPILER=$2 +EXTRA_CONFIG=${@:3} + +docker run --rm -i \ + --volume "${ROOT_DIR}:${ROOT_DIR}" \ + --volume "${KOKORO_ARTIFACTS_DIR}:${KOKORO_ARTIFACTS_DIR}" \ + --workdir "${ROOT_DIR}" \ + --env ROOT_DIR="${ROOT_DIR}" \ + --env SCRIPT_DIR="${SCRIPT_DIR}" \ + --env CONFIG="${CONFIG}" \ + --env COMPILER="${COMPILER}" \ + --env EXTRA_CONFIG="${EXTRA_CONFIG}" \ + --env KOKORO_ARTIFACTS_DIR="${KOKORO_ARTIFACTS_DIR}" \ + --entrypoint "${SCRIPT_DIR}/build-docker.sh" \ + "gcr.io/shaderc-build/radial-build:latest" + +sudo chown -R "$(id -u):$(id -g)" "${ROOT_DIR}/build" diff --git a/kokoro/scripts/linux/build_dawn-docker.sh b/kokoro/scripts/linux/build_dawn-docker.sh new file mode 100755 index 000000000..0171846a5 --- /dev/null +++ b/kokoro/scripts/linux/build_dawn-docker.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +# Copyright 2020 The Amber 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 error + +. /bin/using.sh # Declare the bash `using` function for configuring toolchains. + +set -x # show commands + +BUILD_TYPE="Debug" + +using cmake-3.17.2 +using ninja-1.10.0 + +if [ ! -z "$COMPILER" ]; then + using "$COMPILER" +fi + +# Possible configurations are: +# DEBUG, RELEASE + +if [ $CONFIG = "RELEASE" ] +then + BUILD_TYPE="RelWithDebInfo" +fi + +# Make a directory for Dawn dependencies +mkdir -p $ROOT_DIR/build/out/dawn-deps && cd $ROOT_DIR/build/out/dawn-deps + +# Get depot tools +git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git +export PATH="$PWD/depot_tools:$PATH" + +# Clone the repo as "dawn" +git clone https://dawn.googlesource.com/dawn dawn && cd dawn +DAWN=$PWD + +# Bootstrap the gclient configuration +cp scripts/standalone.gclient .gclient + +# Fetch external dependencies and toolchains with gclient +gclient sync + +# Generate build files +mkdir -p out/Release +touch out/Release/args.gn +gn gen out/Release + +# build dawn +ninja -C out/Release + +cd $ROOT_DIR +./tools/git-sync-deps + +cd $ROOT_DIR/build + +# Invoke the build. +BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT} +echo $(date): Starting build... + +cmake -GNinja ..\ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE\ + -DDawn_INCLUDE_DIR=$DAWN/src/include\ + -DDawn_GEN_INCLUDE_DIR=$DAWN/out/Release/gen/src/include\ + -DDawn_LIBRARY_DIR=$DAWN/out/Release + +echo $(date): Build everything... +ninja +echo $(date): Build completed. + +echo $(date): Starting amber_unittests... +./amber_unittests +echo $(date): amber_unittests completed. diff --git a/kokoro/scripts/linux/build_dawn.sh b/kokoro/scripts/linux/build_dawn.sh old mode 100644 new mode 100755 index df06adb2e..75a03532c --- a/kokoro/scripts/linux/build_dawn.sh +++ b/kokoro/scripts/linux/build_dawn.sh @@ -1,5 +1,6 @@ #!/bin/bash -# Copyright 2019 The Amber Authors. + +# Copyright (C) 2020 The Amber Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,95 +13,29 @@ # 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. +# +# Linux Build Script. + +set -e # Fail on any error. -set -e # fail on error -set -x # show commands +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" +ROOT_DIR="$( cd "${SCRIPT_DIR}/../../.." >/dev/null 2>&1 && pwd )" -BUILD_ROOT=$PWD -SRC=$PWD/github/amber CONFIG=$1 COMPILER=$2 - -BUILD_TYPE="Debug" - -CMAKE_C_CXX_COMPILER="" -if [ $COMPILER = "clang" ] -then - sudo ln -s /usr/bin/clang-3.8 /usr/bin/clang - sudo ln -s /usr/bin/clang++-3.8 /usr/bin/clang++ - CMAKE_C_CXX_COMPILER="-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++" -fi - -# Possible configurations are: -# DEBUG, RELEASE - -if [ $CONFIG = "RELEASE" ] -then - BUILD_TYPE="RelWithDebInfo" -fi - -# removing the old version -echo y | sudo apt-get purge --auto-remove cmake - -# Update CMake -sudo apt purge -y --auto-remove cmake -wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add - -sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main' -sudo apt-get -qq update -sudo apt-get -qq install -y cmake - -echo $(date): $(cmake --version) - -# Get ninja -wget -q https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip -unzip -q ninja-linux.zip -export PATH="$PWD:$PATH" - -# Make a directory for Dawn dependencies -mkdir -p $SRC/build/out/dawn-deps && cd $SRC/build/out/dawn-deps - -# Get depot tools -git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git -export PATH="$PWD/depot_tools:$PATH" - -# Clone the repo as "dawn" -git clone https://dawn.googlesource.com/dawn dawn && cd dawn -DAWN=$PWD - -# Bootstrap the gclient configuration -cp scripts/standalone.gclient .gclient - -# Fetch external dependencies and toolchains with gclient -gclient sync - -# Generate build files -mkdir -p out/Release -touch out/Release/args.gn -gn gen out/Release - -# build dawn -ninja -C out/Release - -cd $SRC -./tools/git-sync-deps - -cd $SRC/build - -# Invoke the build. -BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT} -echo $(date): Starting build... - -cmake -GNinja ..\ - $CMAKE_C_CXX_COMPILER\ - -DCMAKE_BUILD_TYPE=$BUILD_TYPE\ - -DDawn_INCLUDE_DIR=$DAWN/src/include\ - -DDawn_GEN_INCLUDE_DIR=$DAWN/out/Release/gen/src/include\ - -DDawn_LIBRARY_DIR=$DAWN/out/Release - -echo $(date): Build everything... -ninja -echo $(date): Build completed. - -echo $(date): Starting amber_unittests... -./amber_unittests -echo $(date): amber_unittests completed. +EXTRA_CONFIG=${@:3} + +docker run --rm -i \ + --volume "${ROOT_DIR}:${ROOT_DIR}" \ + --volume "${KOKORO_ARTIFACTS_DIR}:${KOKORO_ARTIFACTS_DIR}" \ + --workdir "${ROOT_DIR}" \ + --env ROOT_DIR="${ROOT_DIR}" \ + --env SCRIPT_DIR="${SCRIPT_DIR}" \ + --env CONFIG="${CONFIG}" \ + --env COMPILER="${COMPILER}" \ + --env EXTRA_CONFIG="${EXTRA_CONFIG}" \ + --env KOKORO_ARTIFACTS_DIR="${KOKORO_ARTIFACTS_DIR}" \ + --entrypoint "${SCRIPT_DIR}/build_dawn-docker.sh" \ + "gcr.io/shaderc-build/radial-build:latest" + +sudo chown -R "$(id -u):$(id -g)" "${ROOT_DIR}/build" diff --git a/kokoro/scripts/macos/build.sh b/kokoro/scripts/macos/build.sh old mode 100644 new mode 100755