2019-04-04 11:33:38 +03:00
|
|
|
#!/usr/bin/env bash
|
2019-08-13 19:23:03 +03:00
|
|
|
# Copyright (c) 2019 The DAML Authors. All rights reserved.
|
2019-04-04 11:33:38 +03:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
set -euo pipefail
|
2019-04-04 14:03:56 +03:00
|
|
|
cd "$(dirname "$0")/.."
|
2019-04-04 11:33:38 +03:00
|
|
|
|
|
|
|
## Functions
|
|
|
|
|
|
|
|
step() {
|
|
|
|
echo "step: $*" >&2
|
|
|
|
}
|
|
|
|
|
2019-04-11 15:26:55 +03:00
|
|
|
is_windows() {
|
|
|
|
[[ $os = windows ]]
|
2019-04-04 11:33:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
## Main
|
|
|
|
|
2019-05-11 06:27:17 +03:00
|
|
|
# always run in the project root
|
2019-04-11 15:26:55 +03:00
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
|
2019-05-11 06:27:17 +03:00
|
|
|
# detect the OS
|
2019-04-11 15:26:55 +03:00
|
|
|
case $(uname) in
|
|
|
|
Linux)
|
|
|
|
os=linux
|
|
|
|
;;
|
|
|
|
Darwin)
|
|
|
|
os=darwin
|
|
|
|
;;
|
|
|
|
MINGW*)
|
|
|
|
os=windows
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "unknown kernel: $(uname)"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2019-04-04 11:33:38 +03:00
|
|
|
cd "$(dirname "$0")"/..
|
|
|
|
|
|
|
|
step "configuring bazel"
|
|
|
|
|
2019-04-11 15:26:55 +03:00
|
|
|
if is_windows; then
|
2019-04-12 14:25:31 +03:00
|
|
|
echo "build --config windows" > .bazelrc.local
|
|
|
|
echo "build --config windows-ci" >> .bazelrc.local
|
2019-04-11 15:26:55 +03:00
|
|
|
fi
|
|
|
|
|
2019-04-04 15:48:37 +03:00
|
|
|
# sets up write access to the shared remote cache if the branch is not a fork
|
2019-04-04 14:03:56 +03:00
|
|
|
if [[ "${IS_FORK}" = False ]]; then
|
2019-04-04 15:48:17 +03:00
|
|
|
step "configuring write access to the remote cache"
|
2019-04-11 15:26:55 +03:00
|
|
|
GOOGLE_APPLICATION_CREDENTIALS=$(mktemp .tmp.XXXXXXXXXX)
|
2019-04-04 11:33:38 +03:00
|
|
|
echo "$GOOGLE_APPLICATION_CREDENTIALS_CONTENT" > "$GOOGLE_APPLICATION_CREDENTIALS"
|
|
|
|
unset GOOGLE_APPLICATION_CREDENTIALS_CONTENT
|
|
|
|
export GOOGLE_APPLICATION_CREDENTIALS
|
|
|
|
echo "build --remote_http_cache=https://storage.googleapis.com/daml-bazel-cache --remote_upload_local_results=true --google_credentials=${GOOGLE_APPLICATION_CREDENTIALS}" >> .bazelrc.local
|
|
|
|
fi
|