tools: dev build mac — 64MB xcodebuild buffer, real error output, GOTOOLCHAIN (#1114)
A clean xcodebuild outgrows spawnSync's 1MB default maxBuffer, so Node killed the child (ENOBUFS) and 'build mac' printed a bare 'Build failed!' — stderr is empty and the truncated stdout has no error lines. 64MB buffer on both xcodebuild spawns (build mac + alt), spawn-level errors printed so an ENOBUFS names itself, error lines extracted from stdout (where xcodebuild puts them) like altMac already did, and GOTOOLCHAIN=auto set for the Go build phase.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 file changed,
+17
−5
tools/dev+17 −5
diff --git a/tools/dev b/tools/dev| index 12918c5..6130c9a 100755 |
| --- a/tools/dev |
| +++ b/tools/dev |
| @@ -58,6 +58,12 @@ function needsBuild(appPath) { |
| } |
| } |
| +// The Mac target's Go build phase needs GOTOOLCHAIN=auto (go-toolchain |
| +// pinning otherwise fails the build under Xcode's environment). |
| +function goEnv() { |
| + return { ...process.env, GOTOOLCHAIN: process.env.GOTOOLCHAIN ?? "auto" }; |
| +} |
| + |
| function run(cmd, args, opts = {}) { |
| const result = spawnSync(cmd, args, { cwd: REPO_ROOT, stdio: "inherit", ...opts }); |
| if (result.error) throw result.error; |
| @@ -88,12 +94,17 @@ const commands = { |
| "-destination", "generic/platform=macOS", |
| "-derivedDataPath", path.join(IOS_DIR, "build"), |
| "build", |
| - ], { cwd: IOS_DIR, encoding: "utf8" }); |
| + ], { cwd: IOS_DIR, encoding: "utf8", env: goEnv(), maxBuffer: 64 * 1024 * 1024 }); |
| if (result.status !== 0) { |
| console.error("Build failed!"); |
| - console.error(result.stderr); |
| - process.exit(result.status); |
| + // A spawn-level failure (e.g. ENOBUFS when output outgrows maxBuffer) |
| + // carries no build output — name it, or nothing at all gets printed. |
| + if (result.error) console.error(String(result.error)); |
| + // xcodebuild reports errors on STDOUT — stderr alone is usually empty. |
| + const errs = (result.stdout || "").split("\n").filter((l) => l.includes("error:")); |
| + console.error(errs.slice(-20).join("\n") || result.stderr || ""); |
| + process.exit(result.status ?? 1); |
| } |
| console.log("✓ Mac app built successfully"); |
| @@ -390,11 +401,12 @@ async function altMac(rawSlug) { |
| "LCHAT_MAC_APPICON=AppIconDev", |
| "LCHAT_MAC_SPARKLE_AUTOCHECK=NO", |
| "build", |
| - ], { cwd: IOS_DIR, encoding: "utf8" }); |
| + ], { cwd: IOS_DIR, encoding: "utf8", env: goEnv(), maxBuffer: 64 * 1024 * 1024 }); |
| if (result.status !== 0) { |
| console.error("Build failed!"); |
| + if (result.error) console.error(String(result.error)); |
| const errs = (result.stdout || "").split("\n").filter((l) => l.includes("error:")); |
| - console.error(errs.slice(-20).join("\n") || result.stderr); |
| + console.error(errs.slice(-20).join("\n") || result.stderr || ""); |
| process.exit(result.status ?? 1); |
| } |
| // Relaunch cleanly on rebuild: quit this slug's running copy (matched by |