mirror of
https://github.com/golang/go
synced 2024-11-18 16:04:44 -07:00
go/packages: fix nocgo build
We need the hasGoBuild function outside cgo files now. Change-Id: Ic34134b78bd658728ffe4488d42e552896d863cb Reviewed-on: https://go-review.googlesource.com/c/tools/+/233838 Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
0951661448
commit
d5fe73897c
@ -2768,3 +2768,25 @@ func copyAll(srcPath, dstPath string) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Stolen from internal/testenv package in core.
|
||||
// hasGoBuild reports whether the current system can build programs with ``go build''
|
||||
// and then run them with os.StartProcess or exec.Command.
|
||||
func hasGoBuild() bool {
|
||||
if os.Getenv("GO_GCFLAGS") != "" {
|
||||
// It's too much work to require every caller of the go command
|
||||
// to pass along "-gcflags="+os.Getenv("GO_GCFLAGS").
|
||||
// For now, if $GO_GCFLAGS is set, report that we simply can't
|
||||
// run go build.
|
||||
return false
|
||||
}
|
||||
switch runtime.GOOS {
|
||||
case "android", "js":
|
||||
return false
|
||||
case "darwin":
|
||||
if strings.HasPrefix(runtime.GOARCH, "arm") {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -69,28 +69,6 @@ func TestLoadImportsC(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Stolen from internal/testenv package in core.
|
||||
// hasGoBuild reports whether the current system can build programs with ``go build''
|
||||
// and then run them with os.StartProcess or exec.Command.
|
||||
func hasGoBuild() bool {
|
||||
if os.Getenv("GO_GCFLAGS") != "" {
|
||||
// It's too much work to require every caller of the go command
|
||||
// to pass along "-gcflags="+os.Getenv("GO_GCFLAGS").
|
||||
// For now, if $GO_GCFLAGS is set, report that we simply can't
|
||||
// run go build.
|
||||
return false
|
||||
}
|
||||
switch runtime.GOOS {
|
||||
case "android", "js":
|
||||
return false
|
||||
case "darwin":
|
||||
if strings.HasPrefix(runtime.GOARCH, "arm") {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func TestCgoNoSyntax(t *testing.T) {
|
||||
packagestest.TestAll(t, testCgoNoSyntax)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user