]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: build exec wrappers during bootstrap
authorElias Naur <mail@eliasnaur.com>
Sun, 24 Feb 2019 12:18:13 +0000 (13:18 +0100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 26 Feb 2019 17:59:23 +0000 (17:59 +0000)
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>
src/androidtest.bash
src/cmd/dist/build.go
src/iostest.bash

index e43b89c0dcadc5957fd46589e330736f3383b466..12f240cc5807e56447302c11c62324f8583dc857 100755 (executable)
@@ -31,14 +31,11 @@ fi
 export CGO_ENABLED=1
 unset GOBIN
 
-# Do the build first, so we can build go_android_exec and cleaner.
+# Do the build first, so we can build the 'cleaner' binary.
 # Also lets us fail early before the (slow) adb push if the build is broken.
 . ./make.bash --no-banner
 export GOROOT=$(dirname $(pwd))
 export PATH=$GOROOT/bin:$PATH
-GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go build \
-       -o ../bin/go_android_${GOARCH}_exec \
-       ../misc/android/go_android_exec.go
 
 export pkgdir=$(dirname $(go list -f '{{.Target}}' runtime))
 if [ "$pkgdir" = "" ]; then
index ad2c96436a069d3510ba0cc191b44994891ca5b5..6388e3e86328720e0b3872bf448155cacf89a3fe 100644 (file)
@@ -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")
        }
index b402ff0792c3a338aed8d670f8c55b4bc99840f5..1fc1666bae221869ab55269dbbe0f3f3c5993f5e 100755 (executable)
@@ -56,14 +56,10 @@ export PATH=$GOROOT/bin:$PATH
 export CGO_ENABLED=1
 export CC_FOR_TARGET=$GOROOT/misc/ios/clangwrap.sh
 
-# Run the build for the host bootstrap, so we can build go_darwin_arm_exec.
+# Run the build for the host bootstrap, so we can build detect.go.
 # Also lets us fail early before the (slow) ios-deploy if the build is broken.
 ./make.bash
 
-GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go build \
-       -o ../bin/go_darwin_${GOARCH}_exec \
-       ../misc/ios/go_darwin_arm_exec.go
-
 if [ "$GOIOS_DEV_ID" = "" ]; then
        echo "detecting iOS development identity"
        eval $(GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go run ../misc/ios/detect.go)