File: defs.bzl

package info (click to toggle)
golang-gvisor-gvisor 0.0~20240729.0-4~bpo12%2B2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 21,296 kB
  • sloc: asm: 3,361; ansic: 1,197; cpp: 348; makefile: 92; python: 89; sh: 83
file content (29 lines) | stat: -rw-r--r-- 1,077 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""The go_fieldenum target infers Field, Fields, and FieldSet types for each
struct in an input source file marked +fieldenum.
"""

def _go_fieldenum_impl(ctx):
    output = ctx.outputs.out

    args = ["-pkg=%s" % ctx.attr.package, "-out=%s" % output.path]
    for src in ctx.attr.srcs:
        args += [f.path for f in src.files.to_list()]

    ctx.actions.run(
        inputs = ctx.files.srcs,
        outputs = [output],
        mnemonic = "GoFieldenum",
        progress_message = "Generating Go field enumerators %s" % ctx.label,
        arguments = args,
        executable = ctx.executable._tool,
    )

go_fieldenum = rule(
    implementation = _go_fieldenum_impl,
    attrs = {
        "srcs": attr.label_list(doc = "input source files", mandatory = True, allow_files = True),
        "package": attr.string(doc = "the package for the generated source file", mandatory = True),
        "out": attr.output(doc = "output file", mandatory = True),
        "_tool": attr.label(executable = True, cfg = "exec", default = Label("//tools/go_fieldenum:fieldenum")),
    },
)