mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-22 23:17:15 +03:00
64914fbc98
* Reducing the parameter surface area for good measure, zstd compression works pretty well and it seems redundant to support multiple ways of copying the target directory around
25 lines
888 B
Bash
25 lines
888 B
Bash
inheritCargoArtifacts() {
|
|
echo cargoArtifacts is ${cargoArtifacts}
|
|
|
|
local cargoTarget="${CARGO_TARGET_DIR:-target}"
|
|
mkdir -p "${cargoTarget}"
|
|
|
|
if [ -f "${cargoArtifacts}/target.tar.zst" ]; then
|
|
@zstd@ -d "${cargoArtifacts}/target.tar.zst" --stdout | \
|
|
tar -x -C "${cargoTarget}" --strip-components=1
|
|
else
|
|
echo "${cargoArtifacts} looks invalid, are you sure it is pointing to a ".target" output?"
|
|
false
|
|
fi
|
|
}
|
|
|
|
if [ -n "${cargoArtifacts-}" ]; then
|
|
# NB: inherit cargo artifacts after patching is done, that way target directory
|
|
# is fresher than the source and avoid invalidating the cache
|
|
# Doing this as early as possible also gives us the advantage that any other
|
|
# preBuild hooks (e.g. clippy) can also take advantage of the cache
|
|
postPatchHooks+=(inheritCargoArtifacts)
|
|
else
|
|
echo "cargoArtifacts not set, will not reuse any cargo artifacts"
|
|
fi
|