mirror of
https://github.com/netbirdio/gomobile-tvos-fork.git
synced 2026-05-22 18:43:29 -07:00
cmd/gomobile: test for XCode in gomobile init
Previously, gomobile init assumed that the XCode developer tools were available when running on darwin. That is not always the case, in particular for Android developers on macOS. Replace the GOOS check with an explicit check for the xcrun binary. Change-Id: Ie5ae917288932cc641a17f904ed9822a105367cc Reviewed-on: https://go-review.googlesource.com/35852 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
@@ -14,7 +14,6 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -110,8 +109,8 @@ func runBuild(cmd *command) (err error) {
|
||||
}
|
||||
case "darwin":
|
||||
// TODO: use targetArchs?
|
||||
if runtime.GOOS != "darwin" {
|
||||
return fmt.Errorf("-target=ios requires darwin host")
|
||||
if !xcodeAvailable() {
|
||||
return fmt.Errorf("-target=ios requires XCode")
|
||||
}
|
||||
if pkg.Name != "main" {
|
||||
if err := goBuild(pkg.ImportPath, darwinArmEnv); err != nil {
|
||||
|
||||
+6
-1
@@ -149,7 +149,7 @@ func envInit() (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
if runtime.GOOS != "darwin" {
|
||||
if !xcodeAvailable() {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -378,3 +378,8 @@ var ndk = ndkConfig{
|
||||
minGoVer: go1_6,
|
||||
},
|
||||
}
|
||||
|
||||
func xcodeAvailable() bool {
|
||||
_, err := exec.LookPath("xcrun")
|
||||
return err == nil
|
||||
}
|
||||
|
||||
@@ -315,8 +315,8 @@ var commonPkgs = []string{
|
||||
}
|
||||
|
||||
func installDarwin() error {
|
||||
if goos != "darwin" {
|
||||
return nil // Only build iOS compilers on OS X.
|
||||
if !xcodeAvailable() {
|
||||
return nil
|
||||
}
|
||||
if err := installStd(darwinArmEnv); err != nil {
|
||||
return err
|
||||
|
||||
@@ -51,7 +51,7 @@ func runVersion(cmd *command) (err error) {
|
||||
|
||||
// Supported platforms
|
||||
platforms := "android"
|
||||
if goos == "darwin" {
|
||||
if xcodeAvailable() {
|
||||
platforms = "android,ios"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user