gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/tools/go_fieldenum/defs.bzl (about) 1 """The go_fieldenum target infers Field, Fields, and FieldSet types for each 2 struct in an input source file marked +fieldenum. 3 """ 4 5 def _go_fieldenum_impl(ctx): 6 output = ctx.outputs.out 7 8 args = ["-pkg=%s" % ctx.attr.package, "-out=%s" % output.path] 9 for src in ctx.attr.srcs: 10 args += [f.path for f in src.files.to_list()] 11 12 ctx.actions.run( 13 inputs = ctx.files.srcs, 14 outputs = [output], 15 mnemonic = "GoFieldenum", 16 progress_message = "Generating Go field enumerators %s" % ctx.label, 17 arguments = args, 18 executable = ctx.executable._tool, 19 ) 20 21 go_fieldenum = rule( 22 implementation = _go_fieldenum_impl, 23 attrs = { 24 "srcs": attr.label_list(doc = "input source files", mandatory = True, allow_files = True), 25 "package": attr.string(doc = "the package for the generated source file", mandatory = True), 26 "out": attr.output(doc = "output file", mandatory = True), 27 "_tool": attr.label(executable = True, cfg = "exec", default = Label("//tools/go_fieldenum:fieldenum")), 28 }, 29 )