Skip to content

Commit 82b5d19

Browse files
authored
Merge pull request #121 from TheBlueMatt/main
Fix cargo cache wiping for new registry and for empty caches
2 parents 46fda3f + 85205a4 commit 82b5d19

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

genbindings.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,18 +374,24 @@ function REALLY_PIN_CC {
374374
# -Zbuild-std fails if we have any dependencies of build-deps, which
375375
# cc added in 1.0.80, thus we pin back to 1.0.79 to avoid that.
376376
cargo update -p cc --precise "1.0.79" --verbose
377-
( cargo build --features=std -v --release -Zbuild-std=std,panic_abort > /dev/null 2>&1 ) || echo -n
378-
( cargo build --features=std -v --release --target aarch64-apple-darwin -Zbuild-std=std,panic_abort > /dev/null 2>&1 ) || echo -n
377+
( RUSTC_BOOTSTRAP=1 cargo build --features=std -v --release --target x86_64-apple-darwin -Zbuild-std=std,panic_abort > /dev/null 2>&1 ) || echo -n
378+
( RUSTC_BOOTSTRAP=1 cargo build --features=std -v --release --target aarch64-apple-darwin -Zbuild-std=std,panic_abort > /dev/null 2>&1 ) || echo -n
379379
# Sadly, std also depends on cc, and we can't pin it in that tree
380380
# directly. Instead, we have to delete the file out of the cargo
381381
# registry and build --offline to avoid it using the latest version.
382382
NEW_CC_DEP="$CARGO_HOME"
383383
[ "$NEW_CC_DEP" = "" ] && NEW_CC_DEP="$HOME"
384-
if [ -f "$NEW_CC_DEP/.cargo/registry/cache/github.com-"*/cc-1.0.79.crate ]; then
385-
mv "$NEW_CC_DEP/.cargo/registry/cache/github.com-"*/cc-1.0.79.crate ./
384+
[ -d "$NEW_CC_DEP/.cargo/registry/cache/"github.com-* ] && CARGO_REGISTRY_CACHE="$NEW_CC_DEP/.cargo/registry/cache/"github.com-*
385+
[ -d "$NEW_CC_DEP/.cargo/registry/cache/"index.crates.io-* ] && CARGO_REGISTRY_CACHE="$NEW_CC_DEP/.cargo/registry/cache/"index.crates.io-*
386+
if [ -d "$CARGO_REGISTRY_CACHE" ]; then
387+
if [ -f "$CARGO_REGISTRY_CACHE/cc-1.0.79.crate" ]; then
388+
mv "$CARGO_REGISTRY_CACHE/cc-1.0.79.crate" ./
389+
fi
390+
rm -f "$CARGO_REGISTRY_CACHE/"*/cc-*.crate
391+
[ -f ./cc-1.0.79.crate ] && mv ./cc-1.0.79.crate "$CARGO_REGISTRY_CACHE/"
392+
else
393+
echo "Couldn't find cargo cache, build-std builds are likely to fail!"
386394
fi
387-
rm -f "$NEW_CC_DEP/.cargo/registry/cache/github.com-"*/cc-*.crate
388-
[ -f ./cc-1.0.79.crate ] && mv ./cc-1.0.79.crate "$NEW_CC_DEP/.cargo/registry/cache/github.com-"*/
389395
}
390396

391397
# Then, check with memory sanitizer, if we're on Linux and have rustc nightly

0 commit comments

Comments
 (0)