@imp/rules/imp/generate
generated_files(options)
Declare a graph-native generated-files root.
The result is a task handle for the GENERATE slot of
@imp/rules/workflows/generate. The task has one artifact output for each
output path, and a before value: the CAS digest of the same paths in the
workspace when the goal ran. The goal reads the path of each file from its
artifact. The generator stays hermetic and cacheable: it runs in a
sandbox, keeps its outputs in CAS, and does not know about the check
flag. Thus imp generate and imp generate --check share one cache
entry. The workflow compares the outputs with the workspace and writes
them at the goal boundary.
A separate task captures the current workspace files of output_paths.
Thus a change to a generated file in the workspace does not change the
cache key of the generator. The capture uses the workspace file walk, so
a gitignored output path is always reported as stale. The capture reads
each output path as a glob pattern, so an output path must not contain
*, ?, [, ], {, or }.
Options:
display Optional action label.
tools Optional table of named tool handles. Each tool is on PATH
when the generator runs.
inputs Optional table of named source handles that the generator
reads.
output_paths Workspace-relative paths that the generator writes.
argv function(exec, resolved) that returns the generator
command line.
Example (ci/BUILD.luau):
local generate = require("@imp/rules/imp/generate") local workflow = require("@imp/rules/workflows/generate")
return { docs_workflow = { [workflow.GENERATE] = generate.generated_files({ display = "generate GitHub workflows", tools = { python3 = core.native_tool("python3") }, inputs = { script = core.files({ include = { SCRIPT } }) }, output_paths = { ".github/workflows/docs.yml" }, argv = function(_exec, _resolved) return { "python3", SCRIPT, ".github/workflows/docs.yml" } end, }), }, }
Source: rules/imp/generate/index.luau:153.