diff --git a/dev/ci/setup-sccache b/dev/ci/setup-sccache index 5886173a43..70a466cc10 100755 --- a/dev/ci/setup-sccache +++ b/dev/ci/setup-sccache @@ -43,6 +43,24 @@ for PROG in cc c++; do done +## Update environment variables. + +HAS_SCCACHE_IN_PATH=$(ruby -e 'puts ENV["PATH"].split(":").include?("/usr/local/bin")') +if !$HAS_SCCACHE_IN_PATH; then + echo "PATH=/usr/local/bin:$PATH" >> "$GITHUB_ENV" +fi + +HAS_COMPILER_WRAPPERS_IN_PATH=$(ruby -e 'puts ENV["PATH"].split(":").include?("/usr/local/libexec/sccache")') +if ! $HAS_COMPILER_WRAPPERS_IN_PATH; then + echo "PATH=/usr/local/libexec/sccache:/usr/local/bin:$PATH" >> "$GITHUB_ENV" +else + # When starting the sccache server, the compiler wrappers must *not* be in PATH + # so that the sccache server uses the non-wrapped compilers. + PATH=$(ruby -e 'paths = ENV["PATH"].split(":"); paths.delete("/usr/local/libexec/sccache"); puts paths.join(":")') + export PATH +fi + + ## Start sccache server. ## Uncomment this to have the sccache server write debug logs to sccache.log. @@ -58,5 +76,8 @@ else env SCCACHE_START_SERVER=1 sccache fi -# Give sccache server some time to start. -sleep 0.5 +echo "Waiting until sccache server is started..." +while [[ -z "$(cat sccache.log)" ]]; then + sleep 0.1 +fi +echo "sccache server is started."