diff options
author | Zhaozhong Ni <nzz@google.com> | 2018-08-03 12:07:57 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-08-03 12:09:13 -0700 |
commit | 25178ebdf5e881eae8e81eaf2f69d96de42d2250 (patch) | |
tree | c56769ea375733dfdcc70ac68cf5c1c45fb9baa8 /tools/go_stateify/defs.bzl | |
parent | a3927157c56cc022cefebc30c8a9b6014f5d0412 (diff) |
stateify: make explicit mode no longer optional.
PiperOrigin-RevId: 207303405
Change-Id: I17b6433963d78e3631a862b7ac80f566c8e7d106
Diffstat (limited to 'tools/go_stateify/defs.bzl')
-rw-r--r-- | tools/go_stateify/defs.bzl | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/tools/go_stateify/defs.bzl b/tools/go_stateify/defs.bzl index 2b2582b7a..70ce73d7b 100644 --- a/tools/go_stateify/defs.bzl +++ b/tools/go_stateify/defs.bzl @@ -1,7 +1,20 @@ """Stateify is a tool for generating state wrappers for Go types. -The go_stateify rule is used to generate a file that will appear in a Go -target; the output file should appear explicitly in a srcs list. For example: +The recommended way is to use the go_library rule defined below with mostly +identical configuration as the native go_library rule. + +load("//tools/go_stateify:defs.bzl", "go_library") + +go_library( + name = "foo", + srcs = ["foo.go"], +) + +Under the hood, the go_stateify rule is used to generate a file that will +appear in a Go target; the output file should appear explicitly in a srcs list. +For example (the above is still the preferred way): + +load("//tools/go_stateify:defs.bzl", "go_stateify") go_stateify( name = "foo_state", @@ -35,8 +48,6 @@ def _go_stateify_impl(ctx): args += ["-statepkg=%s" % ctx.attr._statepkg] if ctx.attr.imports: args += ["-imports=%s" % ",".join(ctx.attr.imports)] - if ctx.attr.explicit: - args += ["-explicit=true"] args += ["--"] for src in ctx.attr.srcs: args += [f.path for f in src.files] @@ -57,7 +68,6 @@ def _go_stateify_impl(ctx): # imports: an optional list of extra non-aliased, Go-style absolute import paths. # out: the name of the generated file output. This must not conflict with any other files and must be added to the srcs of the relevant go_library. # package: the package name for the input sources. -# explicit: only generate for types explicitly annotated as savable. go_stateify = rule( implementation = _go_stateify_impl, attrs = { @@ -65,7 +75,6 @@ go_stateify = rule( "imports": attr.string_list(mandatory = False), "package": attr.string(mandatory = True), "out": attr.output(mandatory = True), - "explicit": attr.bool(default = False), "_tool": attr.label(executable = True, cfg = "host", default = Label("//tools/go_stateify:stateify")), "_statepkg": attr.string(default = "gvisor.googlesource.com/gvisor/pkg/state"), }, @@ -81,7 +90,6 @@ def go_library(name, srcs, deps = [], imports = [], **kwargs): imports = imports, package = name, out = name + "_state_autogen.go", - explicit = True, ) all_srcs = srcs + [name + "_state_autogen.go"] if "//pkg/state" not in deps: |