summaryrefslogtreecommitdiffhomepage
path: root/tools/go_generics/defs.bzl
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-07-24 13:59:45 -0700
committergVisor bot <gvisor-bot@google.com>2020-07-24 13:59:45 -0700
commitea0342d470e7eabd9aa2968d4919c67784e4a358 (patch)
tree3523dea342e2fb2b821d0e8958f7833536b61349 /tools/go_generics/defs.bzl
parente2c70ee9814f0f76ab5c30478748e4c697e91f33 (diff)
parentab0262bd94c25bc91d5e0d831b75729c253dfde6 (diff)
Merge pull request #3356 from amscanne:generics_tests
PiperOrigin-RevId: 323066414
Diffstat (limited to 'tools/go_generics/defs.bzl')
-rw-r--r--tools/go_generics/defs.bzl11
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/go_generics/defs.bzl b/tools/go_generics/defs.bzl
index ec047a644..33329cf28 100644
--- a/tools/go_generics/defs.bzl
+++ b/tools/go_generics/defs.bzl
@@ -100,20 +100,21 @@ def _go_template_instance_impl(ctx):
# Build the argument list.
args = ["-i=%s" % template.file.path, "-o=%s" % output.path]
- args += ["-p=%s" % ctx.attr.package]
+ if ctx.attr.package:
+ args.append("-p=%s" % ctx.attr.package)
if len(ctx.attr.prefix) > 0:
- args += ["-prefix=%s" % ctx.attr.prefix]
+ args.append("-prefix=%s" % ctx.attr.prefix)
if len(ctx.attr.suffix) > 0:
- args += ["-suffix=%s" % ctx.attr.suffix]
+ args.append("-suffix=%s" % ctx.attr.suffix)
args += [("-t=%s=%s" % (p[0], p[1])) for p in ctx.attr.types.items()]
args += [("-c=%s=%s" % (p[0], p[1])) for p in ctx.attr.consts.items()]
args += [("-import=%s=%s" % (p[0], p[1])) for p in ctx.attr.imports.items()]
if ctx.attr.anon:
- args += ["-anon"]
+ args.append("-anon")
ctx.actions.run(
inputs = [template.file],
@@ -151,7 +152,7 @@ go_template_instance = rule(
"consts": attr.string_dict(),
"imports": attr.string_dict(),
"anon": attr.bool(mandatory = False, default = False),
- "package": attr.string(mandatory = True),
+ "package": attr.string(mandatory = False),
"out": attr.output(mandatory = True),
"_tool": attr.label(executable = True, cfg = "host", default = Label("//tools/go_generics")),
},