cmd: replace goBin() with a plain string "go"
This was introduced at https://go-review.googlesource.com/c/mobile/+/191518 originally, but this change was against the decision at golang/go#26845. "go" always works even when Go command that name is not "go", like "go1.14beta1" is used. See also the discussion at golang/go#28043 Change-Id: Ifebe969edaeda0373b2840d25a4f4030509176fa Reviewed-on: https://go-review.googlesource.com/c/mobile/+/214898 Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
Родитель
b9f03b3fa3
Коммит
56347cccba
|
@ -78,7 +78,7 @@ func testMain(m *testing.M) int {
|
|||
bin.Close()
|
||||
defer os.Remove(bin.Name())
|
||||
if runtime.GOOS != "android" {
|
||||
if out, err := exec.Command(goBin(), "build", "-o", bin.Name(), "golang.org/x/mobile/cmd/gobind").CombinedOutput(); err != nil {
|
||||
if out, err := exec.Command("go", "build", "-o", bin.Name(), "golang.org/x/mobile/cmd/gobind").CombinedOutput(); err != nil {
|
||||
log.Fatalf("gobind build failed: %v: %s", err, out)
|
||||
}
|
||||
gobindBin = bin.Name()
|
||||
|
|
|
@ -15,7 +15,6 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/mobile/internal/importers"
|
||||
|
@ -45,10 +44,6 @@ func main() {
|
|||
os.Exit(exitStatus)
|
||||
}
|
||||
|
||||
func goBin() string {
|
||||
return filepath.Join(runtime.GOROOT(), "bin", "go")
|
||||
}
|
||||
|
||||
func run() {
|
||||
var langs []string
|
||||
if *lang != "" {
|
||||
|
@ -129,7 +124,7 @@ func run() {
|
|||
// Add a new directory to GOPATH where the file for reverse bindings exist, and recreate allPkg.
|
||||
// It is because the current allPkg did not solve imports for reverse bindings.
|
||||
var gopath string
|
||||
if out, err := exec.Command(goBin(), "env", "GOPATH").Output(); err != nil {
|
||||
if out, err := exec.Command("go", "env", "GOPATH").Output(); err != nil {
|
||||
log.Fatal(err)
|
||||
} else {
|
||||
gopath = string(bytes.TrimSpace(out))
|
||||
|
|
|
@ -227,7 +227,7 @@ func packagesConfig(targetOS string) *packages.Config {
|
|||
|
||||
// getModuleVersions returns a module information at the directory src.
|
||||
func getModuleVersions(targetOS string, targetArch string, src string) (*modfile.File, error) {
|
||||
cmd := exec.Command(goBin(), "list")
|
||||
cmd := exec.Command("go", "list")
|
||||
cmd.Env = append(os.Environ(), "GOOS="+targetOS, "GOARCH="+targetArch)
|
||||
|
||||
tags := buildTags
|
||||
|
@ -308,7 +308,7 @@ func writeGoMod(targetOS string, targetArch string) error {
|
|||
}
|
||||
|
||||
func areGoModulesUsed() (bool, error) {
|
||||
out, err := exec.Command(goBin(), "env", "GOMOD").Output()
|
||||
out, err := exec.Command("go", "env", "GOMOD").Output()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
|
|
@ -207,10 +207,10 @@ func TestBindWithGoModules(t *testing.T) {
|
|||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
if out, err := exec.Command(goBin(), "build", "-o="+dir, "golang.org/x/mobile/cmd/gobind").CombinedOutput(); err != nil {
|
||||
if out, err := exec.Command("go", "build", "-o="+dir, "golang.org/x/mobile/cmd/gobind").CombinedOutput(); err != nil {
|
||||
t.Fatalf("%v: %s", err, string(out))
|
||||
}
|
||||
if out, err := exec.Command(goBin(), "build", "-o="+dir, "golang.org/x/mobile/cmd/gomobile").CombinedOutput(); err != nil {
|
||||
if out, err := exec.Command("go", "build", "-o="+dir, "golang.org/x/mobile/cmd/gomobile").CombinedOutput(); err != nil {
|
||||
t.Fatalf("%v: %s", err, string(out))
|
||||
}
|
||||
path := dir
|
||||
|
|
|
@ -296,10 +296,7 @@ func goCmd(subcmd string, srcs []string, env []string, args ...string) error {
|
|||
}
|
||||
|
||||
func goCmdAt(at string, subcmd string, srcs []string, env []string, args ...string) error {
|
||||
cmd := exec.Command(
|
||||
goBin(),
|
||||
subcmd,
|
||||
)
|
||||
cmd := exec.Command("go", subcmd)
|
||||
tags := buildTags
|
||||
targetOS, _, err := parseBuildTarget(buildTarget)
|
||||
if err != nil {
|
||||
|
|
|
@ -321,7 +321,7 @@ func goEnv(name string) string {
|
|||
if val := os.Getenv(name); val != "" {
|
||||
return val
|
||||
}
|
||||
val, err := exec.Command(goBin(), "env", name).Output()
|
||||
val, err := exec.Command("go", "env", name).Output()
|
||||
if err != nil {
|
||||
panic(err) // the Go tool was tested to work earlier
|
||||
}
|
||||
|
@ -338,12 +338,7 @@ func runCmd(cmd *exec.Cmd) error {
|
|||
if env != "" {
|
||||
env += " "
|
||||
}
|
||||
args := make([]string, len(cmd.Args))
|
||||
copy(args, cmd.Args)
|
||||
if args[0] == goBin() {
|
||||
args[0] = "go"
|
||||
}
|
||||
printcmd("%s%s%s", dir, env, strings.Join(args, " "))
|
||||
printcmd("%s%s%s", dir, env, strings.Join(cmd.Args, " "))
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
|
|
|
@ -18,8 +18,6 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
@ -86,12 +84,8 @@ func main() {
|
|||
os.Exit(2)
|
||||
}
|
||||
|
||||
func goBin() string {
|
||||
return filepath.Join(runtime.GOROOT(), "bin", "go")
|
||||
}
|
||||
|
||||
func determineGoVersion() error {
|
||||
goVersionOut, err := exec.Command(goBin(), "version").CombinedOutput()
|
||||
goVersionOut, err := exec.Command("go", "version").CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("'go version' failed: %v, %s", err, goVersionOut)
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ func runVersion(cmd *command) (err error) {
|
|||
return "", err
|
||||
}
|
||||
bindir := filepath.Dir(bin)
|
||||
cmd := exec.Command(goBin(), "list", "-f", "{{.Stale}}", "golang.org/x/mobile/cmd/gomobile")
|
||||
cmd := exec.Command("go", "list", "-f", "{{.Stale}}", "golang.org/x/mobile/cmd/gomobile")
|
||||
cmd.Env = append(os.Environ(), "GOBIN="+bindir)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
@ -64,7 +64,7 @@ func runVersion(cmd *command) (err error) {
|
|||
}
|
||||
|
||||
func mobileRepoRevision() (rev string, err error) {
|
||||
b, err := exec.Command(goBin(), "list", "-f", "{{.Dir}}", "golang.org/x/mobile/app").CombinedOutput()
|
||||
b, err := exec.Command("go", "list", "-f", "{{.Dir}}", "golang.org/x/mobile/app").CombinedOutput()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("mobile repo not found: %v, %s", err, b)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче