aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java132
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java47
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java32
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java8
10 files changed, 166 insertions, 74 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 02dc3727af..a691d9bbf9 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
@@ -171,11 +171,11 @@ public class AppleCommandLineOptions extends FragmentOptions {
private Platform getPlatform() {
for (String architecture : iosMultiCpus) {
- if (Platform.forIosArch(architecture) == Platform.IOS_DEVICE) {
+ if (Platform.forTarget(PlatformType.IOS, architecture) == Platform.IOS_DEVICE) {
return Platform.IOS_DEVICE;
}
}
- return Platform.forIosArch(iosCpu);
+ return Platform.forTarget(PlatformType.IOS, iosCpu);
}
@Override
diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java
index 01252de602..9fc38f0d12 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java
@@ -16,6 +16,7 @@ package com.google.devtools.build.lib.rules.apple;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
+import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -220,39 +221,136 @@ public class AppleConfiguration extends BuildConfiguration.Fragment {
}
/**
- * Returns the {@link Platform} represented by {@code ios_cpu} (see {@link #getIosCpu}.
- * (For example, {@code i386} maps to {@link Platform#IOS_SIMULATOR}.) Note that this is not
- * necessarily the effective platform for all ios actions in the current context: This is
- * typically the correct platform for implicityly-ios compile and link actions in the current
- * context. For effective platform for bundling actions, see {@link #getBundlingPlatform}.
+ * Gets the single "effective" architecture for the given {@link PlatformType}. Prefer this over
+ * {@link #getArchitectures(PlatformType)} only in cases if in the context of a rule which
+ * is only concerned with a single architecture (such as {@code objc_library}, which registers
+ * single-architecture compile actions.
+ *
+ * <p>Single effective architecture is determined using the following rules:
+ * <ol>
+ * <li>If {@code --apple_split_cpu} is set (done via prior configuration transition), then
+ * that is the effective architecture.</li>
+ * <li>In the case of iOS, use {@code --ios_cpu}.</li>
+ * <li>Use the default.</li></ol>
+ *
+ * @throws IllegalArgumentException if {@code --apple_platform_type} is set (via prior
+ * configuration transition) yet does not match {@code platformType}
*/
- @SkylarkCallable(name = "ios_cpu_platform", doc = "The platform given by the ios_cpu flag.")
- public Platform getIosCpuPlatform() {
- return Platform.forIosArch(getIosCpu());
+ // TODO(cparsons): Support platform types other than iOS.
+ // TODO(b/28958783): Consider changing this behavior to be more consistent between single and
+ // multi-arch cases.
+ public String getSingleArchitecture(PlatformType platformType) {
+ if (!Strings.isNullOrEmpty(appleSplitCpu)) {
+ if (applePlatformType != platformType) {
+ throw new IllegalArgumentException(
+ String.format("Expected post-split-transition platform type %s to match input %s ",
+ applePlatformType, platformType));
+ }
+ return appleSplitCpu;
+ }
+ switch (platformType) {
+ case IOS:
+ return getIosCpu();
+ // TODO(cparsons): Support other platform types.
+ default:
+ throw new IllegalArgumentException("Unhandled platform type " + platformType);
+ }
+ }
+
+ /**
+ * Gets the "effective" architecture(s) for the given {@link PlatformType}. For example,
+ * "i386" or "arm64". At least one architecture is always returned.
+ *
+ * <p>Effective architecture(s) is determined using the following rules:
+ * <ol>
+ * <li>If {@code --apple_split_cpu} is set (done via prior configuration transition), then
+ * that is the effective architecture.</li>
+ * <li>If the multi-cpu flag (for example, {@code --ios_multi_cpus}) is non-empty, then, return
+ * all architectures from that flag.</li>
+ * <li>In the case of iOS, use {@code --ios_cpu} for backwards compatibility.</li>
+ * <li>Use the default.</li></ol>
+ *
+ * @throws IllegalArgumentException if {@code --apple_platform_type} is set (via prior
+ * configuration transition) yet does not match {@code platformType}
+ */
+ public List<String> getArchitectures(PlatformType platformType) {
+ if (!Strings.isNullOrEmpty(appleSplitCpu)) {
+ if (applePlatformType != platformType) {
+ throw new IllegalArgumentException(
+ String.format("Expected post-split-transition platform type %s to match input %s ",
+ applePlatformType, platformType));
+ }
+ return ImmutableList.of(appleSplitCpu);
+ }
+ switch (platformType) {
+ case IOS:
+ if (getIosMultiCpus().isEmpty()) {
+ return ImmutableList.of(getIosCpu());
+ } else {
+ return getIosMultiCpus();
+ }
+ // TODO(cparsons): Support other platform types.
+ default:
+ throw new IllegalArgumentException("Unhandled platform type " + platformType);
+ }
+ }
+
+ /**
+ * Gets the current configuration {@link Platform} for the given {@link PlatformType}. Platform
+ * is determined via a combination between the given platform type and the "effective
+ * architecture" of this configuration, as returned by {@link #getArchitectures}. If there
+ * are multiple effective architectures, the first in the list will be used. (This handles
+ * cases where multiple architectures may be specified, for example via multi-cpu flag, though
+ * only one can be consumed for the current rule.) Consider {@link #getBundlingPlatform} as an
+ * alternative, when more than one architecture may be expected.
+ */
+ public Platform getPlatform(PlatformType platformType) {
+ return Platform.forTarget(platformType, getSingleArchitecture(platformType));
}
/**
- * Returns the platform of the configuration for the current bundle, based on configured
- * architectures (for example, {@code i386} maps to {@link Platform#IOS_SIMULATOR}).
+ * Returns the platform of the configuration for the current bundle for {@link PlatformType#IOS}
+ * platform type, based on configured "effective" architectures (for example, {@code i386} maps
+ * to {@link Platform#IOS_SIMULATOR}).
+ *
+ * <p>Effective architecture(s) are determined via {@link #getArchitectures}. If there are
+ * multiple effective architectures, then returns {@link Platform#IOS_DEVICE} if any of the
+ * architectures matches it, otherwise returns {@link Platform#IOS_SIMULATOR}.
*
- * <p>If {@link #getIosMultiCpus()} is set, returns {@link Platform#IOS_DEVICE} if any of the
- * architectures matches it, otherwise returns the mapping for {@link #getIosCpu()}.
+ * <p>Note that this method is similar to, {@link #getPlatform} but different in how it handles
+ * multiple architecture scenarios. This method should be used for obtaining {@link Platform} in
+ * contexts where multiple architectures are expected, such as bundling rules.
*
- * <p>Note that this method should not be used to determine the platform for code compilation.
- * Derive the platform from {@link #getIosCpu()} instead.
+ * @throws IllegalArgumentException if the current build options specify architecture(s) with
+ * no known apple platform
*/
// TODO(bazel-team): This method should be enabled to return multiple values once all call sites
// (in particular actool, bundlemerge, momc) have been upgraded to support multiple values.
+ // TODO(cparsons): Take platform type as input, supporting platforms other than IOS.
public Platform getBundlingPlatform() {
- for (String architecture : getIosMultiCpus()) {
- if (Platform.forIosArch(architecture) == Platform.IOS_DEVICE) {
+ List<String> architectures = getArchitectures(PlatformType.IOS);
+ for (String arch : architectures) {
+ if (Platform.forTarget(PlatformType.IOS, arch) == Platform.IOS_DEVICE) {
return Platform.IOS_DEVICE;
}
}
- return Platform.forIosArch(getIosCpu());
+ return Platform.IOS_SIMULATOR;
}
/**
+ * Returns the {@link Platform} represented by {@code ios_cpu} (see {@link #getIosCpu}.
+ * (For example, {@code i386} maps to {@link Platform#IOS_SIMULATOR}.) Note that this is not
+ * necessarily the effective platform for all ios actions in the current context: This is
+ * typically the correct platform for implicityly-ios compile and link actions in the current
+ * context. For effective platform for bundling actions, see {@link #getBundlingPlatform}.
+ */
+ // TODO(b/28754442): Deprecate for more general skylark-exposed platform retrieval.
+ @SkylarkCallable(name = "ios_cpu_platform", doc = "The platform given by the ios_cpu flag.")
+ public Platform getIosCpuPlatform() {
+ return getPlatform(PlatformType.IOS);
+ }
+
+ /**
* Returns the architecture for which we keep dependencies that should be present only once (in a
* single architecture).
*
diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java
index 8bf283e8a1..a2bbaa1798 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java
@@ -33,6 +33,7 @@ import com.google.devtools.build.lib.packages.Rule;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder;
import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
+import com.google.devtools.build.lib.rules.apple.Platform.PlatformType;
import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.xcode.xcodegen.proto.XcodeGenProtos.XcodeprojBuildSetting;
@@ -86,7 +87,7 @@ public class AppleToolchain {
*/
// TODO(bazel-team): Support non-ios platforms.
public static String getPlatformPlistName(AppleConfiguration configuration) {
- return Platform.forIosArch(configuration.getIosCpu()).getNameInPlist();
+ return configuration.getPlatform(PlatformType.IOS).getNameInPlist();
}
/**
diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java b/src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java
index 089061a7c7..f9c0e86fa1 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java
@@ -36,14 +36,10 @@ public enum Platform {
WATCHOS_DEVICE("WatchOS"),
WATCHOS_SIMULATOR("WatchSimulator");
- private static final Set<String> IOS_SIMULATOR_ARCHS = ImmutableSet.of("i386", "x86_64");
- private static final Set<String> IOS_DEVICE_ARCHS =
- ImmutableSet.of("armv6", "armv7", "armv7s", "arm64");
-
private static final Set<String> IOS_SIMULATOR_TARGET_CPUS =
ImmutableSet.of("ios_x86_64", "ios_i386");
private static final Set<String> IOS_DEVICE_TARGET_CPUS =
- ImmutableSet.of("ios_armv7", "ios_arm64");
+ ImmutableSet.of("ios_armv6", "ios_arm64", "ios_armv7", "ios_armv7s");
private static final Set<String> MACOSX_TARGET_CPUS =
ImmutableSet.of("darwin_x86_64");
@@ -68,26 +64,6 @@ public enum Platform {
return nameInPlist.toLowerCase(Locale.US);
}
- /**
- * Returns the iOS platform for the given iOS architecture.
- *
- * <p>If this method is used in non-iOS contexts, results are undefined. If the input happens
- * to share an architecture with some iOS platform, this will return that platform even if it is
- * incorrect (for example, IOS_SIMULATOR for the x86_64 of darwin_x86_64).
- *
- * @throws IllegalArgumentException if there is no valid ios platform for the given architecture
- */
- public static Platform forIosArch(String arch) {
- if (IOS_SIMULATOR_ARCHS.contains(arch)) {
- return IOS_SIMULATOR;
- } else if (IOS_DEVICE_ARCHS.contains(arch)) {
- return IOS_DEVICE;
- } else {
- throw new IllegalArgumentException(
- "No supported ios platform registered for architecture " + arch);
- }
- }
-
@Nullable
private static Platform forTargetCpuNullable(String targetCpu) {
if (IOS_SIMULATOR_TARGET_CPUS.contains(targetCpu)) {
@@ -102,10 +78,22 @@ public enum Platform {
}
/**
- * Returns the platform for the given target cpu.
+ * Returns the platform for the given target cpu and platform type.
*
+ * @param platformType platform type that the given cpu value is implied for
+ * @param arch architecture representation, such as 'arm64'
* @throws IllegalArgumentException if there is no valid apple platform for the given target cpu
*/
+ public static Platform forTarget(PlatformType platformType, String arch) {
+ return forTargetCpu(String.format("%s_%s", platformType.toString(), arch));
+ }
+
+ /**
+ * Returns the platform for the given target cpu.
+ *
+ * @param targetCpu cpu value with platform type prefix, such as 'ios_arm64'
+ * @throws IllegalArgumentException if there is no valid apple platform for the given target cpu
+ */
public static Platform forTargetCpu(String targetCpu) {
Platform platform = forTargetCpuNullable(targetCpu);
if (platform != null) {
@@ -132,6 +120,11 @@ public enum Platform {
IOS,
WATCHOS,
TVOS,
- MACOSX
+ MACOSX;
+
+ @Override
+ public String toString() {
+ return name().toLowerCase();
+ }
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java
index 690207b3ab..bc26cf74ed 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java
@@ -142,11 +142,11 @@ public class AppleBinary implements RuleConfiguredTargetFactory {
.registerCombineArchitecturesAction(
binariesToLipo.build(),
ruleIntermediateArtifacts.combinedArchitectureBinary(),
- appleConfiguration.getIosCpuPlatform())
+ appleConfiguration.getPlatform(PlatformType.IOS))
.registerCombineArchitecturesAction(
archivesToLipo.build(),
ruleContext.getImplicitOutputArtifact(AppleBinaryRule.LIPO_ARCHIVE),
- appleConfiguration.getIosCpuPlatform());
+ appleConfiguration.getPlatform(PlatformType.IOS));
RuleConfiguredTargetBuilder targetBuilder =
ObjcRuleClasses.ruleConfiguredTarget(ruleContext, filesToBuild.build());
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java
index abbeba537c..bb816ba2be 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java
@@ -36,6 +36,7 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
import com.google.devtools.build.lib.rules.apple.AppleToolchain;
import com.google.devtools.build.lib.rules.apple.Platform;
+import com.google.devtools.build.lib.rules.apple.Platform.PlatformType;
import com.google.devtools.build.lib.rules.objc.XcodeProvider.Builder;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -137,8 +138,8 @@ final class BundleSupport {
Platform platform = null;
for (String architecture : appleConfiguration.getIosMultiCpus()) {
if (platform == null) {
- platform = Platform.forIosArch(architecture);
- } else if (platform != Platform.forIosArch(architecture)) {
+ platform = Platform.forTarget(PlatformType.IOS, architecture);
+ } else if (platform != Platform.forTarget(PlatformType.IOS, architecture)) {
ruleContext.ruleError(
String.format("In builds which require bundling, --ios_multi_cpus does not currently "
+ "allow values for both simulator and device builds. Flag was %s",
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
index 8c60aaa1ed..fb420384c5 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
@@ -81,6 +81,7 @@ import com.google.devtools.build.lib.packages.TargetUtils;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
import com.google.devtools.build.lib.rules.apple.AppleToolchain;
import com.google.devtools.build.lib.rules.apple.Platform;
+import com.google.devtools.build.lib.rules.apple.Platform.PlatformType;
import com.google.devtools.build.lib.rules.cpp.CppModuleMap;
import com.google.devtools.build.lib.rules.cpp.CppModuleMapAction;
import com.google.devtools.build.lib.rules.cpp.LinkerInputs;
@@ -522,7 +523,7 @@ public final class CompilationSupport {
// TODO(bazel-team): Remote private headers from inputs once they're added to the provider.
ruleContext.registerAction(
ObjcRuleClasses.spawnAppleEnvActionBuilder(
- ruleContext, appleConfiguration.getIosCpuPlatform())
+ ruleContext, appleConfiguration.getPlatform(PlatformType.IOS))
.setMnemonic("ObjcCompile")
.setExecutable(xcrunwrapper(ruleContext))
.setCommandLine(commandLine.build())
@@ -652,7 +653,7 @@ public final class CompilationSupport {
ruleContext.registerAction(
ObjcRuleClasses.spawnAppleEnvActionBuilder(
- ruleContext, appleConfiguration.getIosCpuPlatform())
+ ruleContext, appleConfiguration.getPlatform(PlatformType.IOS))
.setMnemonic("SwiftCompile")
.setExecutable(xcrunwrapper(ruleContext))
.setCommandLine(commandLine.build())
@@ -722,7 +723,7 @@ public final class CompilationSupport {
commandLine.add(commonFrameworkFlags(objcProvider, appleConfiguration));
ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder(
- ruleContext, appleConfiguration.getIosCpuPlatform())
+ ruleContext, appleConfiguration.getPlatform(PlatformType.IOS))
.setMnemonic("SwiftModuleMerge")
.setExecutable(xcrunwrapper(ruleContext))
.setCommandLine(commandLine.build())
@@ -756,13 +757,13 @@ public final class CompilationSupport {
/*makeExecutable=*/ false));
actions.add(ObjcRuleClasses.spawnAppleEnvActionBuilder(
- ruleContext, appleConfiguration.getIosCpuPlatform())
+ ruleContext, appleConfiguration.getPlatform(PlatformType.IOS))
.setMnemonic("ObjcLink")
.setExecutable(libtool(ruleContext))
.setCommandLine(new CustomCommandLine.Builder()
.add("-static")
.add("-filelist").add(objList.getExecPathString())
- .add("-arch_only").add(appleConfiguration.getIosCpu())
+ .add("-arch_only").add(appleConfiguration.getSingleArchitecture(PlatformType.IOS))
.add("-syslibroot").add(AppleToolchain.sdkDir())
.add("-o").add(archive.getExecPathString())
.build())
@@ -787,12 +788,12 @@ public final class CompilationSupport {
ImmutableList<Artifact> objcLibraries = objcLibraries(objcProvider);
ImmutableList<Artifact> ccLibraries = ccLibraries(objcProvider);
ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder(
- ruleContext, appleConfiguration.getIosCpuPlatform())
+ ruleContext, appleConfiguration.getPlatform(PlatformType.IOS))
.setMnemonic("ObjcLink")
.setExecutable(libtool(ruleContext))
.setCommandLine(new CustomCommandLine.Builder()
.add("-static")
- .add("-arch_only").add(appleConfiguration.getIosCpu())
+ .add("-arch_only").add(appleConfiguration.getSingleArchitecture(PlatformType.IOS))
.add("-syslibroot").add(AppleToolchain.sdkDir())
.add("-o").add(outputArchive.getExecPathString())
.addExecPaths(objcLibraries)
@@ -990,7 +991,7 @@ public final class CompilationSupport {
linkmap);
ruleContext.registerAction(
ObjcRuleClasses.spawnAppleEnvActionBuilder(
- ruleContext, appleConfiguration.getIosCpuPlatform())
+ ruleContext, appleConfiguration.getPlatform(PlatformType.IOS))
.setMnemonic("ObjcLink")
.setShellCommand(ImmutableList.of("/bin/bash", "-c"))
.setCommandLine(new SingleArgCommandLine(commandLine))
@@ -1024,7 +1025,7 @@ public final class CompilationSupport {
ruleContext.registerAction(
ObjcRuleClasses.spawnAppleEnvActionBuilder(
- ruleContext, appleConfiguration.getIosCpuPlatform())
+ ruleContext, appleConfiguration.getPlatform(PlatformType.IOS))
.setMnemonic("ObjcBinarySymbolStrip")
.setExecutable(xcrunwrapper(ruleContext))
.setCommandLine(symbolStripCommandLine(stripArgs, binaryToLink, strippedBinary))
@@ -1293,7 +1294,7 @@ public final class CompilationSupport {
commandLine,
ParameterFile.ParameterFileType.UNQUOTED, ISO_8859_1));
ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder(
- ruleContext, appleConfiguration.getIosCpuPlatform())
+ ruleContext, appleConfiguration.getPlatform(PlatformType.IOS))
.setMnemonic("DummyPruner")
.setExecutable(pruner)
.addInput(dummyArchive)
@@ -1508,7 +1509,8 @@ public final class CompilationSupport {
*/
@VisibleForTesting
static String swiftTarget(AppleConfiguration configuration) {
- return configuration.getIosCpu() + "-apple-ios" + configuration.getIosSdkVersion();
+ return configuration.getSingleArchitecture(PlatformType.IOS)
+ + "-apple-ios" + configuration.getIosSdkVersion();
}
/**
@@ -1518,7 +1520,7 @@ public final class CompilationSupport {
ObjcProvider provider, ObjcConfiguration objcConfiguration,
AppleConfiguration appleConfiguration) {
ImmutableList.Builder<String> builder = new ImmutableList.Builder<>();
- Platform platform = Platform.forIosArch(appleConfiguration.getIosCpu());
+ Platform platform = appleConfiguration.getPlatform(PlatformType.IOS);
if (platform == Platform.IOS_SIMULATOR) {
builder.add("-mios-simulator-version-min=" + objcConfiguration.getMinimumOs());
} else {
@@ -1530,7 +1532,7 @@ public final class CompilationSupport {
}
return builder
- .add("-arch", appleConfiguration.getIosCpu())
+ .add("-arch", appleConfiguration.getSingleArchitecture(PlatformType.IOS))
.add("-isysroot", AppleToolchain.sdkDir())
// TODO(bazel-team): Pass framework search paths to Xcodegen.
.addAll(commonFrameworkFlags(provider, appleConfiguration))
@@ -1550,7 +1552,7 @@ public final class CompilationSupport {
*/
static Iterable<String> commonFrameworkNames(
ObjcProvider provider, AppleConfiguration appleConfiguration) {
- Platform platform = Platform.forIosArch(appleConfiguration.getIosCpu());
+ Platform platform = appleConfiguration.getPlatform(PlatformType.IOS);
return new ImmutableList.Builder<String>()
.add(AppleToolchain.sdkFrameworkDir(platform, appleConfiguration))
@@ -1578,7 +1580,7 @@ public final class CompilationSupport {
private static List<String> platformSpecificCompileFlagsForClang(
AppleConfiguration configuration) {
- switch (Platform.forIosArch(configuration.getIosCpu())) {
+ switch (configuration.getPlatform(PlatformType.IOS)) {
case IOS_DEVICE:
return ImmutableList.of();
case IOS_SIMULATOR:
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
index 4c089de70c..f6a0c938d2 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
@@ -52,6 +52,7 @@ import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
import com.google.devtools.build.lib.rules.apple.AppleToolchain;
import com.google.devtools.build.lib.rules.apple.AppleToolchain.RequiresXcodeConfigRule;
import com.google.devtools.build.lib.rules.apple.Platform;
+import com.google.devtools.build.lib.rules.apple.Platform.PlatformType;
import com.google.devtools.build.lib.rules.cpp.CppConfiguration;
import com.google.devtools.build.lib.syntax.Type;
import com.google.devtools.build.lib.util.FileType;
@@ -187,7 +188,7 @@ public class ObjcRuleClasses {
AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
return spawnAppleEnvActionBuilder(ruleContext,
- Platform.forIosArch(appleConfiguration.getIosCpu()));
+ Platform.forTarget(PlatformType.IOS, appleConfiguration.getIosCpu()));
}
/**
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java
index f4fb0338e2..868303e70a 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java
@@ -820,7 +820,7 @@ public final class ReleaseBundlingSupport {
AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
new LipoSupport(ruleContext).registerCombineArchitecturesAction(linkedBinaries(),
- resultingLinkedBinary, appleConfiguration.getIosCpuPlatform());
+ resultingLinkedBinary, appleConfiguration.getPlatform(PlatformType.IOS));
}
private NestedSet<Artifact> linkedBinaries() {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java
index 802fc8f658..61ac5a6af3 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java
@@ -30,6 +30,7 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.packages.ImplicitOutputsFunction.SafeImplicitOutputsFunction;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration.ConfigurationDistinguisher;
+import com.google.devtools.build.lib.rules.apple.Platform.PlatformType;
import com.google.devtools.build.lib.rules.objc.XcodeProvider.Builder;
import com.google.devtools.build.lib.rules.objc.XcodeProvider.Project;
import com.google.devtools.build.xcode.xcodegen.proto.XcodeGenProtos;
@@ -271,12 +272,7 @@ public final class XcodeSupport {
this.project = project;
this.pbxproj = pbxproj;
this.workspaceRoot = objcConfiguration.getXcodeWorkspaceRoot();
- List<String> multiCpus = appleConfiguration.getIosMultiCpus();
- if (multiCpus.isEmpty()) {
- this.appleCpus = ImmutableList.of(appleConfiguration.getIosCpu());
- } else {
- this.appleCpus = multiCpus;
- }
+ this.appleCpus = appleConfiguration.getArchitectures(PlatformType.IOS);
this.minimumOs = objcConfiguration.getMinimumOs().toString();
this.generateDebugSymbols =
objcConfiguration.generateDebugSymbols() || objcConfiguration.generateDsym();