cmd/gomobile: init darwin/arm{,64} concurrently

Drops the time for `gomobile init` on my machine from 46s to 30s.

Change-Id: Iab89f2e1d1cee4b414dc2fb1c735b4167aef9036
Reviewed-on: https://go-review.googlesource.com/12641
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
David Crawshaw 2015-07-24 07:14:52 -04:00
parent bd8a095b54
commit 58652d815d
3 changed files with 6 additions and 2 deletions

View File

@ -44,7 +44,6 @@ func goIOSBind(pkg *build.Package) error {
cmd := exec.Command("xcrun", "lipo", "-create") cmd := exec.Command("xcrun", "lipo", "-create")
// TODO(crawshaw): Build in parallel.
for _, env := range [][]string{darwinArmEnv, darwinArm64Env, darwinAmd64Env} { for _, env := range [][]string{darwinArmEnv, darwinArm64Env, darwinAmd64Env} {
arch := archClang(getenv(env, "GOARCH")) arch := archClang(getenv(env, "GOARCH"))
path, err := goIOSBindArchive(name, mainFile, env) path, err := goIOSBindArchive(name, mainFile, env)

View File

@ -203,9 +203,12 @@ func init() {
} }
func goBuild(src string, env []string, args ...string) error { func goBuild(src string, env []string, args ...string) error {
// The -p flag is to speed up darwin/arm builds.
// Remove when golang.org/issue/10477 is resolved.
cmd := exec.Command( cmd := exec.Command(
"go", "go",
"build", "build",
fmt.Sprintf("-p=%d", runtime.NumCPU()),
"-pkgdir="+pkgdir(env), "-pkgdir="+pkgdir(env),
"-tags="+strconv.Quote(strings.Join(ctx.BuildTags, ",")), "-tags="+strconv.Quote(strings.Join(ctx.BuildTags, ",")),
) )

View File

@ -168,7 +168,9 @@ func installStd(env []string, args ...string) error {
fmt.Fprintf(os.Stderr, "\n# Building standard library for %s/%s.\n", tOS, tArch) fmt.Fprintf(os.Stderr, "\n# Building standard library for %s/%s.\n", tOS, tArch)
} }
cmd := exec.Command("go", "install", "-pkgdir="+pkgdir(env)) // The -p flag is to speed up darwin/arm builds.
// Remove when golang.org/issue/10477 is resolved.
cmd := exec.Command("go", "install", fmt.Sprintf("-p=%d", runtime.NumCPU()), "-pkgdir="+pkgdir(env))
cmd.Args = append(cmd.Args, args...) cmd.Args = append(cmd.Args, args...)
if buildV { if buildV {
cmd.Args = append(cmd.Args, "-v") cmd.Args = append(cmd.Args, "-v")