Skip to content

Commit

Permalink
Add local read/write variables, adjust comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottTodd committed Jan 20, 2023
1 parent 317a7bc commit 5352020
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ jobs:
steps:
- name: "Checking out repository"
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
# Restore caches.
# Restore caches unconditionally. Cache misses are okay.
- name: "Fetching cache (git submodules)"
uses: actions/cache/restore@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3.2.3
with:
Expand All @@ -184,7 +184,8 @@ jobs:
path: ${{ github.workspace }}/.ccache
key: ccache_all_windows_${{ github.sha }}
restore-keys: ccache_all_windows
# Fetch deps.
# Fetch dependencies.
# TODO(scotttodd): Move these into a Docker image.
- name: "Updating git submodules"
run: git submodule update --init --jobs 8 --depth 1
- name: "Setting up Python"
Expand All @@ -203,8 +204,10 @@ jobs:
# Finally: build and run tests.
- name: "Building IREE"
env:
IREE_USE_LOCAL_CCACHE: 1
IREE_READ_REMOTE_CCACHE: 0
IREE_WRITE_REMOTE_CCACHE: 0
IREE_READ_LOCAL_CCACHE: 1
IREE_WRITE_LOCAL_CCACHE: ${{ needs.setup.outputs.write-caches }}
CCACHE_DIR: ${{ github.workspace }}/.ccache
run: ./build_tools/cmake/build_all.sh "${BUILD_DIR}"
- name: "Testing IREE"
Expand Down
24 changes: 16 additions & 8 deletions build_tools/cmake/setup_ccache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# Local caches can also be used to interface with external remote caches
# (like https://github.com/actions/cache) by
# 1. downloading the cache directory
# 2. sourcing this file with IREE_USE_LOCAL_CCACHE=1 IREE_READ_REMOTE_CCACHE=0
# 2. sourcing with IREE_READ_LOCAL_CCACHE=1 IREE_WRITE_LOCAL_CCACHE=[0,1]
# 3. building with CMake
# 4. uploading the cache directory (optionally)
# 4. uploading the cache directory (if writing)
#
# Note: this file must be *sourced* not executed.

Expand All @@ -24,18 +24,19 @@ set -euo pipefail
# Configuration environment variables.
IREE_READ_REMOTE_CCACHE="${IREE_READ_REMOTE_CCACHE:-1}"
IREE_WRITE_REMOTE_CCACHE="${IREE_WRITE_REMOTE_CCACHE:-0}"
IREE_USE_LOCAL_CCACHE="${IREE_USE_LOCAL_CCACHE:-0}"
IREE_READ_LOCAL_CCACHE="${IREE_READ_LOCAL_CCACHE:-0}"
IREE_WRITE_LOCAL_CCACHE="${IREE_WRITE_LOCAL_CCACHE:-0}"

if (( ${IREE_WRITE_REMOTE_CCACHE} == 1 && ${IREE_READ_REMOTE_CCACHE} != 1 )); then
echo "Can't have 'IREE_WRITE_REMOTE_CCACHE' (${IREE_WRITE_REMOTE_CCACHE})" \
" set without 'IREE_READ_REMOTE_CCACHE' (${IREE_READ_REMOTE_CCACHE})"
fi
if (( ${IREE_USE_LOCAL_CCACHE} == 1 && ${IREE_READ_REMOTE_CCACHE} == 1)); then
echo "Can't have 'IREE_USE_LOCAL_CCACHE' (${IREE_USE_LOCAL_CCACHE})" \
" set with 'IREE_READ_REMOTE_CCACHE' (${IREE_READ_REMOTE_CCACHE})"
if (( ${IREE_WRITE_LOCAL_CCACHE} == 1 && ${IREE_READ_LOCAL_CCACHE} != 1 )); then
echo "Can't have 'IREE_WRITE_LOCAL_CCACHE' (${IREE_WRITE_LOCAL_CCACHE})" \
" set without 'IREE_READ_LOCAL_CCACHE' (${IREE_READ_LOCAL_CCACHE})"
fi

if (( IREE_READ_REMOTE_CCACHE == 1 || IREE_USE_LOCAL_CCACHE == 1 )); then
if (( IREE_READ_REMOTE_CCACHE == 1 || IREE_READ_LOCAL_CCACHE == 1 )); then
export IREE_USE_CCACHE=1
export CMAKE_C_COMPILER_LAUNCHER=$(which ccache)
export CMAKE_CXX_COMPILER_LAUNCHER=$(which ccache)
Expand All @@ -44,9 +45,16 @@ else
export IREE_USE_CCACHE=0
fi

if (( IREE_READ_LOCAL_CCACHE == 1 && IREE_WRITE_LOCAL_CCACHE == 0 )); then
export CCACHE_READONLY=1
fi

if (( IREE_READ_REMOTE_CCACHE == 1 && IREE_READ_LOCAL_CCACHE == 0 )); then
export CCACHE_REMOTE_ONLY=1
fi

if (( IREE_READ_REMOTE_CCACHE == 1 )); then
export CCACHE_REMOTE_STORAGE="http://storage.googleapis.com/iree-sccache/ccache"
export CCACHE_REMOTE_ONLY=1
if (( IREE_WRITE_REMOTE_CCACHE == 1 )); then
set +x # Don't leak the token (even though it's short-lived)
export CCACHE_REMOTE_STORAGE="${CCACHE_REMOTE_STORAGE}|bearer-token=${IREE_CCACHE_GCP_TOKEN}"
Expand Down

0 comments on commit 5352020

Please sign in to comment.