Bug 1577498 - Part 3: Ensure actor and conduit cleanup r=rpl
[gecko.git] / build / mozconfig.cache
blob40ed3a82b26198141b478814035a5b791b41be3d
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 # builds where buildprops didn't have the data (eg: taskcluster) and without sccache disabled:
8 if test -z "$bucket" -a -z "$SCCACHE_DISABLE"; then
10     # prevent rerun if az is set, or wget is not available
11     if test -z "$availability_zone" -a -x "$(command -v wget)"; then
12         if test -n "$TASKCLUSTER_WORKER_LOCATION" -a -x "$(command -v jq)"; then
13             cloud=$(echo $TASKCLUSTER_WORKER_LOCATION | jq .cloud | tr -d \")
14             case $cloud in
15                 aws|google)
16                     availability_zone=$(echo $TASKCLUSTER_WORKER_LOCATION | jq .availabilityZone | tr -d \")
17                     region=$(echo $TASKCLUSTER_WORKER_LOCATION | jq .region | tr -d \")
18                     ;;
19             esac
20         fi
21         if test -z "$availability_zone" -o -z "$region"; then
22             if test -n "${TASKCLUSTER_WORKER_GROUP}"; then
23                 # TASKCLUSTER_WORKER_GROUP is just the region now, so
24                 # stick an extra character on to make the already-convoluted logic
25                 # here simpler.
26                 availability_zone="${TASKCLUSTER_WORKER_GROUP}x"
27             elif [ -n "${SCCACHE_GCS_KEY_PATH}" ]; then
28                 # gcp availability_zone is of the form <region>-<letter> where region is e.g. us-west2, and az is us-west2-a
29                 gcp_zone=$(wget -T 1 -t 1 -q -O - http://169.254.169.254/computeMetadata/v1beta1/instance/zone || true)
30                 availability_zone=${gcp_zone##*/}
31             else
32                 # timeout after 1 second, and don't retry (failure indicates instance is not in ec2 or network issue)
33                 # ec2 availability_zone is of the form <region><letter> where region is e.g. us-west-2, and az is us-west-2a
34                 availability_zone=$(wget -T 1 -t 1 -q -O - http://169.254.169.254/latest/meta-data/placement/availability-zone || true)
35             fi
36         fi
37         if test -z "$availability_zone" -o "$availability_zone" = "not-ec2"; then
38             availability_zone=not-ec2
39         elif test -n "$cloud"; then
40             case $cloud in
41             google)
42                 bucket=sccache-l${MOZ_SCM_LEVEL}-${region}
43                 ;;
44             aws)
45                 bucket=taskcluster-level-${MOZ_SCM_LEVEL}-sccache-${region}
46                 ;;
47             esac
48         elif [ -n "${SCCACHE_GCS_KEY_PATH}" ]; then
49             # gcp region is az with last two letters trimmed
50             if test -z "$region"; then
51                 region=${availability_zone::${#availability_zone}-2}
52             fi
53             bucket=taskcluster-level-${MOZ_SCM_LEVEL}-sccache-${region}
54         else
55             # ec2 region is az with last letter trimmed
56             if test -z "$region"; then
57                 region=${availability_zone%?}
58             fi
59             bucket=taskcluster-level-${MOZ_SCM_LEVEL}-sccache-${region}
60         fi
61     fi
64 if test -n "$bucket"; then
65     if test "$cloud" = "google"; then
66         mk_add_options "export SCCACHE_GCS_BUCKET=$bucket"
67         mk_add_options "export SCCACHE_GCS_RW_MODE=READ_WRITE"
68         mk_add_options "export SCCACHE_GCS_CREDENTIALS_URL=http://taskcluster/auth/v1/gcp/credentials/$SCCACHE_GCS_PROJECT/sccache-l${MOZ_SCM_LEVEL}-${region}@$SCCACHE_GCS_PROJECT.iam.gserviceaccount.com"
69     elif [ -n "${SCCACHE_GCS_KEY_PATH}" ]; then
70         mk_add_options "export SCCACHE_GCS_BUCKET=$bucket"
71     else
72         mk_add_options "export SCCACHE_BUCKET=$bucket"
73         # instruct sccache to fetch the credentials from the Auth service's awsS3Credentials endpoint, via the Taskcluster proxy.
74         mk_add_options "export AWS_IAM_CREDENTIALS_URL=http://taskcluster/auth/v1/aws/s3/read-write/${bucket}/?format=iam-role-compat"
75     fi
76     export CCACHE="$MOZ_FETCHES_DIR/sccache/sccache"
77     export SCCACHE_VERBOSE_STATS=1
78     mk_add_options MOZBUILD_MANAGE_SCCACHE_DAEMON=${MOZ_FETCHES_DIR}/sccache/sccache