Skip to content

Commit 8815639

Browse files
committed
support installing sccache from a custom github repository
1 parent 1ff4bb6 commit 8815639

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

features/src/sccache/.bashrc

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
export RUSTC_WRAPPER=${RUSTC_WRAPPER:-/usr/bin/sccache};
2-
export CMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER:-/usr/bin/sccache};
3-
export CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER:-/usr/bin/sccache};
4-
export CMAKE_CUDA_COMPILER_LAUNCHER=${CMAKE_CUDA_COMPILER_LAUNCHER:-/usr/bin/sccache};
1+
if test -z "${DISABLE_SCCACHE+x}"; then
2+
# Log sccache server messages
3+
export SCCACHE_ERROR_LOG="${SCCACHE_ERROR_LOG:-/var/log/devcontainer-utils/sccache.log}";
4+
export SCCACHE_SERVER_LOG="${SCCACHE_SERVER_LOG:-sccache=info}";
5+
6+
# Use sccache for Rust, C, C++, and CUDA compilations
7+
if ! test -v RUSTC_WRAPPER; then
8+
export RUSTC_WRAPPER="${RUSTC_WRAPPER:-/usr/bin/sccache}";
9+
fi
10+
if ! test -v CMAKE_C_COMPILER_LAUNCHER; then
11+
export CMAKE_C_COMPILER_LAUNCHER="${CMAKE_C_COMPILER_LAUNCHER:-/usr/bin/sccache}";
12+
fi
13+
if ! test -v CMAKE_CXX_COMPILER_LAUNCHER; then
14+
export CMAKE_CXX_COMPILER_LAUNCHER="${CMAKE_CXX_COMPILER_LAUNCHER:-/usr/bin/sccache}";
15+
fi
16+
if ! test -v CMAKE_CUDA_COMPILER_LAUNCHER; then
17+
export CMAKE_CUDA_COMPILER_LAUNCHER="${CMAKE_CUDA_COMPILER_LAUNCHER:-/usr/bin/sccache}";
18+
fi
19+
fi

features/src/sccache/devcontainer-feature.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
{
22
"name": "sccache",
33
"id": "sccache",
4-
"version": "25.4.0",
4+
"version": "25.4.1",
55
"description": "A feature to install sccache",
66
"options": {
7+
"repository": {
8+
"type": "string",
9+
"proposals": [
10+
"mozilla/sccache"
11+
],
12+
"default": "mozilla/sccache",
13+
"description": "The GitHub repository from which to install the sccache binary."
14+
},
715
"version": {
816
"type": "string",
917
"proposals": [

features/src/sccache/install.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -e
33

44
SCCACHE_VERSION="${VERSION:-latest}";
5+
SCCACHE_REPOSITORY="${REPOSITORY:-"mozilla/sccache"}";
56

67
# Ensure we're in this feature's directory during build
78
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
@@ -13,14 +14,18 @@ check_packages jq wget ca-certificates bash-completion;
1314

1415
echo "Installing sccache...";
1516

16-
if [ $SCCACHE_VERSION == latest ]; then
17-
find_version_from_git_tags SCCACHE_VERSION https://github.com/mozilla/sccache;
17+
if test "$SCCACHE_VERSION" = latest; then
18+
find_version_from_git_tags SCCACHE_VERSION "https://github.com/$SCCACHE_REPOSITORY";
1819
fi
1920

2021
# Install sccache
21-
wget --no-hsts -q -O- "https://github.com/mozilla/sccache/releases/download/v$SCCACHE_VERSION/sccache-v$SCCACHE_VERSION-$(uname -p)-unknown-linux-musl.tar.gz" \
22-
| tar -C /usr/bin -zf - --wildcards --strip-components=1 -x */sccache \
23-
&& chmod +x /usr/bin/sccache;
22+
wget --no-hsts -q -O- \
23+
"https://github.com/$SCCACHE_REPOSITORY/releases/download/v$SCCACHE_VERSION/sccache-v$SCCACHE_VERSION-$(uname -m)-unknown-linux-musl.tar.gz" \
24+
| tar -C /usr/bin -zf - --wildcards --strip-components=1 -x '*/sccache';
25+
26+
mkdir -m 0777 -p /var/log/devcontainer-utils;
27+
touch /var/log/devcontainer-utils/sccache.log;
28+
chmod 0777 /var/log/devcontainer-utils/sccache.log;
2429

2530
# export envvars in /etc/bash.bashrc
2631
append_to_etc_bashrc "$(cat .bashrc)";

0 commit comments

Comments
 (0)