2
0
mirror of synced 2025-02-23 14:58:12 +00:00

cmd/gomobile: fix a bug in handling -target=ios flag value

When -target=ios, GOOS must be 'darwin'.

Fixes golang/go#13670

Change-Id: Ie20db14cf24d886e13d9fe2e70caa0308790ad87
Reviewed-on: https://go-review.googlesource.com/18042
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
Hyang-Ah (Hana) Kim 2015-12-18 12:04:02 -05:00 committed by Hyang-Ah Hana Kim
parent c897050410
commit 4f51fe273b
3 changed files with 14 additions and 10 deletions

View File

@ -97,10 +97,10 @@ func runBind(cmd *command) error {
return err
}
switch buildTarget {
switch targetOS {
case "android":
return goAndroidBind(pkgs, targetArchs)
case "ios":
case "darwin":
// TODO: use targetArchs?
return goIOSBind(pkgs)
default:

View File

@ -106,7 +106,7 @@ func runBuild(cmd *command) (err error) {
if err != nil {
return err
}
case "ios":
case "darwin":
// TODO: use targetArchs?
if runtime.GOOS != "darwin" {
return fmt.Errorf("-target=ios requires darwin host")
@ -357,8 +357,12 @@ func parseBuildTarget(buildTarget string) (os string, archs []string, _ error) {
archs = append(archs, arch)
}
if all {
return os, supported, nil
targetOS := os
if os == "ios" {
targetOS = "darwin"
}
return os, archs, nil
if all {
return targetOS, supported, nil
}
return targetOS, archs, nil
}

View File

@ -117,10 +117,10 @@ func TestParseBuildTargetFlag(t *testing.T) {
{"android,android/arm", false, "android", androidArchs},
{"android/arm", false, "android", "arm"},
{"ios", false, "ios", iosArchs},
{"ios,ios/arm", false, "ios", iosArchs},
{"ios/arm", false, "ios", "arm"},
{"ios/amd64", false, "ios", "amd64"},
{"ios", false, "darwin", iosArchs},
{"ios,ios/arm", false, "darwin", iosArchs},
{"ios/arm", false, "darwin", "arm"},
{"ios/amd64", false, "darwin", "amd64"},
{"", true, "", ""},
{"linux", true, "", ""},