@@ -35,6 +35,13 @@ function inject_version {
3535 # Version starts immediately after the sentinel
3636 local version_offset=$(( sentinel_offset + ${# sentinel} ))
3737 printf " $version \0" | dd of=" $binary " bs=1 seek=$version_offset conv=notrunc 2> /dev/null
38+
39+ # Re-sign after modifying the binary.
40+ if [[ " $( os) " == " macos" ]]; then
41+ codesign -s - -f " $binary " 2> /dev/null || true
42+ elif llvm-objdump --macho --private-header " $binary " & > /dev/null; then
43+ ldid -S " $binary "
44+ fi
3845}
3946
4047# Define build commands for each preset
@@ -55,6 +62,7 @@ function build_preset() {
5562function build_native_objects {
5663 set -eu
5764 if ! cache_exists barretenberg-$native_preset -$hash .zst; then
65+ (flock -x 200 && cd src/barretenberg/nodejs_module && yarn --immutable) 200> /tmp/bb-yarn.lock
5866 cmake --preset " $native_preset "
5967 targets=$( cmake --build --preset " $native_preset " --target help | awk -F: ' $1 ~ /(_objects|_tests|_bench|_gen|.a)$/ && $1 !~ /^cmake_/{print $1}' | tr ' \n' ' ' )
6068 cmake --build --preset " $native_preset " --target $targets nodejs_module
@@ -87,6 +95,7 @@ function build_cross_objects {
8795 set -eu
8896 target=$1
8997 if ! cache_exists barretenberg-$target -$hash .zst; then
98+ (flock -x 200 && cd src/barretenberg/nodejs_module && yarn --immutable) 200> /tmp/bb-yarn.lock
9099 build_preset zig-$target --target barretenberg nodejs_module vm2_stub circuit_checker honk
91100 fi
92101}
@@ -96,17 +105,13 @@ function build_cross_objects {
96105function build_cross {
97106 set -eu
98107 target=$1
99- is_macos=${2:- false}
100108 if ! cache_download barretenberg-$target -$hash .zst; then
109+ (flock -x 200 && cd src/barretenberg/nodejs_module && yarn --immutable) 200> /tmp/bb-yarn.lock
101110 build_preset zig-$target --target bb --target nodejs_module --target bb-external
102111 cache_upload barretenberg-$target -$hash .zst build-zig-$target /{bin,lib}
103112 fi
104113 # Always inject version (even for cached binaries) to ensure correct version on release
105114 inject_version build-zig-$target /bin/bb
106- # Code sign for macOS after version injection (must be last modification to binary)
107- if [ " $is_macos " == " true" ]; then
108- ldid -S build-zig-$target /bin/bb
109- fi
110115}
111116
112117# Build static library (.a) for iOS using Zig cross-compilation from Linux.
@@ -294,8 +299,6 @@ function build {
294299 rm -rf build*
295300 fi
296301
297- (cd src/barretenberg/nodejs_module && yarn --frozen-lockfile --prefer-offline)
298-
299302 if semver check " $REF_NAME " && [[ " $( arch) " == " amd64" ]]; then
300303 # Download mobile SDKs before parallel builds (shared across presets)
301304 bash scripts/download-ios-sdk.sh
@@ -306,8 +309,8 @@ function build {
306309 " build_wasm" \
307310 " build_wasm_threads" \
308311 " build_cross arm64-linux" \
309- " build_cross amd64-macos true " \
310- " build_cross arm64-macos true " \
312+ " build_cross amd64-macos" \
313+ " build_cross arm64-macos" \
311314 " build_ios zig-arm64-ios" \
312315 " build_ios zig-arm64-ios-sim" \
313316 " build_android zig-arm64-android" \
@@ -325,7 +328,7 @@ function build {
325328 if [ " $( arch) " == " amd64" ] && [ " $CI_FULL " -eq 1 ]; then
326329 bash scripts/download-ios-sdk.sh
327330 bash scripts/download-android-sysroot.sh
328- builds+=(" build_cross arm64-macos true " build_smt_verification " build_ios zig-arm64-ios" " build_ios zig-arm64-ios-sim" " build_android zig-arm64-android" " build_android zig-x86_64-android" )
331+ builds+=(" build_cross arm64-macos" build_smt_verification " build_ios zig-arm64-ios" " build_ios zig-arm64-ios-sim" " build_android zig-arm64-android" " build_android zig-x86_64-android" )
329332 fi
330333 parallel --line-buffered --tag --halt now,fail=1 " denoise {}" ::: " ${builds[@]} "
331334 fi
0 commit comments