Skip to content

Commit d82d511

Browse files
committed
Fix: Run entire build+stage pipeline in single shell invocation
Previous approach used separate Homebrew system() calls for build and cp, but Ruby cp was not persisting staged binaries between builds. Now wraps all swift build + cp commands in a single 'sh -c' call.
1 parent b7e1411 commit d82d511

File tree

1 file changed

+20
-32
lines changed

1 file changed

+20
-32
lines changed

Formula/wwk.rb

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,29 @@ def install
2323
}
2424
SWIFT
2525

26-
# Swift 6 new build system only keeps the last --product binary
27-
# in the output directory. Build each product and immediately
28-
# move it to a staging area using shell cp (Homebrew's Ruby cp
29-
# does not execute between system calls in a loop).
30-
swift_flags = "--configuration release --disable-sandbox -Xswiftc -cross-module-optimization"
31-
26+
# Swift 6 new build system may remove previous binaries when
27+
# building a different --product. Run the entire build-and-stage
28+
# pipeline in a single shell invocation so nothing interferes.
3229
staging = buildpath/"staged_binaries"
3330
staging.mkpath
3431

35-
# Build wwk, stage it
36-
system "swift", "build",
37-
"--configuration", "release",
38-
"--disable-sandbox",
39-
"-Xswiftc", "-cross-module-optimization",
40-
"--product", "wwk"
41-
bp = Utils.safe_popen_read(
42-
"swift", "build", "--show-bin-path", "--configuration", "release"
43-
).chomp
44-
system "cp", "#{bp}/wwk", staging.to_s
45-
46-
# Build wwkd, stage it
47-
system "swift", "build",
48-
"--configuration", "release",
49-
"--disable-sandbox",
50-
"-Xswiftc", "-cross-module-optimization",
51-
"--product", "wwkd"
52-
system "cp", "#{bp}/wwkd", staging.to_s
53-
54-
# Build WellWhaddyaKnow, stage it
55-
system "swift", "build",
56-
"--configuration", "release",
57-
"--disable-sandbox",
58-
"-Xswiftc", "-cross-module-optimization",
59-
"--product", "WellWhaddyaKnow"
60-
system "cp", "#{bp}/WellWhaddyaKnow", staging.to_s
32+
system "sh", "-c", <<~SH
33+
set -e
34+
FLAGS="--configuration release --disable-sandbox -Xswiftc -cross-module-optimization"
35+
36+
swift build $FLAGS --product wwk
37+
BP=$(swift build --show-bin-path --configuration release)
38+
cp "$BP/wwk" "#{staging}/"
39+
40+
swift build $FLAGS --product wwkd
41+
cp "$BP/wwkd" "#{staging}/"
42+
43+
swift build $FLAGS --product WellWhaddyaKnow
44+
cp "$BP/WellWhaddyaKnow" "#{staging}/"
45+
46+
echo "--- staged_binaries ---"
47+
ls -la "#{staging}/"
48+
SH
6149

6250
# Install CLI and agent binaries
6351
bin.install staging/"wwk"

0 commit comments

Comments
 (0)