diff options
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java | 29 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolTransition.java | 5 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java index 612d2b3e3a..bba468d3a2 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java @@ -15,6 +15,7 @@ package com.google.devtools.build.lib.rules.apple; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.Multimap; import com.google.devtools.build.lib.analysis.config.BuildConfiguration.DefaultLabelConverter; @@ -286,6 +287,34 @@ public class AppleCommandLineOptions extends FragmentOptions { return Platform.forTarget(PlatformType.IOS, iosCpu); } + /** + * Returns the architecture implied by these options. + * + * <p> In contexts in which a configuration instance is present, prefer + * {@link AppleConfiguration#getSingleArchitecture}. + */ + public String getSingleArchitecture() { + if (!Strings.isNullOrEmpty(appleSplitCpu)) { + return appleSplitCpu; + } + switch (applePlatformType) { + case IOS: + if (!iosMultiCpus.isEmpty()) { + return iosMultiCpus.get(0); + } else { + return iosCpu; + } + case WATCHOS: + return watchosCpus.get(0); + case TVOS: + return tvosCpus.get(0); + case MACOS: + return macosCpus.get(0); + default: + throw new IllegalArgumentException("Unhandled platform type " + applePlatformType); + } + } + @Override public void addAllLabels(Multimap<String, Label> labelMap) { if (getPlatform() == Platform.IOS_DEVICE) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolTransition.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolTransition.java index 953329563c..38c79dd84a 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolTransition.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolTransition.java @@ -53,7 +53,10 @@ public class AppleCrosstoolTransition implements PatchTransition { // TODO(b/29355778): Once ios_cpu is retired, introduce another top-level flag (perhaps // --apple_cpu) for toolchain selection in top-level consuming rules. - String cpu = "ios_" + buildOptions.get(AppleCommandLineOptions.class).iosCpu; + String cpu = String.format("%s_%s", + buildOptions.get(AppleCommandLineOptions.class).applePlatformType, + buildOptions.get(AppleCommandLineOptions.class).getSingleArchitecture()); + setAppleCrosstoolTransitionConfiguration(buildOptions, result, cpu); return result; } |