aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/xcode-common/java/com/google/devtools/build/xcode/common
diff options
context:
space:
mode:
authorGravatar Chris Parsons <cparsons@google.com>2015-10-30 18:32:25 +0000
committerGravatar Florian Weikert <fwe@google.com>2015-11-02 16:54:14 +0000
commit43bc404c4983a902964573ab13b44a6bde7920b3 (patch)
tree8be44c666745021227f6ede427d7b0c61c2c45c8 /src/tools/xcode-common/java/com/google/devtools/build/xcode/common
parent28759f18067f474899941156c9312d6aacab8557 (diff)
Strict matching of architecture name to ios platform. Also refactor Platform into a new .apple package, as it is not relevant for solely objc rules.
-- MOS_MIGRATED_REVID=106709486
Diffstat (limited to 'src/tools/xcode-common/java/com/google/devtools/build/xcode/common')
-rw-r--r--src/tools/xcode-common/java/com/google/devtools/build/xcode/common/Platform.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/tools/xcode-common/java/com/google/devtools/build/xcode/common/Platform.java b/src/tools/xcode-common/java/com/google/devtools/build/xcode/common/Platform.java
index b680497e42..e17ad12c74 100644
--- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/common/Platform.java
+++ b/src/tools/xcode-common/java/com/google/devtools/build/xcode/common/Platform.java
@@ -16,18 +16,19 @@ package com.google.devtools.build.xcode.common;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
-import com.google.devtools.build.xcode.util.Containing;
import java.util.Locale;
import java.util.Set;
/**
- * An enum that can be used to distinguish between an iOS simulator and device.
+ * An enum that can be used to distinguish between various apple platforms.
*/
public enum Platform {
- DEVICE("iPhoneOS"), SIMULATOR("iPhoneSimulator");
+ IOS_DEVICE("iPhoneOS"), IOS_SIMULATOR("iPhoneSimulator");
- private static final Set<String> SIMULATOR_ARCHS = ImmutableSet.of("i386", "x86_64");
+ 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 final String nameInPlist;
@@ -51,9 +52,19 @@ public enum Platform {
}
/**
- * Returns the platform for the arch.
+ * Returns the platform for the architecture.
+ *
+ * @throws IllegalArgumentException if there is no valid apple platform for the given
+ * architecture.
*/
public static Platform forArch(String arch) {
- return Containing.item(SIMULATOR_ARCHS, arch) ? SIMULATOR : DEVICE;
+ 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 apple platform registered for architecture " + arch);
+ }
}
}