Skip to content

Commit a360772

Browse files
committed
ci: extract installing sccache into a script
1 parent c1fb42a commit a360772

File tree

4 files changed

+46
-22
lines changed

4 files changed

+46
-22
lines changed

src/ci/azure-pipelines/steps/install-sccache.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/ci/azure-pipelines/steps/run.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ steps:
5151
- bash: src/ci/scripts/dump-environment.sh
5252
displayName: Show the current environment
5353

54-
- template: install-sccache.yml
54+
- bash: src/ci/scripts/install-sccache.sh
55+
env:
56+
AGENT_OS: $(Agent.OS)
57+
displayName: Install sccache
58+
condition: and(succeeded(), not(variables.SKIP_JOB))
59+
5560
- template: install-clang.yml
5661

5762
# Switch to XCode 9.3 on OSX since it seems to be the last version that supports

src/ci/scripts/install-sccache.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
# This script installs sccache on the local machine. Note that we don't install
3+
# sccache on Linux since it's installed elsewhere through all the containers.
4+
5+
set -euo pipefail
6+
IFS=$'\n\t'
7+
8+
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
9+
10+
if isMacOS; then
11+
curl -fo /usr/local/bin/sccache "${MIRRORS_BASE}/2018-04-02-sccache-x86_64-apple-darwin"
12+
chmod +x /usr/local/bin/sccache
13+
elif isWindows; then
14+
mkdir -p sccache
15+
curl -fo sccache/sccache.exe "${MIRRORS_BASE}/2018-04-26-sccache-x86_64-pc-windows-msvc"
16+
ciCommandAddPath "$(pwd)/sccache"
17+
fi
18+
19+
# FIXME: we should probably install sccache outside the containers and then
20+
# mount it inside the containers so we can centralize all installation here.

src/ci/shared.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# `source shared.sh`, hence the invalid shebang and not being
55
# marked as an executable file in git.
66

7+
export MIRRORS_BASE="https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc"
8+
79
# See http://unix.stackexchange.com/questions/82598
810
# Duplicated in docker/dist-various-2/shared.sh
911
function retry {
@@ -32,6 +34,24 @@ function isOSX {
3234
[ "$AGENT_OS" = "Darwin" ]
3335
}
3436

37+
function isMacOS {
38+
isOSX
39+
}
40+
41+
function isWindows {
42+
[ "$AGENT_OS" = "Windows_NT" ]
43+
}
44+
3545
function getCIBranch {
3646
echo "$BUILD_SOURCEBRANCHNAME"
3747
}
48+
49+
function ciCommandAddPath {
50+
if [[ $# -ne 1 ]]; then
51+
echo "usage: $0 <path>"
52+
exit 1
53+
fi
54+
path="$1"
55+
56+
echo "##vso[task.prependpath]${path}"
57+
}

0 commit comments

Comments
 (0)