diff options
| author | Elias Naur <mail@eliasnaur.com> | 2019-02-24 13:18:13 +0100 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2019-02-26 17:59:23 +0000 |
| commit | da2d02a9356f2d808992990510eca2b26513be0c (patch) | |
| tree | d8dcafc1ad0377ee711e07bfa85cc7a9f58ae365 /src/cmd/dist | |
| parent | 42a82ce1a7051b3a2762bff73b6eda4797e0fd4b (diff) | |
| download | go-da2d02a9356f2d808992990510eca2b26513be0c.tar.xz | |
cmd/dist: build exec wrappers during bootstrap
The androidtest.bash script encodes the additional steps to build
Go and run tests on Android. In order to add sharded builders and
trybots, Android needs to fit into the usual make.bash + cmd/dist test
pattern.
This change moves building the exec wrapper into cmd/dist bootstrap.
Do the same for iOS while we're here.
Updates #23824
Change-Id: I58a1b0679c3a6c92fdc7fff464b469641f1fee74
Reviewed-on: https://go-review.googlesource.com/c/163618
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/cmd/dist')
| -rw-r--r-- | src/cmd/dist/build.go | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index ad2c96436a..6388e3e863 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -1366,14 +1366,42 @@ func cmdbootstrap() { // Remove go_bootstrap now that we're done. xremove(pathf("%s/go_bootstrap", tooldir)) + // Build the exec wrapper if necessary. + if wrapperPath := wrapperPathFor(goos, goarch); wrapperPath != "" { + oldcc := os.Getenv("CC") + os.Setenv("GOOS", gohostos) + os.Setenv("GOARCH", gohostarch) + os.Setenv("CC", compilerEnvLookup(defaultcc, gohostos, gohostarch)) + goCmd(cmdGo, "build", "-o", pathf("%s/go_%s_%s_exec%s", gobin, goos, goarch, exe), wrapperPath) + // Restore environment. + // TODO(elias.naur): support environment variables in goCmd? + os.Setenv("GOOS", goos) + os.Setenv("GOARCH", goarch) + os.Setenv("CC", oldcc) + } + // Print trailing banner unless instructed otherwise. if !noBanner { banner() } } +func wrapperPathFor(goos, goarch string) string { + switch { + case goos == "android": + return pathf("%s/misc/android/go_android_exec.go", goroot) + case goos == "darwin" && (goarch == "arm" || goarch == "arm64"): + return pathf("%s/misc/ios/go_darwin_arm_exec.go", goroot) + } + return "" +} + func goInstall(goBinary string, args ...string) { - installCmd := []string{goBinary, "install", "-gcflags=all=" + gogcflags, "-ldflags=all=" + goldflags} + goCmd(goBinary, "install", args...) +} + +func goCmd(goBinary string, cmd string, args ...string) { + installCmd := []string{goBinary, cmd, "-gcflags=all=" + gogcflags, "-ldflags=all=" + goldflags} if vflag > 0 { installCmd = append(installCmd, "-v") } |
