ci: extract installing sccache into a script

This commit is contained in:
Pietro Albini 2019-10-04 18:42:53 +02:00
parent c1fb42add5
commit a36077235e
No known key found for this signature in database
GPG Key ID: 3E06ABE80BAAF19C
4 changed files with 46 additions and 22 deletions

View File

@ -1,21 +0,0 @@
steps:
- bash: |
set -e
curl -fo /usr/local/bin/sccache https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2018-04-02-sccache-x86_64-apple-darwin
chmod +x /usr/local/bin/sccache
displayName: Install sccache (OSX)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))
- script: |
md sccache
powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf sccache\sccache.exe https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2018-04-26-sccache-x86_64-pc-windows-msvc"
echo ##vso[task.prependpath]%CD%\sccache
displayName: Install sccache (Windows)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
# Note that we don't install sccache on Linux since it's installed elsewhere
# through all the containers.
#
# FIXME: we should probably install sccache outside the containers and then
# mount it inside the containers so we can centralize all installation here.

View File

@ -51,7 +51,12 @@ steps:
- bash: src/ci/scripts/dump-environment.sh
displayName: Show the current environment
- template: install-sccache.yml
- bash: src/ci/scripts/install-sccache.sh
env:
AGENT_OS: $(Agent.OS)
displayName: Install sccache
condition: and(succeeded(), not(variables.SKIP_JOB))
- template: install-clang.yml
# Switch to XCode 9.3 on OSX since it seems to be the last version that supports

View File

@ -0,0 +1,20 @@
#!/bin/bash
# This script installs sccache on the local machine. Note that we don't install
# sccache on Linux since it's installed elsewhere through all the containers.
set -euo pipefail
IFS=$'\n\t'
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
if isMacOS; then
curl -fo /usr/local/bin/sccache "${MIRRORS_BASE}/2018-04-02-sccache-x86_64-apple-darwin"
chmod +x /usr/local/bin/sccache
elif isWindows; then
mkdir -p sccache
curl -fo sccache/sccache.exe "${MIRRORS_BASE}/2018-04-26-sccache-x86_64-pc-windows-msvc"
ciCommandAddPath "$(pwd)/sccache"
fi
# FIXME: we should probably install sccache outside the containers and then
# mount it inside the containers so we can centralize all installation here.

View File

@ -4,6 +4,8 @@
# `source shared.sh`, hence the invalid shebang and not being
# marked as an executable file in git.
export MIRRORS_BASE="https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc"
# See http://unix.stackexchange.com/questions/82598
# Duplicated in docker/dist-various-2/shared.sh
function retry {
@ -32,6 +34,24 @@ function isOSX {
[ "$AGENT_OS" = "Darwin" ]
}
function isMacOS {
isOSX
}
function isWindows {
[ "$AGENT_OS" = "Windows_NT" ]
}
function getCIBranch {
echo "$BUILD_SOURCEBRANCHNAME"
}
function ciCommandAddPath {
if [[ $# -ne 1 ]]; then
echo "usage: $0 <path>"
exit 1
fi
path="$1"
echo "##vso[task.prependpath]${path}"
}