@imp/rules/imp/codegen
codegen(options)
Declare generated sources that stay in the graph.
local codegen = require("@imp/rules/imp/codegen").codegen
local bindings = codegen({ display = "generate Odin bindings", tools = { python3 = core.native_tool("python3") }, inputs = { schema = core.files({ include = { "schema.json" } }) }, output_paths = { "app/generated/bindings.odin" }, argv = function(_exec, _resolved) return { "python3", "tools/schema_to_odin.py", "schema.json", "app/generated/bindings.odin" } end, })
output_paths are workspace-relative, and they are the contract: a
package stages each artifact at exactly that path, so a path has one
owner. Exclude a generated path from each glob that could also include it.
A nested output path needs no mkdir. The executor creates the parent
directory of each declared file output before it starts the program.
Options are as for generated_files(): display, tools, inputs,
output_paths, and argv.
Returns a frozen table { paths, files, BUILD, CODEGEN }.
files[path] is the artifact handle of that output path. BUILD builds
the generator and writes nothing to the workspace. CODEGEN holds the
same generator task and makes it selectable with imp codegen, which
exports the files below dist/codegen/.
Source: rules/imp/codegen/index.luau:61.
stamp_file(options)
Declare a graph artifact that contains fixed text.
This is the simplest codegen(): the content is a literal, so there is no
generator command and no declared tool. argv[0] is a bare sh, the
shell that the executor finds.
Options: output (the workspace-relative output path) and text.
Returns a frozen { file, BUILD } with the file artifact and its build
root.
Source: rules/imp/codegen/index.luau:177.