mozconfig.cache (4850B)
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/. 4 5 # Setup for build cache 6 7 # Thunderbird builds will set prior to including this file 8 aws_prefix=${aws_prefix:-taskcluster} 9 gcp_prefix=${gcp_prefix:-sccache} 10 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 14 fi 15 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 18 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 # deal with length limit on serviceaccount names (https://bugzilla.mozilla.org/show_bug.cgi?id=1882374#c5) 53 serviceaccount=$(echo $bucket | sed s/northamerica/na/) 54 ;; 55 aws) 56 bucket=${aws_prefix}-level-${MOZ_SCM_LEVEL}-sccache-${region} 57 ;; 58 esac 59 elif [ -n "${SCCACHE_GCS_KEY_PATH}" ]; then 60 # gcp region is az with last two letters trimmed 61 if test -z "$region"; then 62 region=${availability_zone::${#availability_zone}-2} 63 fi 64 bucket=${aws_prefix}-level-${MOZ_SCM_LEVEL}-sccache-${region} 65 else 66 # ec2 region is az with last letter trimmed 67 if test -z "$region"; then 68 region=${availability_zone%?} 69 fi 70 bucket=${aws_prefix}-level-${MOZ_SCM_LEVEL}-sccache-${region} 71 fi 72 fi 73 fi 74 75 if test -n "$bucket"; then 76 if test "$cloud" = "google"; then 77 mk_add_options "export SCCACHE_GCS_BUCKET=$bucket" 78 mk_add_options "export SCCACHE_GCS_RW_MODE=READ_WRITE" 79 mk_add_options "export SCCACHE_GCS_CREDENTIALS_URL=http://taskcluster/auth/v1/gcp/credentials/$SCCACHE_GCS_PROJECT/${serviceaccount}@$SCCACHE_GCS_PROJECT.iam.gserviceaccount.com" 80 elif [ -n "${SCCACHE_GCS_KEY_PATH}" ]; then 81 mk_add_options "export SCCACHE_GCS_BUCKET=$bucket" 82 else 83 mk_add_options "export SCCACHE_BUCKET=$bucket" 84 # instruct sccache to fetch the credentials from the Auth service's awsS3Credentials endpoint, via the Taskcluster proxy. 85 mk_add_options "export AWS_IAM_CREDENTIALS_URL=http://taskcluster/auth/v1/aws/s3/read-write/${bucket}/?format=iam-role-compat" 86 fi 87 export CCACHE="sccache" 88 export SCCACHE_VERBOSE_STATS=1 89 # Workaround for https://github.com/mozilla/sccache/issues/459#issuecomment-618756635 90 mk_add_options "export SCCACHE_MAX_FRAME_LENGTH=50000000" 91 mk_add_options MOZBUILD_MANAGE_SCCACHE_DAEMON=${MOZ_FETCHES_DIR}/sccache/sccache 92 elif test -n "$USE_SCCACHE"; then 93 echo "SetupError: sccache is enabled but there is no shared storage set up for it?" >&2 94 exit 1 95 fi