Commit 9aa630fa authored by Russ Cox's avatar Russ Cox

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/19618Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent fe5eac63
......@@ -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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment