2 # This script guesses some environment variables based on the builder name and
3 # the current platform, to reduce the amount of variables defined in the CI
9 source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
11 # Since matrix variables are readonly in Azure Pipelines, we take
12 # INITIAL_RUST_CONFIGURE_ARGS and establish RUST_CONFIGURE_ARGS
13 # which downstream steps can alter
14 if isAzurePipelines; then
15 # macOS ships with Bash 3.16, so we cannot use [[ -v FOO ]],
16 # which was introduced in Bash 4.2
17 if [[ -z "${INITIAL_RUST_CONFIGURE_ARGS+x}" ]]; then
18 INITIAL_RUST_CONFIG=""
19 echo "No initial Rust configure args set"
21 INITIAL_RUST_CONFIG="${INITIAL_RUST_CONFIGURE_ARGS}"
22 ciCommandSetEnv RUST_CONFIGURE_ARGS "${INITIAL_RUST_CONFIG}"
26 # Load extra environment variables
27 vars="${EXTRA_VARIABLES-}"
28 echo "${vars}" | jq '' >/dev/null # Validate JSON and exit on errors
29 for key in $(echo "${vars}" | jq "keys[]" -r); do
30 # On Windows, for whatever reason, $key contains the BOM character in it,
31 # and that messes up `jq ".${key}"`. This line strips the BOM from the key.
33 # https://unix.stackexchange.com/a/381263
34 key="$(echo "${key}" | sed '1s/^\xEF\xBB\xBF//')"
36 echo "adding extra environment variable ${key}"
37 value="$(echo "${vars}" | jq ".${key}" -r)"
38 export "${key}"="${value}"
39 ciCommandSetEnv "${key}" "${value}"
42 # Builders starting with `dist-` are dist builders, but if they also end with
43 # `-alt` they are alternate dist builders.
44 if [[ "${CI_JOB_NAME}" = dist-* ]]; then
45 if [[ "${CI_JOB_NAME}" = *-alt ]]; then
46 echo "alternate dist builder detected, setting DEPLOY_ALT=1"
47 ciCommandSetEnv DEPLOY_ALT 1
49 echo "normal dist builder detected, setting DEPLOY=1"
50 ciCommandSetEnv DEPLOY 1
54 # All the Linux builds happen inside Docker.
56 if [[ -z "${IMAGE+x}" ]]; then
57 echo "linux builder detected, using docker to run the build"
58 ciCommandSetEnv IMAGE "${CI_JOB_NAME}"
60 echo "a custom docker image is already set"