Merge remote-tracking branch 'aosp/upstream' into master
* aosp/upstream:
Workaround gimme not setting GOROOT
Export GOROOT for minibp / primary builder
Support parallel Go compiles with Go 1.9
Fix build on Go 1.9
Test: m -j nothing with Go 1.8
Test: m -j nothing with Go 1.9rc1
Change-Id: Ib47750adc88728be8c1f3e8d27364ed652204d82
diff --git a/.travis.yml b/.travis.yml
index 201816e..f616ff8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,6 +2,7 @@
go:
- 1.8.3
+ - 1.9rc1
cache:
directories:
@@ -15,6 +16,7 @@
- source .travis.fix-fork.sh
script:
+ - export GOROOT=$(go env GOROOT)
- ./.travis.gofmt.sh
- go test ./...
- ./tests/test.sh
diff --git a/blueprint_impl.bash b/blueprint_impl.bash
index 0c5d4b9..0570f94 100644
--- a/blueprint_impl.bash
+++ b/blueprint_impl.bash
@@ -3,6 +3,8 @@
exit 1
fi
+export GOROOT
+
source "${BLUEPRINTDIR}/microfactory/microfactory.bash"
BUILDDIR="${BUILDDIR}/.minibootstrap" build_go minibp github.com/google/blueprint/bootstrap/minibp
diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go
index 365d0ee..25e5d39 100644
--- a/bootstrap/bootstrap.go
+++ b/bootstrap/bootstrap.go
@@ -16,6 +16,7 @@
import (
"fmt"
+ "go/build"
"path/filepath"
"runtime"
"strings"
@@ -34,10 +35,20 @@
goTestRunnerCmd = pctx.StaticVariable("goTestRunnerCmd", filepath.Join(bootstrapDir, "bin", "gotestrunner"))
pluginGenSrcCmd = pctx.StaticVariable("pluginGenSrcCmd", filepath.Join(bootstrapDir, "bin", "loadplugins"))
+ parallelCompile = pctx.StaticVariable("parallelCompile", func() string {
+ // Parallel compilation is only supported on >= go1.9
+ for _, r := range build.Default.ReleaseTags {
+ if r == "go1.9" {
+ return fmt.Sprintf("-c %d", runtime.NumCPU())
+ }
+ }
+ return ""
+ }())
+
compile = pctx.StaticRule("compile",
blueprint.RuleParams{
- Command: "GOROOT='$goRoot' $compileCmd -o $out -p $pkgPath -complete " +
- "$incFlags -pack $in",
+ Command: "GOROOT='$goRoot' $compileCmd $parallelCompile -o $out " +
+ "-p $pkgPath -complete $incFlags -pack $in",
CommandDeps: []string{"$compileCmd"},
Description: "compile $out",
},
diff --git a/gotestmain/gotestmain.go b/gotestmain/gotestmain.go
index 9bf78b5..8f914c0 100644
--- a/gotestmain/gotestmain.go
+++ b/gotestmain/gotestmain.go
@@ -156,6 +156,10 @@
panic("shouldn't get here")
}
+func (matchString) ImportPath() string {
+ return "{{.Package}}"
+}
+
func main() {
{{if .MainStartTakesInterface}}
m := testing.MainStart(matchString{}, t, nil, nil)
diff --git a/microfactory/microfactory.go b/microfactory/microfactory.go
index 19f0a0c..e8c6f22 100644
--- a/microfactory/microfactory.go
+++ b/microfactory/microfactory.go
@@ -69,6 +69,7 @@
goToolDir = filepath.Join(runtime.GOROOT(), "pkg", "tool", runtime.GOOS+"_"+runtime.GOARCH)
goVersion = findGoVersion()
+ isGo18 = strings.Contains(goVersion, "go1.8")
)
func findGoVersion() string {
@@ -276,6 +277,9 @@
"-o", p.output,
"-p", p.Name,
"-complete", "-pack", "-nolocalimports")
+ if !isGo18 {
+ cmd.Args = append(cmd.Args, "-c", fmt.Sprintf("%d", runtime.NumCPU()))
+ }
if race {
cmd.Args = append(cmd.Args, "-race")
fmt.Fprintln(hash, "-race")