Skip to content

Commit 6bc78a7

Browse files
committed
feat: expose scriptc --print build flag
1 parent e559bb9 commit 6bc78a7

4 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ On every build the plugin runs `scriptc coverage <entry> --print diagnostics` at
4848
| `failOnBlockers` | `true` | Fail the bundler build when coverage finds blockers |
4949
| `out` | `.scriptc/<name><suffix>` | `-o/--out` primary output path |
5050
| `emit` | `"exe"` | `--emit`: ir, llvm, asm, obj, exe |
51+
| `print` | , | `--print`: native-link-info or diagnostics |
5152
| `backend` | , | `--backend` code generator |
5253
| `optimization` | `"release"` | `--optimization`: release, dev, speed |
5354
| `strip` | `false` | `--strip` symbol/debug payload |

‎docs/options.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Every `scriptc build` flag of the pinned release maps to a typed option. Flags a
1919
| --- | --- | --- |
2020
| `out` | `-o, --out` | Primary output path (default `.scriptc/<name><suffix>`) |
2121
| `emit` | `--emit` | Primary output: `ir`, `llvm`, `asm`, `obj`, `exe` |
22+
| `print` | `--print` | `native-link-info` (implies `--emit=obj`, no link) or `diagnostics` |
2223
| `backend` | `--backend` | Code generator (`llvm`) |
2324
| `optimization` | `--optimization` | `release` (-O2), `dev` (-O0 + breakpoints), `speed` (runtime inlining, inline RC) |
2425
| `strip` | `--strip` | Remove symbol/debug payload |

‎src/scriptc.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ export interface ScriptcBuildOptions {
1515
out?: string;
1616
// --emit: primary output kind (default exe). asm/obj need a platform helper.
1717
emit?: "ir" | "llvm" | "asm" | "obj" | "exe";
18+
// --print: machine-readable metadata instead of the output path.
19+
// native-link-info implies --emit=obj and never links; diagnostics prints
20+
// the versioned JSON diagnostics envelope.
21+
print?: "native-link-info" | "diagnostics";
1822
// --backend: code generator (llvm).
1923
backend?: string;
2024
// --optimization: release (default, -O2), dev (-O0 + breakpoints + cached
@@ -59,6 +63,7 @@ export function buildArgs(o: ScriptcBuildOptions, entry: string): string[] {
5963
a.push(entry);
6064
if (o.out !== undefined) a.push("--out", o.out);
6165
if (o.emit !== undefined) a.push("--emit", o.emit);
66+
if (o.print !== undefined) a.push("--print", o.print);
6267
if (o.backend !== undefined) a.push("--backend", o.backend);
6368
if (o.optimization !== undefined) a.push("--optimization", o.optimization);
6469
if (o.strip === true) a.push("--strip");

‎test/scriptc.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ test("buildArgs: scalar flags map one-to-one", () => {
4747
]);
4848
});
4949

50+
test("buildArgs: print selects a machine-readable output", () => {
51+
assert.deepEqual(buildArgs({ print: "native-link-info" }, "e.ts"), [
52+
"build",
53+
"e.ts",
54+
"--print",
55+
"native-link-info",
56+
]);
57+
assert.deepEqual(buildArgs({ print: "diagnostics" }, "e.ts"), [
58+
"build",
59+
"e.ts",
60+
"--print",
61+
"diagnostics",
62+
]);
63+
});
64+
5065
test("buildArgs: keepLlvm default emits nothing, true emits --keep-llvm", () => {
5166
assert.ok(!buildArgs({}, "e.ts").includes("--keep-llvm"));
5267
assert.ok(!buildArgs({ keepLlvm: false }, "e.ts").includes("--keep-llvm"));

0 commit comments

Comments
 (0)