]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Fix cargo cache wiping for new registry and for empty caches
authorMatt Corallo <git@bluematt.me>
Fri, 1 Mar 2024 19:25:59 +0000 (19:25 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 5 Mar 2024 16:41:28 +0000 (16:41 +0000)
genbindings.sh

index b7ae3717c1008dcab9e2118f041c3b572b4f2dc4..ca336caa8f674cefec966ff7f305b47851c4053a 100755 (executable)
@@ -374,18 +374,24 @@ function REALLY_PIN_CC {
        # -Zbuild-std fails if we have any dependencies of build-deps, which
        # cc added in 1.0.80, thus we pin back to 1.0.79 to avoid that.
        cargo update -p cc --precise "1.0.79" --verbose
-       ( cargo build --features=std -v --release -Zbuild-std=std,panic_abort > /dev/null 2>&1 ) || echo -n
-       ( cargo build --features=std -v --release --target aarch64-apple-darwin -Zbuild-std=std,panic_abort > /dev/null 2>&1 ) || echo -n
+       ( 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
+       ( RUSTC_BOOTSTRAP=1 cargo build --features=std -v --release --target aarch64-apple-darwin -Zbuild-std=std,panic_abort > /dev/null 2>&1 ) || echo -n
        # Sadly, std also depends on cc, and we can't pin it in that tree
        # directly. Instead, we have to delete the file out of the cargo
        # registry and build --offline to avoid it using the latest version.
        NEW_CC_DEP="$CARGO_HOME"
        [ "$NEW_CC_DEP" = "" ] && NEW_CC_DEP="$HOME"
-       if [ -f "$NEW_CC_DEP/.cargo/registry/cache/github.com-"*/cc-1.0.79.crate ]; then
-               mv "$NEW_CC_DEP/.cargo/registry/cache/github.com-"*/cc-1.0.79.crate ./
+       [ -d "$NEW_CC_DEP/.cargo/registry/cache/"github.com-* ] && CARGO_REGISTRY_CACHE="$NEW_CC_DEP/.cargo/registry/cache/"github.com-*
+       [ -d "$NEW_CC_DEP/.cargo/registry/cache/"index.crates.io-* ] && CARGO_REGISTRY_CACHE="$NEW_CC_DEP/.cargo/registry/cache/"index.crates.io-*
+       if [ -d "$CARGO_REGISTRY_CACHE" ]; then
+               if [ -f "$CARGO_REGISTRY_CACHE/cc-1.0.79.crate" ]; then
+                       mv "$CARGO_REGISTRY_CACHE/cc-1.0.79.crate" ./
+               fi
+               rm -f "$CARGO_REGISTRY_CACHE/"*/cc-*.crate
+               [ -f ./cc-1.0.79.crate ] && mv ./cc-1.0.79.crate "$CARGO_REGISTRY_CACHE/"
+       else
+               echo "Couldn't find cargo cache, build-std builds are likely to fail!"
        fi
-       rm -f "$NEW_CC_DEP/.cargo/registry/cache/github.com-"*/cc-*.crate
-       [ -f ./cc-1.0.79.crate ] && mv ./cc-1.0.79.crate "$NEW_CC_DEP/.cargo/registry/cache/github.com-"*/
 }
 
 # Then, check with memory sanitizer, if we're on Linux and have rustc nightly