summaryrefslogtreecommitdiff
path: root/src/internal/goos
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2021-06-16 20:14:22 +0000
committerMichael Knyszek <mknyszek@google.com>2021-06-17 18:54:38 +0000
commit122f5e16d690bd14ae46e9cc7e37c0c84fdc2be8 (patch)
tree6ae81d8dbe8c10c841c48a8d3d84f5b37d7f928c /src/internal/goos
parent804ecc2581caf33ae347d6a1ce67436d1f74e93b (diff)
downloadgo-git-122f5e16d690bd14ae46e9cc7e37c0c84fdc2be8.tar.gz
[dev.typeparams] internal/goarch,internal/goos: explode runtime/internal/sys into pieces
This change extracts the GOOS and GOARCH specific constants from runtime/internal/sys into packages that are available to the entire standard library. This change does not yet update the runtime and associated packages to use them, and instead adds constants to runtime/internal/sys to forward the constants defined by these new packages. Change-Id: I14d574b8d7bfe599ad25da29dc1b39716e35a734 Reviewed-on: https://go-review.googlesource.com/c/go/+/328336 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/internal/goos')
-rw-r--r--src/internal/goos/gengoos.go70
-rw-r--r--src/internal/goos/goos.go12
-rw-r--r--src/internal/goos/zgoos_aix.go26
-rw-r--r--src/internal/goos/zgoos_android.go26
-rw-r--r--src/internal/goos/zgoos_darwin.go26
-rw-r--r--src/internal/goos/zgoos_dragonfly.go26
-rw-r--r--src/internal/goos/zgoos_freebsd.go26
-rw-r--r--src/internal/goos/zgoos_hurd.go26
-rw-r--r--src/internal/goos/zgoos_illumos.go26
-rw-r--r--src/internal/goos/zgoos_ios.go26
-rw-r--r--src/internal/goos/zgoos_js.go26
-rw-r--r--src/internal/goos/zgoos_linux.go26
-rw-r--r--src/internal/goos/zgoos_netbsd.go26
-rw-r--r--src/internal/goos/zgoos_openbsd.go26
-rw-r--r--src/internal/goos/zgoos_plan9.go26
-rw-r--r--src/internal/goos/zgoos_solaris.go26
-rw-r--r--src/internal/goos/zgoos_windows.go26
-rw-r--r--src/internal/goos/zgoos_zos.go26
18 files changed, 498 insertions, 0 deletions
diff --git a/src/internal/goos/gengoos.go b/src/internal/goos/gengoos.go
new file mode 100644
index 0000000000..ebcdfec3ba
--- /dev/null
+++ b/src/internal/goos/gengoos.go
@@ -0,0 +1,70 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build ignore
+// +build ignore
+
+package main
+
+import (
+ "bytes"
+ "fmt"
+ "log"
+ "os"
+ "strconv"
+ "strings"
+)
+
+var gooses []string
+
+func main() {
+ data, err := os.ReadFile("../../go/build/syslist.go")
+ if err != nil {
+ log.Fatal(err)
+ }
+ const goosPrefix = `const goosList = `
+ 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)
+ }
+ }
+
+ for _, target := range gooses {
+ if target == "nacl" {
+ continue
+ }
+ var tags []string
+ if target == "linux" {
+ tags = append(tags, "!android") // must explicitly exclude android for linux
+ }
+ if target == "solaris" {
+ tags = append(tags, "!illumos") // must explicitly exclude illumos for solaris
+ }
+ if target == "darwin" {
+ tags = append(tags, "!ios") // must explicitly exclude ios for darwin
+ }
+ 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, "// +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 {
+ value := 0
+ if goos == target {
+ value = 1
+ }
+ fmt.Fprintf(&buf, "const Goos%s = %d\n", strings.Title(goos), value)
+ }
+ err := os.WriteFile("zgoos_"+target+".go", buf.Bytes(), 0666)
+ if err != nil {
+ log.Fatal(err)
+ }
+ }
+}
diff --git a/src/internal/goos/goos.go b/src/internal/goos/goos.go
new file mode 100644
index 0000000000..332cf51e5d
--- /dev/null
+++ b/src/internal/goos/goos.go
@@ -0,0 +1,12 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// package goos contains GOOS-specific constants.
+package goos
+
+// The next line makes 'go generate' write the zgoos*.go files with
+// per-OS information, including constants named Goos$GOOS for every
+// known GOOS. The constant is 1 on the current system, 0 otherwise;
+// multiplying by them is useful for defining GOOS-specific constants.
+//go:generate go run gengoos.go
diff --git a/src/internal/goos/zgoos_aix.go b/src/internal/goos/zgoos_aix.go
new file mode 100644
index 0000000000..f453a8a0a8
--- /dev/null
+++ b/src/internal/goos/zgoos_aix.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build aix
+// +build aix
+
+package goos
+
+const GOOS = `aix`
+
+const GoosAix = 1
+const GoosAndroid = 0
+const GoosDarwin = 0
+const GoosDragonfly = 0
+const GoosFreebsd = 0
+const GoosHurd = 0
+const GoosIllumos = 0
+const GoosIos = 0
+const GoosJs = 0
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 0
+const GoosPlan9 = 0
+const GoosSolaris = 0
+const GoosWindows = 0
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_android.go b/src/internal/goos/zgoos_android.go
new file mode 100644
index 0000000000..d90c04f758
--- /dev/null
+++ b/src/internal/goos/zgoos_android.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build android
+// +build android
+
+package goos
+
+const GOOS = `android`
+
+const GoosAix = 0
+const GoosAndroid = 1
+const GoosDarwin = 0
+const GoosDragonfly = 0
+const GoosFreebsd = 0
+const GoosHurd = 0
+const GoosIllumos = 0
+const GoosIos = 0
+const GoosJs = 0
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 0
+const GoosPlan9 = 0
+const GoosSolaris = 0
+const GoosWindows = 0
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_darwin.go b/src/internal/goos/zgoos_darwin.go
new file mode 100644
index 0000000000..18f6c28b12
--- /dev/null
+++ b/src/internal/goos/zgoos_darwin.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build !ios && darwin
+// +build !ios,darwin
+
+package goos
+
+const GOOS = `darwin`
+
+const GoosAix = 0
+const GoosAndroid = 0
+const GoosDarwin = 1
+const GoosDragonfly = 0
+const GoosFreebsd = 0
+const GoosHurd = 0
+const GoosIllumos = 0
+const GoosIos = 0
+const GoosJs = 0
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 0
+const GoosPlan9 = 0
+const GoosSolaris = 0
+const GoosWindows = 0
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_dragonfly.go b/src/internal/goos/zgoos_dragonfly.go
new file mode 100644
index 0000000000..a658d1d07f
--- /dev/null
+++ b/src/internal/goos/zgoos_dragonfly.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build dragonfly
+// +build dragonfly
+
+package goos
+
+const GOOS = `dragonfly`
+
+const GoosAix = 0
+const GoosAndroid = 0
+const GoosDarwin = 0
+const GoosDragonfly = 1
+const GoosFreebsd = 0
+const GoosHurd = 0
+const GoosIllumos = 0
+const GoosIos = 0
+const GoosJs = 0
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 0
+const GoosPlan9 = 0
+const GoosSolaris = 0
+const GoosWindows = 0
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_freebsd.go b/src/internal/goos/zgoos_freebsd.go
new file mode 100644
index 0000000000..2534eb8c6f
--- /dev/null
+++ b/src/internal/goos/zgoos_freebsd.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build freebsd
+// +build freebsd
+
+package goos
+
+const GOOS = `freebsd`
+
+const GoosAix = 0
+const GoosAndroid = 0
+const GoosDarwin = 0
+const GoosDragonfly = 0
+const GoosFreebsd = 1
+const GoosHurd = 0
+const GoosIllumos = 0
+const GoosIos = 0
+const GoosJs = 0
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 0
+const GoosPlan9 = 0
+const GoosSolaris = 0
+const GoosWindows = 0
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_hurd.go b/src/internal/goos/zgoos_hurd.go
new file mode 100644
index 0000000000..3fefb1fbb1
--- /dev/null
+++ b/src/internal/goos/zgoos_hurd.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build hurd
+// +build hurd
+
+package goos
+
+const GOOS = `hurd`
+
+const GoosAix = 0
+const GoosAndroid = 0
+const GoosDarwin = 0
+const GoosDragonfly = 0
+const GoosFreebsd = 0
+const GoosHurd = 1
+const GoosIllumos = 0
+const GoosIos = 0
+const GoosJs = 0
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 0
+const GoosPlan9 = 0
+const GoosSolaris = 0
+const GoosWindows = 0
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_illumos.go b/src/internal/goos/zgoos_illumos.go
new file mode 100644
index 0000000000..77495a3369
--- /dev/null
+++ b/src/internal/goos/zgoos_illumos.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build illumos
+// +build illumos
+
+package goos
+
+const GOOS = `illumos`
+
+const GoosAix = 0
+const GoosAndroid = 0
+const GoosDarwin = 0
+const GoosDragonfly = 0
+const GoosFreebsd = 0
+const GoosHurd = 0
+const GoosIllumos = 1
+const GoosIos = 0
+const GoosJs = 0
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 0
+const GoosPlan9 = 0
+const GoosSolaris = 0
+const GoosWindows = 0
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_ios.go b/src/internal/goos/zgoos_ios.go
new file mode 100644
index 0000000000..92820fe77e
--- /dev/null
+++ b/src/internal/goos/zgoos_ios.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build ios
+// +build ios
+
+package goos
+
+const GOOS = `ios`
+
+const GoosAix = 0
+const GoosAndroid = 0
+const GoosDarwin = 0
+const GoosDragonfly = 0
+const GoosFreebsd = 0
+const GoosHurd = 0
+const GoosIllumos = 0
+const GoosIos = 1
+const GoosJs = 0
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 0
+const GoosPlan9 = 0
+const GoosSolaris = 0
+const GoosWindows = 0
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_js.go b/src/internal/goos/zgoos_js.go
new file mode 100644
index 0000000000..6331a5c3f1
--- /dev/null
+++ b/src/internal/goos/zgoos_js.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build js
+// +build js
+
+package goos
+
+const GOOS = `js`
+
+const GoosAix = 0
+const GoosAndroid = 0
+const GoosDarwin = 0
+const GoosDragonfly = 0
+const GoosFreebsd = 0
+const GoosHurd = 0
+const GoosIllumos = 0
+const GoosIos = 0
+const GoosJs = 1
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 0
+const GoosPlan9 = 0
+const GoosSolaris = 0
+const GoosWindows = 0
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_linux.go b/src/internal/goos/zgoos_linux.go
new file mode 100644
index 0000000000..aa4e2d3145
--- /dev/null
+++ b/src/internal/goos/zgoos_linux.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build !android && linux
+// +build !android,linux
+
+package goos
+
+const GOOS = `linux`
+
+const GoosAix = 0
+const GoosAndroid = 0
+const GoosDarwin = 0
+const GoosDragonfly = 0
+const GoosFreebsd = 0
+const GoosHurd = 0
+const GoosIllumos = 0
+const GoosIos = 0
+const GoosJs = 0
+const GoosLinux = 1
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 0
+const GoosPlan9 = 0
+const GoosSolaris = 0
+const GoosWindows = 0
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_netbsd.go b/src/internal/goos/zgoos_netbsd.go
new file mode 100644
index 0000000000..39635104c0
--- /dev/null
+++ b/src/internal/goos/zgoos_netbsd.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build netbsd
+// +build netbsd
+
+package goos
+
+const GOOS = `netbsd`
+
+const GoosAix = 0
+const GoosAndroid = 0
+const GoosDarwin = 0
+const GoosDragonfly = 0
+const GoosFreebsd = 0
+const GoosHurd = 0
+const GoosIllumos = 0
+const GoosIos = 0
+const GoosJs = 0
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 1
+const GoosOpenbsd = 0
+const GoosPlan9 = 0
+const GoosSolaris = 0
+const GoosWindows = 0
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_openbsd.go b/src/internal/goos/zgoos_openbsd.go
new file mode 100644
index 0000000000..61d4ac8bb0
--- /dev/null
+++ b/src/internal/goos/zgoos_openbsd.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build openbsd
+// +build openbsd
+
+package goos
+
+const GOOS = `openbsd`
+
+const GoosAix = 0
+const GoosAndroid = 0
+const GoosDarwin = 0
+const GoosDragonfly = 0
+const GoosFreebsd = 0
+const GoosHurd = 0
+const GoosIllumos = 0
+const GoosIos = 0
+const GoosJs = 0
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 1
+const GoosPlan9 = 0
+const GoosSolaris = 0
+const GoosWindows = 0
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_plan9.go b/src/internal/goos/zgoos_plan9.go
new file mode 100644
index 0000000000..7f0dc2fa04
--- /dev/null
+++ b/src/internal/goos/zgoos_plan9.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build plan9
+// +build plan9
+
+package goos
+
+const GOOS = `plan9`
+
+const GoosAix = 0
+const GoosAndroid = 0
+const GoosDarwin = 0
+const GoosDragonfly = 0
+const GoosFreebsd = 0
+const GoosHurd = 0
+const GoosIllumos = 0
+const GoosIos = 0
+const GoosJs = 0
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 0
+const GoosPlan9 = 1
+const GoosSolaris = 0
+const GoosWindows = 0
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_solaris.go b/src/internal/goos/zgoos_solaris.go
new file mode 100644
index 0000000000..7497324a4f
--- /dev/null
+++ b/src/internal/goos/zgoos_solaris.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build !illumos && solaris
+// +build !illumos,solaris
+
+package goos
+
+const GOOS = `solaris`
+
+const GoosAix = 0
+const GoosAndroid = 0
+const GoosDarwin = 0
+const GoosDragonfly = 0
+const GoosFreebsd = 0
+const GoosHurd = 0
+const GoosIllumos = 0
+const GoosIos = 0
+const GoosJs = 0
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 0
+const GoosPlan9 = 0
+const GoosSolaris = 1
+const GoosWindows = 0
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_windows.go b/src/internal/goos/zgoos_windows.go
new file mode 100644
index 0000000000..e316b80c82
--- /dev/null
+++ b/src/internal/goos/zgoos_windows.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build windows
+// +build windows
+
+package goos
+
+const GOOS = `windows`
+
+const GoosAix = 0
+const GoosAndroid = 0
+const GoosDarwin = 0
+const GoosDragonfly = 0
+const GoosFreebsd = 0
+const GoosHurd = 0
+const GoosIllumos = 0
+const GoosIos = 0
+const GoosJs = 0
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 0
+const GoosPlan9 = 0
+const GoosSolaris = 0
+const GoosWindows = 1
+const GoosZos = 0
diff --git a/src/internal/goos/zgoos_zos.go b/src/internal/goos/zgoos_zos.go
new file mode 100644
index 0000000000..26471f4f36
--- /dev/null
+++ b/src/internal/goos/zgoos_zos.go
@@ -0,0 +1,26 @@
+// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
+
+//go:build zos
+// +build zos
+
+package goos
+
+const GOOS = `zos`
+
+const GoosAix = 0
+const GoosAndroid = 0
+const GoosDarwin = 0
+const GoosDragonfly = 0
+const GoosFreebsd = 0
+const GoosHurd = 0
+const GoosIllumos = 0
+const GoosIos = 0
+const GoosJs = 0
+const GoosLinux = 0
+const GoosNacl = 0
+const GoosNetbsd = 0
+const GoosOpenbsd = 0
+const GoosPlan9 = 0
+const GoosSolaris = 0
+const GoosWindows = 0
+const GoosZos = 1