ReviewOS

also looking at this

craft-native/craft

fix(build): select the core Zig project explicitly

#383
Merged chris wants to merge codex/zig-core-build-root into main
4 files +44 -2

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

.github/workflows/ci.ymlmodifiedformatting only+3-3
Changes to .github/workflows/ci.yml
@@ -187,14 +187,14 @@ jobs:
187187 - name: First-party Zig dependencies
188188 uses: ./.github/actions/first-party-zig-deps
189189
190 - name: Verify pinned compiler core project selection
191 run: bun scripts/verify-zig-core-project.ts
192
193190 - name: Build Windows CLI
194191 # scripts/zig.ts resolves the actual managed binary from pantry.lock,
195192 # including its adjacent standard library on Windows.
196193 run: bun run build:core
197194
195 - name: Verify pinned compiler core project selection
196 run: bun scripts/verify-zig-core-project.ts
197
198198 - name: Stage pinned WebView2 loader
199199 shell: pwsh
200200 run: |
scripts/verify-zig-core-project.tsmodified+0-8
Changes to scripts/verify-zig-core-project.ts
@@ -16,14 +16,6 @@ try {
1616 writeFileSync(join(root, 'build.zig'), 'const std=; pub fn build(b:*std.Build) void {_=b.standardOptimizeOption(.{});}\n')
1717 writeFileSync(join(core, 'build.zig'), 'const std=; pub fn build(b:*std.Build) void {_=b.standardOptimizeOption(.{}); const version=b.option([]const u8,"version","version") orelse "missing"; std.debug.print("PROJECT_VERSION={s}\\n",.{version});}\n')
1818 const env = { ...process.env, CRAFT_ZIG: zig.path }
19 const child = Bun.spawnSync([process.execPath, '-p', 'process.cwd()'], { cwd: core, env, stdout: 'pipe', stderr: 'pipe' })
20 console.log('Requested/observed child cwd:', JSON.stringify({ requested: core, observed: child.stdout.toString().trim(), status: child.exitCode }))
21 for (const mode of ['default', 'absolute', 'relative'] as const) {
22 const cwd = mode === 'relative' ? root : core
23 const args = mode === 'default' ? [] : ['--build-file', mode === 'absolute' ? join(core, 'build.zig') : 'packages/zig/build.zig']
24 const result = Bun.spawnSync([zig.path, 'build', ...args, '-Dversion=1.2.3'], { cwd, env, stdout: 'pipe', stderr: 'pipe' })
25 console.log(JSON.stringify({ mode, cwd, status: result.exitCode, stdout: result.stdout.toString(), stderr: result.stderr.toString() }))
26 }
2719 const runner = join(root, 'runner.ts')
2820 writeFileSync(runner, `import {runZig} from ${JSON.stringify(join(source, 'scripts/zig.ts'))};process.exitCode=runZig(${JSON.stringify(root)},['--core','--versioned','build']);\n`)
2921 const result = Bun.spawnSync([process.execPath, runner], { cwd: root, env, stdout: 'pipe', stderr: 'pipe' })