You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Three roles, one primitive — `role` only decides where the edge's outputs
182
+
Four roles, one primitive — `role` only decides where the edge's outputs
183
183
attach:
184
184
185
185
|`role`| Outputs | Ordering | Typical |
186
186
|---|---|---|---|
187
187
|`source`| join the compile set | the compile edge consumes them | protoc, a transpiler |
188
188
|`check`| a stamp file | runs **alongside** compilation (set `blocking = true` to gate it) | clang-tidy, a format or ABI check |
189
+
|`object`| join the **link** set | the link edge consumes them | a resource compiler, `objcopy` embedding a blob, a generated `.def`, a pre-built `.o`|
189
190
|`artifact`| a new file | its *inputs* are link outputs, so it runs after the link | codesign, packaging, size budgets |
190
191
191
192
No phase machinery is involved: ninja's own file dependencies do the
192
193
sequencing, which is also why an `artifact` action cannot double-apply itself
193
194
the way a naive "post-build hook" would.
194
195
196
+
`object` (2026.8.7.1+) takes an optional `.target("name")`, repeatable; omit it
197
+
and the outputs attach to every image (binary / shared library) the declaring
198
+
package produces. It needs the name because, unlike `artifact`, it runs *before*
199
+
the link and so has no `${mcpp.target_file:…}` to infer one from — an unknown
200
+
name is an error rather than an edge that quietly attaches to nothing.
201
+
202
+
> Naming a pre-built object in `[build].ldflags` also reaches the linker, and
203
+
> should not be used for anything the build produces: ldflags is a flat string
204
+
> in the link command, not a file in the graph, so nothing tracks it and editing
205
+
> it gives you `ninja: no work to do`. For Windows resources specifically, use
206
+
> [`[resources]`](05-mcpp-toml.md) —
207
+
> `object` is the escape hatch for everything else.
208
+
195
209
**You must name the output files.** mcpp fixes the source set, the fingerprint
196
210
and the module graph during prepare, so an output whose *name* is unknown
197
211
cannot be built. Content may arrive later; names may not. A malformed action is
0 commit comments