Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / build / mozconfig.cache
blob33092c9861544151cf0fa25cceabe2823f45bb8d
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 # Setup for build cache
7 # Thunderbird builds will set prior to including this file
8 aws_prefix=${aws_prefix:-taskcluster}
9 gcp_prefix=${gcp_prefix:-sccache}
11 if test -n "$SCCACHE_DISABLE" -a -n "$USE_SCCACHE"; then
12     echo "SetupError: SCCACHE_DISABLE and USE_SCCACHE should not be set at the same time" >&2
13     exit 1
16 # builds where buildprops didn't have the data (eg: taskcluster) and without sccache disabled:
17 if test -z "$bucket" -a -z "$SCCACHE_DISABLE"; then
19     # prevent rerun if az is set, or wget is not available
20     if test -z "$availability_zone" -a -x "$(command -v wget)"; then
21         if test -n "$TASKCLUSTER_WORKER_LOCATION" -a -x "$(command -v jq)"; then
22             cloud=$(echo $TASKCLUSTER_WORKER_LOCATION | jq .cloud | tr -d \")
23             case $cloud in
24                 aws|google)
25                     availability_zone=$(echo $TASKCLUSTER_WORKER_LOCATION | jq .availabilityZone | tr -d \")
26                     region=$(echo $TASKCLUSTER_WORKER_LOCATION | jq .region | tr -d \")
27                     ;;
28             esac
29         fi
30         if test -z "$availability_zone" -o -z "$region"; then
31             if test -n "${TASKCLUSTER_WORKER_GROUP}"; then
32                 # TASKCLUSTER_WORKER_GROUP is just the region now, so
33                 # stick an extra character on to make the already-convoluted logic
34                 # here simpler.
35                 availability_zone="${TASKCLUSTER_WORKER_GROUP}x"
36             elif [ -n "${SCCACHE_GCS_KEY_PATH}" ]; then
37                 # gcp availability_zone is of the form <region>-<letter> where region is e.g. us-west2, and az is us-west2-a
38                 gcp_zone=$(wget -T 1 -t 1 -q -O - http://169.254.169.254/computeMetadata/v1beta1/instance/zone || true)
39                 availability_zone=${gcp_zone##*/}
40             else
41                 # timeout after 1 second, and don't retry (failure indicates instance is not in ec2 or network issue)
42                 # ec2 availability_zone is of the form <region><letter> where region is e.g. us-west-2, and az is us-west-2a
43                 availability_zone=$(wget -T 1 -t 1 -q -O - http://169.254.169.254/latest/meta-data/placement/availability-zone || true)
44             fi
45         fi
46         if test -z "$availability_zone" -o "$availability_zone" = "not-ec2"; then
47             availability_zone=not-ec2
48         elif test -n "$cloud"; then
49             case $cloud in
50             google)
51                 bucket=${gcp_prefix}-l${MOZ_SCM_LEVEL}-${region}
52                 ;;
53             aws)
54                 bucket=${aws_prefix}-level-${MOZ_SCM_LEVEL}-sccache-${region}
55                 ;;
56             esac
57         elif [ -n "${SCCACHE_GCS_KEY_PATH}" ]; then
58             # gcp region is az with last two letters trimmed
59             if test -z "$region"; then
60                 region=${availability_zone::${#availability_zone}-2}
61             fi
62             bucket=${aws_prefix}-level-${MOZ_SCM_LEVEL}-sccache-${region}
63         else
64             # ec2 region is az with last letter trimmed
65             if test -z "$region"; then
66                 region=${availability_zone%?}
67             fi
68             bucket=${aws_prefix}-level-${MOZ_SCM_LEVEL}-sccache-${region}
69         fi
70     fi
73 if test -n "$bucket"; then
74     if test "$cloud" = "google"; then
75         mk_add_options "export SCCACHE_GCS_BUCKET=$bucket"
76         mk_add_options "export SCCACHE_GCS_RW_MODE=READ_WRITE"
77         mk_add_options "export SCCACHE_GCS_CREDENTIALS_URL=http://taskcluster/auth/v1/gcp/credentials/$SCCACHE_GCS_PROJECT/${bucket}@$SCCACHE_GCS_PROJECT.iam.gserviceaccount.com"
78     elif [ -n "${SCCACHE_GCS_KEY_PATH}" ]; then
79         mk_add_options "export SCCACHE_GCS_BUCKET=$bucket"
80     else
81         mk_add_options "export SCCACHE_BUCKET=$bucket"
82         # instruct sccache to fetch the credentials from the Auth service's awsS3Credentials endpoint, via the Taskcluster proxy.
83         mk_add_options "export AWS_IAM_CREDENTIALS_URL=http://taskcluster/auth/v1/aws/s3/read-write/${bucket}/?format=iam-role-compat"
84     fi
85     export CCACHE="sccache"
86     export SCCACHE_VERBOSE_STATS=1
87     # Workaround for https://github.com/mozilla/sccache/issues/459#issuecomment-618756635
88     mk_add_options "export SCCACHE_MAX_FRAME_LENGTH=50000000"
89     mk_add_options MOZBUILD_MANAGE_SCCACHE_DAEMON=${MOZ_FETCHES_DIR}/sccache/sccache
90 elif test -n "$USE_SCCACHE"; then
91     echo "SetupError: sccache is enabled but there is no shared storage set up for it?" >&2
92     exit 1