about summary refs log tree commit diff
path: root/src/ci
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2019-10-04 18:42:53 +0200
committerPietro Albini <pietro@pietroalbini.org>2019-10-25 16:03:06 +0200
commita36077235e800cd2d46aa70151de8c7eac0ced5b (patch)
tree83beac30e82940a99032e0314c6b84ceadcff243 /src/ci
parentc1fb42add5a7859b1b8e258d3c03fd5a29129c40 (diff)
downloadrust-a36077235e800cd2d46aa70151de8c7eac0ced5b.tar.gz
rust-a36077235e800cd2d46aa70151de8c7eac0ced5b.zip
ci: extract installing sccache into a script
Diffstat (limited to 'src/ci')
-rw-r--r--src/ci/azure-pipelines/steps/install-sccache.yml21
-rw-r--r--src/ci/azure-pipelines/steps/run.yml7
-rwxr-xr-xsrc/ci/scripts/install-sccache.sh20
-rw-r--r--src/ci/shared.sh20
4 files changed, 46 insertions, 22 deletions
diff --git a/src/ci/azure-pipelines/steps/install-sccache.yml b/src/ci/azure-pipelines/steps/install-sccache.yml
deleted file mode 100644
index d4679c1c673..00000000000
--- a/src/ci/azure-pipelines/steps/install-sccache.yml
+++ /dev/null
@@ -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.
diff --git a/src/ci/azure-pipelines/steps/run.yml b/src/ci/azure-pipelines/steps/run.yml
index 86399e5828f..66405f2d2bf 100644
--- a/src/ci/azure-pipelines/steps/run.yml
+++ b/src/ci/azure-pipelines/steps/run.yml
@@ -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
diff --git a/src/ci/scripts/install-sccache.sh b/src/ci/scripts/install-sccache.sh
new file mode 100755
index 00000000000..d3c29899225
--- /dev/null
+++ b/src/ci/scripts/install-sccache.sh
@@ -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.
diff --git a/src/ci/shared.sh b/src/ci/shared.sh
index b093a07ec5c..49fe3841ceb 100644
--- a/src/ci/shared.sh
+++ b/src/ci/shared.sh
@@ -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}"
+}