Skip to content

Commit cdb5aec

Browse files
committed
fix: restore native arch binary after packaging and skip testpackage for cross arch
The previous fix left the x86_64 binary in lib/binding/ after packaging, causing tests to fail on arm64 CI runners. Now we package the cross arch first (without testpackage since it can't be loaded), then the native arch last (with testpackage) so the correct binary remains for tests.
1 parent 168d3e3 commit cdb5aec

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

scripts/ci/build.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,24 @@ if [[ "$MACOS_UNIVERSAL_BUILD" == "true" ]]; then
494494
# play well with electron-builder which will try to lipo native add-ons
495495
# for different architectures.
496496
# --
497-
lipo build/Release/node_libcurl.node -thin arm64 -output lib/binding/node_libcurl.node
498-
npm_config_target_arch=arm64 pnpm pregyp package testpackage --verbose
497+
native_arch=$(uname -m)
498+
if [ "$native_arch" == "x86_64" ]; then
499+
cross_arch="arm64"
500+
native_npm_arch="x64"
501+
cross_npm_arch="arm64"
502+
else
503+
cross_arch="x86_64"
504+
native_npm_arch="arm64"
505+
cross_npm_arch="x64"
506+
fi
507+
508+
# Package the cross-compiled architecture first (no testpackage - can't load it)
509+
lipo build/Release/node_libcurl.node -thin $cross_arch -output lib/binding/node_libcurl.node
510+
npm_config_target_arch=$cross_npm_arch pnpm pregyp package --verbose
499511

500-
lipo build/Release/node_libcurl.node -thin x86_64 -output lib/binding/node_libcurl.node
501-
npm_config_target_arch=x64 pnpm pregyp package testpackage --verbose
512+
# Package the native architecture (with testpackage to verify it loads)
513+
lipo build/Release/node_libcurl.node -thin $native_arch -output lib/binding/node_libcurl.node
514+
npm_config_target_arch=$native_npm_arch pnpm pregyp package testpackage --verbose
502515
else
503516
pnpm pregyp package testpackage --verbose
504517
fi

0 commit comments

Comments
 (0)