diff options
author | Jamie Liu <jamieliu@google.com> | 2021-07-27 18:11:03 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-07-27 18:14:05 -0700 |
commit | 964fb3ca768756fbc58d1d9312c53886964ae608 (patch) | |
tree | 6d9a2dd0c0b16dd68a1b2c11666c3f9564ea72fd /tools/go_stateify/main.go | |
parent | 9a96e00f0fb0215d604c72485a85c29f75f48ebc (diff) |
Use go:build directives in generated files.
Build constraints are now inferred from go:build directives rather than +build
directives. +build directives are still emitted in generated files as required
in Go 1.16 and earlier.
Note that go/build/constraint was added in Go 1.16, so gVisor now requires Go
1.16.
PiperOrigin-RevId: 387240779
Diffstat (limited to 'tools/go_stateify/main.go')
-rw-r--r-- | tools/go_stateify/main.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/go_stateify/main.go b/tools/go_stateify/main.go index 93022f504..7216388a0 100644 --- a/tools/go_stateify/main.go +++ b/tools/go_stateify/main.go @@ -28,7 +28,7 @@ import ( "strings" "sync" - "gvisor.dev/gvisor/tools/tags" + "gvisor.dev/gvisor/tools/constraintutil" ) var ( @@ -214,10 +214,13 @@ func main() { // Automated warning. fmt.Fprint(outputFile, "// automatically generated by stateify.\n\n") - // Emit build tags. - if t := tags.Aggregate(flag.Args()); len(t) > 0 { - fmt.Fprintf(outputFile, "%s\n\n", strings.Join(t.Lines(), "\n")) + // Emit build constraints. + bcexpr, err := constraintutil.CombineFromFiles(flag.Args()) + if err != nil { + fmt.Fprintf(os.Stderr, "Failed to infer build constraints: %v", err) + os.Exit(1) } + outputFile.WriteString(constraintutil.Lines(bcexpr)) // Emit the package name. _, pkg := filepath.Split(*fullPkg) |