From 299b40b86dc4d71a269f063603c6654c56de6b80 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 12 Apr 2018 20:33:47 +0200 Subject: [PATCH] misc/ios: speed up the iOS exec wrapper First, take the exclusive lock that ensures only one running binary later: after assembling the gotest.app directory and signing it. Second, don't pass -r to ios-deploy. The -r flag uninstalls the app before installing it. It seems unnecessary, takes extra time and if there was only the one developer app on the phone, it will drop the developer permission on uninstall. Change-Id: Ia222d3e5c2e1e2285f53074eb952941fd45fadd9 Reviewed-on: https://go-review.googlesource.com/106676 Reviewed-by: Hyang-Ah Hana Kim --- misc/ios/go_darwin_arm_exec.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/misc/ios/go_darwin_arm_exec.go b/misc/ios/go_darwin_arm_exec.go index 20318ba169..5ba0299bad 100644 --- a/misc/ios/go_darwin_arm_exec.go +++ b/misc/ios/go_darwin_arm_exec.go @@ -94,6 +94,13 @@ func main() { log.Fatal(err) } + appdir := filepath.Join(tmpdir, "gotest.app") + os.RemoveAll(appdir) + + if err := assembleApp(appdir, os.Args[1]); err != nil { + log.Fatal(err) + } + // This wrapper uses complicated machinery to run iOS binaries. It // works, but only when running one binary at a time. // Use a file lock to make sure only one wrapper is running at a time. @@ -108,6 +115,7 @@ func main() { if err := syscall.Flock(int(lock.Fd()), syscall.LOCK_EX); err != nil { log.Fatal(err) } + // Approximately 1 in a 100 binaries fail to start. If it happens, // try again. These failures happen for several reasons beyond // our control, but all of them are safe to retry as they happen @@ -118,7 +126,7 @@ func main() { if i > 0 { fmt.Fprintln(os.Stderr, "start timeout, trying again") } - err = run(os.Args[1], os.Args[2:]) + err = run(appdir, os.Args[2:]) if err == nil || err != errRetry { break } @@ -140,9 +148,7 @@ func getenv(envvar string) string { return s } -func run(bin string, args []string) (err error) { - appdir := filepath.Join(tmpdir, "gotest.app") - os.RemoveAll(appdir) +func assembleApp(appdir, bin string) error { if err := os.MkdirAll(appdir, 0755); err != nil { return err } @@ -182,7 +188,10 @@ func run(bin string, args []string) (err error) { if err := cmd.Run(); err != nil { return fmt.Errorf("codesign: %v", err) } + return nil +} +func run(appdir string, args []string) (err error) { oldwd, err := os.Getwd() if err != nil { return err @@ -317,7 +326,6 @@ func newSession(appdir string, args []string, opts options) (*lldbSession, error iosdPath, "--debug", "-u", - "-r", "-n", `--args=` + strings.Join(args, " ") + ``, "--bundle", appdir,