Skip to content

Commit 2041aa1

Browse files
committed
Use stub in docker
1 parent e97df94 commit 2041aa1

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

.ci/docker/common/install_cache.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,26 @@ init_sccache() {
8989
as_ci_user sccache --zero-stats || true
9090
}
9191

92+
function write_android_sccache_stub() {
93+
BINARY=$1
94+
mv "/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/$1" "/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/.$1"
95+
cat >"/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/$1" <<EOF
96+
#!/bin/sh
97+
if [ \$(env -u LD_PRELOAD ps -p \$PPID -o comm=) != sccache ]; then
98+
exec sccache /opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/.$1 "\$@"
99+
else
100+
exec /opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/.$1 "\$@"
101+
fi
102+
EOF
103+
chmod a+x "/opt/toolchains/llvm/prebuilt/linux-x86_64/bin/${BINARY}"
104+
}
105+
92106
write_sccache_stub cc
93107
write_sccache_stub c++
94108
write_sccache_stub gcc
95109
write_sccache_stub g++
96110
write_sccache_stub clang
97111
write_sccache_stub clang++
112+
write_android_sccache_stub clang
113+
write_android_sccache_stub clang++
98114
init_sccache

.ci/docker/ubuntu/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ COPY ./common/install_conda.sh install_conda.sh
5454
COPY ./common/utils.sh utils.sh
5555
RUN bash ./install_conda.sh && rm install_conda.sh utils.sh /opt/conda/requirements-ci.txt /opt/conda/conda-env-ci.txt
5656

57+
ARG ANDROID_NDK_VERSION
58+
# Install Android NDK if needed
59+
COPY ./common/install_android.sh install_android.sh
60+
RUN if [ -n "${ANDROID_NDK_VERSION}" ]; then bash ./install_android.sh; fi
61+
RUN rm install_android.sh
62+
5763
# Install sccache before building torch
5864
COPY ./common/install_cache.sh install_cache.sh
5965
ENV PATH /opt/cache/bin:$PATH
@@ -76,12 +82,6 @@ COPY ./requirements-lintrunner.txt requirements-lintrunner.txt
7682
RUN if [ -n "${LINTRUNNER}" ]; then bash ./install_linter.sh; fi
7783
RUN rm install_linter.sh utils.sh requirements-lintrunner.txt
7884

79-
ARG ANDROID_NDK_VERSION
80-
# Install lintrunner if needed
81-
COPY ./common/install_android.sh install_android.sh
82-
RUN if [ -n "${ANDROID_NDK_VERSION}" ]; then bash ./install_android.sh; fi
83-
RUN rm install_android.sh
84-
8585
ARG ARM_SDK
8686

8787
ARG QNN_SDK

.github/workflows/_android.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ jobs:
2222
script: |
2323
set -eux
2424
25-
# Use sccache for NDK compiler as well
26-
export CMAKE_CXX_COMPILER_LAUNCHER=sccache
27-
export CMAKE_C_COMPILER_LAUNCHER=sccache
28-
2925
# The generic Linux job chooses to use base env, not the one setup by the image
3026
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
3127
conda activate "${CONDA_ENV}"

.github/workflows/android-perf.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,6 @@ jobs:
353353
script: |
354354
set -eux
355355
356-
# Use sccache for NDK compiler as well
357-
export CMAKE_CXX_COMPILER_LAUNCHER=sccache
358-
export CMAKE_C_COMPILER_LAUNCHER=sccache
359-
360356
# The generic Linux job chooses to use base env, not the one setup by the image
361357
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
362358
conda activate "${CONDA_ENV}"

.github/workflows/android-release-artifacts.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ jobs:
5959
script: |
6060
set -eux
6161
62-
# Use sccache for NDK compiler as well
63-
export CMAKE_CXX_COMPILER_LAUNCHER=sccache
64-
export CMAKE_C_COMPILER_LAUNCHER=sccache
65-
6662
# The generic Linux job chooses to use base env, not the one setup by the image
6763
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
6864
conda activate "${CONDA_ENV}"

0 commit comments

Comments
 (0)