16 lines
503 B
Python
16 lines
503 B
Python
MyHeaderInfo = provider(fields = ["hdr"])
|
|
|
|
def _gen_hdr_impl(ctx):
|
|
out = ctx.actions.declare_file(ctx.label.name + ".h") # out is a file, not a path
|
|
ctx.actions.run_shell(
|
|
inputs = [],
|
|
outputs = [out],
|
|
command = "printf '#pragma once\n#define %s 42\n' > %s" % (ctx.label.name.upper(), out.path),
|
|
progress_message = "Generating %s" % out.path,
|
|
)
|
|
return [DefaultInfo(files=depset([out])), MyHeaderInfo(hdr = out)]
|
|
|
|
gen_hdr = rule(
|
|
implementation = _gen_hdr_impl,
|
|
attrs = {},
|
|
)
|