Skip to content

Commit

Permalink
Shellcheck: ci/ (2) (#13169)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax authored Sep 22, 2020
1 parent ba54dbd commit 5d401ec
Show file tree
Hide file tree
Showing 17 changed files with 277 additions and 161 deletions.
48 changes: 33 additions & 15 deletions ci/build_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,25 @@ set -e

export PPROF_PATH=/thirdparty_build/bin/pprof

[ -z "${NUM_CPUS}" ] && NUM_CPUS=`grep -c ^processor /proc/cpuinfo`
[ -z "${NUM_CPUS}" ] && NUM_CPUS=$(grep -c ^processor /proc/cpuinfo)
[ -z "${ENVOY_SRCDIR}" ] && export ENVOY_SRCDIR=/source
[ -z "${ENVOY_BUILD_TARGET}" ] && export ENVOY_BUILD_TARGET=//source/exe:envoy-static
[ -z "${ENVOY_BUILD_DEBUG_INFORMATION}" ] && export ENVOY_BUILD_DEBUG_INFORMATION=//source/exe:envoy-static.dwp
[ -z "${ENVOY_BUILD_ARCH}" ] && export ENVOY_BUILD_ARCH=$(uname -m)
[ -z "${ENVOY_BUILD_ARCH}" ] && {
ENVOY_BUILD_ARCH=$(uname -m)
export ENVOY_BUILD_ARCH
}

read -ra BAZEL_BUILD_EXTRA_OPTIONS <<< "${BAZEL_BUILD_EXTRA_OPTIONS:-}"
read -ra BAZEL_EXTRA_TEST_OPTIONS <<< "${BAZEL_EXTRA_TEST_OPTIONS:-}"
read -ra BAZEL_OPTIONS <<< "${BAZEL_OPTIONS:-}"

echo "ENVOY_SRCDIR=${ENVOY_SRCDIR}"
echo "ENVOY_BUILD_TARGET=${ENVOY_BUILD_TARGET}"
echo "ENVOY_BUILD_ARCH=${ENVOY_BUILD_ARCH}"

function setup_gcc_toolchain() {
if [[ ! -z "${ENVOY_STDLIB}" && "${ENVOY_STDLIB}" != "libstdc++" ]]; then
if [[ -n "${ENVOY_STDLIB}" && "${ENVOY_STDLIB}" != "libstdc++" ]]; then
echo "gcc toolchain doesn't support ${ENVOY_STDLIB}."
exit 1
fi
Expand All @@ -26,23 +34,23 @@ function setup_gcc_toolchain() {
export BAZEL_COMPILER=gcc
echo "$CC/$CXX toolchain configured"
else
export BAZEL_BUILD_OPTIONS="--config=remote-gcc ${BAZEL_BUILD_OPTIONS}"
BAZEL_BUILD_OPTIONS=("--config=remote-gcc" "${BAZEL_BUILD_OPTIONS[@]}")
fi
}

function setup_clang_toolchain() {
ENVOY_STDLIB="${ENVOY_STDLIB:-libc++}"
if [[ -z "${ENVOY_RBE}" ]]; then
if [[ "${ENVOY_STDLIB}" == "libc++" ]]; then
export BAZEL_BUILD_OPTIONS="--config=libc++ ${BAZEL_BUILD_OPTIONS}"
BAZEL_BUILD_OPTIONS=("--config=libc++" "${BAZEL_BUILD_OPTIONS[@]}")
else
export BAZEL_BUILD_OPTIONS="--config=clang ${BAZEL_BUILD_OPTIONS}"
BAZEL_BUILD_OPTIONS=("--config=clang" "${BAZEL_BUILD_OPTIONS[@]}")
fi
else
if [[ "${ENVOY_STDLIB}" == "libc++" ]]; then
export BAZEL_BUILD_OPTIONS="--config=remote-clang-libc++ ${BAZEL_BUILD_OPTIONS}"
BAZEL_BUILD_OPTIONS=("--config=remote-clang-libc++" "${BAZEL_BUILD_OPTIONS[@]}")
else
export BAZEL_BUILD_OPTIONS="--config=remote-clang ${BAZEL_BUILD_OPTIONS}"
BAZEL_BUILD_OPTIONS=("--config=remote-clang" "${BAZEL_BUILD_OPTIONS[@]}")
fi
fi
echo "clang toolchain with ${ENVOY_STDLIB} configured"
Expand All @@ -61,7 +69,7 @@ export PATH=/opt/llvm/bin:${PATH}
export CLANG_FORMAT="${CLANG_FORMAT:-clang-format}"

if [[ -f "/etc/redhat-release" ]]; then
export BAZEL_BUILD_EXTRA_OPTIONS+="--copt=-DENVOY_IGNORE_GLIBCXX_USE_CXX11_ABI_ERROR=1"
BAZEL_BUILD_EXTRA_OPTIONS+=("--copt=-DENVOY_IGNORE_GLIBCXX_USE_CXX11_ABI_ERROR=1")
fi

function cleanup() {
Expand All @@ -76,16 +84,25 @@ trap cleanup EXIT
export LLVM_ROOT="${LLVM_ROOT:-/opt/llvm}"
"$(dirname "$0")"/../bazel/setup_clang.sh "${LLVM_ROOT}"

[[ "${BUILD_REASON}" != "PullRequest" ]] && BAZEL_EXTRA_TEST_OPTIONS+=" --nocache_test_results"
[[ "${BUILD_REASON}" != "PullRequest" ]] && BAZEL_EXTRA_TEST_OPTIONS+=("--nocache_test_results")

export BAZEL_QUERY_OPTIONS="${BAZEL_OPTIONS}"
# Use https://docs.bazel.build/versions/master/command-line-reference.html#flag--experimental_repository_cache_hardlinks
# to save disk space.
export BAZEL_BUILD_OPTIONS=" ${BAZEL_OPTIONS} --verbose_failures --show_task_finish --experimental_generate_json_trace_profile \
--test_output=errors --repository_cache=${BUILD_DIR}/repository_cache --experimental_repository_cache_hardlinks \
${BAZEL_BUILD_EXTRA_OPTIONS} ${BAZEL_EXTRA_TEST_OPTIONS}"

[[ "${ENVOY_BUILD_ARCH}" == "aarch64" ]] && BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} --flaky_test_attempts=2 --test_env=HEAPCHECK="
BAZEL_BUILD_OPTIONS=(
"${BAZEL_OPTIONS[@]}"
"--verbose_failures"
"--show_task_finish"
"--experimental_generate_json_trace_profile"
"--test_output=errors"
"--repository_cache=${BUILD_DIR}/repository_cache"
"--experimental_repository_cache_hardlinks"
"${BAZEL_BUILD_EXTRA_OPTIONS[@]}"
"${BAZEL_EXTRA_TEST_OPTIONS[@]}")

[[ "${ENVOY_BUILD_ARCH}" == "aarch64" ]] && BAZEL_BUILD_OPTIONS+=(
"--flaky_test_attempts=2"
"--test_env=HEAPCHECK=")

[[ "${BAZEL_EXPUNGE}" == "1" ]] && bazel clean --expunge

Expand Down Expand Up @@ -119,6 +136,7 @@ export BUILDOZER_BIN="${BUILDOZER_BIN:-/usr/local/bin/buildozer}"
# source tree is different than the current workspace, the setup step is
# skipped.
if [[ "$1" != "-nofetch" && "${ENVOY_SRCDIR}" == "$(bazel info workspace)" ]]; then
# shellcheck source=ci/filter_example_setup.sh
. "$(dirname "$0")"/filter_example_setup.sh
else
echo "Skip setting up Envoy Filter Example."
Expand Down
Loading

0 comments on commit 5d401ec

Please sign in to comment.