1
0
mirror of https://github.com/golang/go synced 2024-11-24 20:40:23 -07:00

cmd/dist: accept "//+build" with no spaces, like go/build

The go/build parser accepts "//+build", with no spaces.
Make the cmd/dist bootstrap parser do the same.
While in theory we should always use the space form,
I copied some code that did not into the standard tree,
and I was very confused that 'go test' had had no problem
but then make.bash died.

(As a reminder, cmd/dist does not use go/build because
cmd/dist must build against earlier versions of Go.)

Change-Id: I90a18014bd878247b8811487e5c1a7589260cbfc
Reviewed-on: https://go-review.googlesource.com/19618
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Russ Cox 2016-02-08 07:08:14 -05:00
parent fe5eac63c4
commit 9aa630faa8

17
src/cmd/dist/build.go vendored
View File

@ -754,7 +754,7 @@ func matchtag(tag string) bool {
}
return !matchtag(tag[1:])
}
return tag == goos || tag == goarch || tag == "cmd_go_bootstrap" || tag == "go1.1" || (goos == "android" && tag == "linux")
return tag == "gc" || tag == goos || tag == goarch || tag == "cmd_go_bootstrap" || tag == "go1.1" || (goos == "android" && tag == "linux")
}
// shouldbuild reports whether we should build this file.
@ -798,10 +798,15 @@ func shouldbuild(file, dir string) bool {
if p == "" {
continue
}
if strings.Contains(p, "package documentation") {
code := p
i := strings.Index(code, "//")
if i > 0 {
code = strings.TrimSpace(code[:i])
}
if code == "package documentation" {
return false
}
if strings.Contains(p, "package main") && dir != "cmd/go" && dir != "cmd/cgo" {
if code == "package main" && dir != "cmd/go" && dir != "cmd/cgo" {
return false
}
if !strings.HasPrefix(p, "//") {
@ -810,11 +815,11 @@ func shouldbuild(file, dir string) bool {
if !strings.Contains(p, "+build") {
continue
}
fields := splitfields(p)
if len(fields) < 2 || fields[1] != "+build" {
fields := splitfields(p[2:])
if len(fields) < 1 || fields[0] != "+build" {
continue
}
for _, p := range fields[2:] {
for _, p := range fields[1:] {
if matchfield(p) {
goto fieldmatch
}