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_generics/go_merge/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_generics/go_merge/main.go')
-rw-r--r-- | tools/go_generics/go_merge/main.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tools/go_generics/go_merge/main.go b/tools/go_generics/go_merge/main.go index 801f2354f..81394ddce 100644 --- a/tools/go_generics/go_merge/main.go +++ b/tools/go_generics/go_merge/main.go @@ -25,9 +25,8 @@ import ( "os" "path/filepath" "strconv" - "strings" - "gvisor.dev/gvisor/tools/tags" + "gvisor.dev/gvisor/tools/constraintutil" ) var ( @@ -131,6 +130,12 @@ func main() { } f.Decls = newDecls + // Infer build constraints for the output file. + bcexpr, err := constraintutil.CombineFromFiles(flag.Args()) + if err != nil { + fatalf("Failed to read build constraints: %v\n", err) + } + // Write the output file. var buf bytes.Buffer if err := format.Node(&buf, fset, f); err != nil { @@ -141,9 +146,7 @@ func main() { fatalf("opening output: %v\n", err) } defer outf.Close() - if t := tags.Aggregate(flag.Args()); len(t) > 0 { - fmt.Fprintf(outf, "%s\n\n", strings.Join(t.Lines(), "\n")) - } + outf.WriteString(constraintutil.Lines(bcexpr)) if _, err := outf.Write(buf.Bytes()); err != nil { fatalf("write: %v\n", err) } |