diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index 9193748bba..411bb6c121 100644 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -12,7 +12,8 @@ export PS4="++" # Restore target/ from the previous CI build on this machine # eval "$(ci/channel-info.sh)" -export CARGO_TARGET_CACHE=$HOME/cargo-target-cache/"$CHANNEL"-"$BUILDKITE_LABEL" +eval "$(ci/sbf-tools-info.sh)" +export CARGO_TARGET_CACHE=$HOME/cargo-target-cache/"$CHANNEL"-"$BUILDKITE_LABEL"-"$SBF_TOOLS_VERSION" ( set -x MAX_CACHE_SIZE=18 # gigabytes diff --git a/ci/sbf-tools-info.sh b/ci/sbf-tools-info.sh new file mode 100755 index 0000000000..04e389b0f6 --- /dev/null +++ b/ci/sbf-tools-info.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# +# Finds the version of sbf-tools used by this source tree. +# +# stdout of this script may be eval-ed. +# + +here="$(dirname "$0")" + +SBF_TOOLS_VERSION=unknown + +cargo_build_bpf_main="${here}/../sdk/cargo-build-bpf/src/main.rs" +if [[ -f "${cargo_build_bpf_main}" ]]; then + version=$(sed -e 's/^.*bpf_tools_version\s*=\s*"\(v[0-9.]\+\)".*/\1/;t;d' "${cargo_build_bpf_main}") + if [[ ${version} != '' ]]; then + SBF_TOOLS_VERSION="${version}" + else + echo '--- unable to parse SBF_TOOLS_VERSION' + fi +else + echo "--- '${cargo_build_bpf_main}' not present" +fi + +echo SBF_TOOLS_VERSION="${SBF_TOOLS_VERSION}" diff --git a/sdk/cargo-build-bpf/src/main.rs b/sdk/cargo-build-bpf/src/main.rs index ee840acb75..2a97c1fb04 100644 --- a/sdk/cargo-build-bpf/src/main.rs +++ b/sdk/cargo-build-bpf/src/main.rs @@ -476,17 +476,20 @@ fn build_bpf_package(config: &Config, target_directory: &Path, package: &cargo_m eprintln!("Can't get home directory path: {}", err); exit(1); })); - let version = "v1.23"; + + // The following line is scanned by CI configuration script to + // separate cargo caches according to the version of sbf-tools. + let bpf_tools_version = "v1.23"; let package = "bpf-tools"; let target_path = home_dir .join(".cache") .join("solana") - .join(version) + .join(bpf_tools_version) .join(package); install_if_missing( config, package, - version, + bpf_tools_version, "https://github.com/solana-labs/bpf-tools/releases/download", bpf_tools_download_file_name, &target_path,