Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

language/go: Handle unix build tag. #1512

Merged
merged 2 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions language/go/fileinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ func matchesOS(os, value string) bool {
if os == value {
return true
}
if value == "unix" {
return rule.UnixOS[os]
}
for _, alias := range rule.OSAliases[os] {
if alias == value {
return true
Expand Down Expand Up @@ -556,8 +559,7 @@ func checkConstraints(c *config.Config, os, arch, osSuffix, archSuffix string, t
if isIgnoredTag(tag) {
return true
}

if _, ok := rule.KnownOSSet[tag]; ok {
if _, ok := rule.KnownOSSet[tag]; ok || tag == "unix" {
if os == "" {
return false
}
Expand Down
17 changes: 17 additions & 0 deletions rule/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ var OSAliases = map[string][]string{
"ios": {"darwin"},
}

// UnixOS is the set of GOOS values matched by the "unix" build tag.
// This list is from go/src/cmd/dist/build.go.
var UnixOS = map[string]bool{
"aix": true,
"android": true,
"darwin": true,
"dragonfly": true,
"freebsd": true,
"hurd": true,
"illumos": true,
"ios": true,
"linux": true,
"netbsd": true,
"openbsd": true,
"solaris": true,
}

var (
// KnownOSs is the sorted list of operating systems that Go supports.
KnownOSs []string
Expand Down