diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java | 41 |
1 files changed, 33 insertions, 8 deletions
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 6fcb2f2073..890d4a8b1d 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 @@ -95,7 +95,7 @@ final class BundleSupport { this.bundling = bundling; this.attributes = new Attributes(ruleContext); } - + /** * Registers actions required for constructing this bundle, namely merging all involved {@code * Info.plist} files and generating asset catalogues. @@ -126,13 +126,22 @@ final class BundleSupport { return this; } - /** - * Validates that resources defined in this rule and its dependencies and written to this bundle - * are legal (for example that they are not mapped to the same bundle location). - * - * @return this bundle support - */ - BundleSupport validateResources(ObjcProvider objcProvider) { + private void validatePlatform() { + ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(ruleContext); + Platform platform = null; + for (String architecture : objcConfiguration.getIosMultiCpus()) { + if (platform == null) { + platform = Platform.forArch(architecture); + } else if (platform != Platform.forArch(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", + objcConfiguration.getIosMultiCpus())); + } + } + } + + private void validateResources(ObjcProvider objcProvider) { Map<String, Artifact> bundlePathToFile = new HashMap<>(); NestedSet<Artifact> artifacts = objcProvider.get(STRINGS); @@ -177,6 +186,22 @@ final class BundleSupport { // TODO(bazel-team): Do the same validation for storyboards and datamodels which could also be // generated by genrules or doubly defined. + } + + /** + * Validates bundle support. + * <ul> + * <li>Validates that resources defined in this rule and its dependencies and written to this + * bundle are legal (for example that they are not mapped to the same bundle location) + * <li>Validates the platform for this build is either simulator or device, and does not + * contain architectures for both platforms + * </ul> + * + * @return this bundle support + */ + BundleSupport validate(ObjcProvider objcProvider) { + validatePlatform(); + validateResources(objcProvider); return this; } |