]> Cypherpunks repositories - gostls13.git/commitdiff
internal/goarch, internal/goos: update generators for syslist.go
authorIan Lance Taylor <iant@golang.org>
Wed, 8 Jun 2022 23:33:45 +0000 (16:33 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 15 Jun 2022 21:31:23 +0000 (21:31 +0000)
Update the generator programs for the changes to syslist.go in CL
390274 and the changes to the generated files in CL 344955.

Tested by running the programs and verifying that the files did not
change.

Fixes #53299

Change-Id: I2b2c5769f7e9283aa05c803256d2ea1eb9ad1547
Reviewed-on: https://go-review.googlesource.com/c/go/+/411334
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/go/build/syslist.go
src/internal/goarch/gengoarch.go
src/internal/goos/gengoos.go

index ea67662c3e2c97dc172408049a49c6466c75e60c..35cffce6dcab2772b334e970f97efbd25a407e69 100644 (file)
@@ -4,6 +4,10 @@
 
 package build
 
+// Note that this file is read by internal/goarch/gengoarch.go and by
+// internal/goos/gengoos.go. If you change this file, look at those
+// files as well.
+
 // knownOS is the list of past, present, and future known GOOS values.
 // Do not remove from this list, as it is used for filename matching.
 // If you add an entry to this list, look at unixOS, below.
index 3c706e04ad0cc5a56bebe06408115c27e20c321e..0b0be5cd157da4a8ab4b230a051a410d6a67c374 100644 (file)
@@ -11,7 +11,6 @@ import (
        "fmt"
        "log"
        "os"
-       "strconv"
        "strings"
 )
 
@@ -22,14 +21,18 @@ func main() {
        if err != nil {
                log.Fatal(err)
        }
-       const goarchPrefix = `const goarchList = `
+       const goarchPrefix = `var knownArch = map[string]bool{`
+       inGOARCH := false
        for _, line := range strings.Split(string(data), "\n") {
                if strings.HasPrefix(line, goarchPrefix) {
-                       text, err := strconv.Unquote(strings.TrimPrefix(line, goarchPrefix))
-                       if err != nil {
-                               log.Fatalf("parsing goarchList: %v", err)
-                       }
-                       goarches = strings.Fields(text)
+                       inGOARCH = true
+               } else if inGOARCH && strings.HasPrefix(line, "}") {
+                       break
+               } else if inGOARCH {
+                       goarch := strings.Fields(line)[0]
+                       goarch = strings.TrimPrefix(goarch, `"`)
+                       goarch = strings.TrimSuffix(goarch, `":`)
+                       goarches = append(goarches, goarch)
                }
        }
 
@@ -39,7 +42,7 @@ func main() {
                }
                var buf bytes.Buffer
                fmt.Fprintf(&buf, "// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.\n\n")
-               fmt.Fprintf(&buf, "//go:build %s\n", target) // must explicitly include target for bootstrapping purposes
+               fmt.Fprintf(&buf, "//go:build %s\n\n", target) // must explicitly include target for bootstrapping purposes
                fmt.Fprintf(&buf, "package goarch\n\n")
                fmt.Fprintf(&buf, "const GOARCH = `%s`\n\n", target)
                for _, goarch := range goarches {
index 1b62503fd007427fcfcc359edb4ebf900ce87fa2..37d9706d1e877cb98f53626628b4600f4c875032 100644 (file)
@@ -11,7 +11,6 @@ import (
        "fmt"
        "log"
        "os"
-       "strconv"
        "strings"
 )
 
@@ -22,14 +21,18 @@ func main() {
        if err != nil {
                log.Fatal(err)
        }
-       const goosPrefix = `const goosList = `
+       const goosPrefix = `var knownOS = map[string]bool{`
+       inGOOS := false
        for _, line := range strings.Split(string(data), "\n") {
                if strings.HasPrefix(line, goosPrefix) {
-                       text, err := strconv.Unquote(strings.TrimPrefix(line, goosPrefix))
-                       if err != nil {
-                               log.Fatalf("parsing goosList: %v", err)
-                       }
-                       gooses = strings.Fields(text)
+                       inGOOS = true
+               } else if inGOOS && strings.HasPrefix(line, "}") {
+                       break
+               } else if inGOOS {
+                       goos := strings.Fields(line)[0]
+                       goos = strings.TrimPrefix(goos, `"`)
+                       goos = strings.TrimSuffix(goos, `":`)
+                       gooses = append(gooses, goos)
                }
        }
 
@@ -50,7 +53,7 @@ func main() {
                tags = append(tags, target) // must explicitly include target for bootstrapping purposes
                var buf bytes.Buffer
                fmt.Fprintf(&buf, "// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.\n\n")
-               fmt.Fprintf(&buf, "//go:build %s\n", strings.Join(tags, " && "))
+               fmt.Fprintf(&buf, "//go:build %s\n\n", strings.Join(tags, " && "))
                fmt.Fprintf(&buf, "package goos\n\n")
                fmt.Fprintf(&buf, "const GOOS = `%s`\n\n", target)
                for _, goos := range gooses {