Skip to content

Commit

Permalink
ci/circle: fix ccache cache, take 2
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit-pierre committed Nov 27, 2024
1 parent 538f024 commit 11594ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 13 additions & 10 deletions .ci/build_script.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
#!/usr/bin/env bash

CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DOCKER_HOME=/home/ko
# shellcheck source=/dev/null
source "${CI_DIR}/common.sh"

if [[ -z "${CCACHE_DIR}" ]]; then
CCACHE_DIR="${HOME}/.ccache"
fi

mkdir -p "${CCACHE_DIR}"
echo "using cache dir: ${CCACHE_DIR}"

docker-make() {
local cmdlist=(
'source /home/ko/.bashrc'
'cd /home/ko/base'
'sudo chown -R ko:ko .'
"env MAKEFLAGS='${MAKEFLAGS}' make $(printf '%q ' "$@")"
)
if [[ -z "${CCACHE_DIR}" ]]; then
CCACHE_DIR="$(ccache --get-config cache_dir)"
fi
mkdir -p "${CCACHE_DIR}"
sudo chmod -R 777 "${CCACHE_DIR}"
DOCKER_HOME=/home/ko
DOCKER_CCACHE_DIR="${DOCKER_HOME}/.cache/ccache"
echo "using host cache dir: ${CCACHE_DIR}"
echo "using docker cache dir: ${DOCKER_CCACHE_DIR}"
docker run --rm -t \
-v "${CCACHE_DIR}:${DOCKER_HOME}/.ccache" \
-v "$(pwd):${DOCKER_HOME}/base" "${DOCKER_IMG}" \
-e CCACHE_DIR="${DOCKER_CCACHE_DIR}" \
-v "${CCACHE_DIR}:${DOCKER_CCACHE_DIR}" \
-v "${PWD}:${DOCKER_HOME}/base" "${DOCKER_IMG}" \
/bin/bash -c "$(printf '%s && ' "${cmdlist[@]}")true"
}

Expand All @@ -31,3 +32,5 @@ if [[ -z "${DOCKER_IMG}" ]]; then
else
docker-make TARGET="${TARGET}" VERBOSE=1 "$@"
fi

# vim: sw=4
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ parameters:
# Bump this to reset all caches.
cache_epoch:
type: integer
default: 3
default: 4

# }}}

Expand Down

0 comments on commit 11594ee

Please sign in to comment.