From ff97c3003e0280f68991417469cd04d773866b9c Mon Sep 17 00:00:00 2001 From: Dave MacLachlan Date: Fri, 11 Mar 2016 20:45:21 +0000 Subject: Removes restriction on having both a launchimage and a launchstoryboard in a given application as there are cases where you want both. -- MOS_MIGRATED_REVID=116998425 --- .../devtools/build/lib/rules/objc/ObjcCommon.java | 15 ++++++++- .../build/lib/rules/objc/ObjcRuleClasses.java | 29 ----------------- .../lib/rules/objc/ReleaseBundlingSupport.java | 36 +++------------------- 3 files changed, 18 insertions(+), 62 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules') diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java index abf35a1fea..16ec90aab2 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.rules.objc; +import static com.google.devtools.build.lib.packages.BuildType.LABEL; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.ASSET_CATALOG; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.BREAKPAD_FILE; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.BUNDLE_FILE; @@ -555,7 +556,7 @@ public final class ObjcCommon { .addAll(STORYBOARD, attributes.storyboards()); } - if (ObjcRuleClasses.useLaunchStoryboard(context)) { + if (useLaunchStoryboard(context)) { Artifact launchStoryboard = context.getPrerequisiteArtifact("launch_storyboard", Mode.TARGET); objcProvider.add(GENERAL_RESOURCE_FILE, launchStoryboard); @@ -626,6 +627,18 @@ public final class ObjcCommon { return new ObjcCommon(objcProvider.build(), compilationArtifacts); } + /** + * Returns {@code true} if the given rule context has a launch storyboard set. + */ + private static boolean useLaunchStoryboard(RuleContext ruleContext) { + if (!ruleContext.attributes().has("launch_storyboard", LABEL)) { + return false; + } + Artifact launchStoryboard = + ruleContext.getPrerequisiteArtifact("launch_storyboard", Mode.TARGET); + return launchStoryboard != null; + } + } static final FileType BUNDLE_CONTAINER_TYPE = FileType.of(".bundle"); 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 65e1f9c1d8..d307c5bc05 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,7 +52,6 @@ import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType; 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.DottedVersion; import com.google.devtools.build.lib.rules.apple.Platform; import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.util.FileType; @@ -70,9 +69,6 @@ public class ObjcRuleClasses { static final String LIPO = "lipo"; static final String STRIP = "strip"; - private static final DottedVersion MIN_LAUNCH_STORYBOARD_OS_VERSION = - DottedVersion.fromString("8.0"); - private ObjcRuleClasses() { throw new UnsupportedOperationException("static-only"); } @@ -191,31 +187,6 @@ public class ObjcRuleClasses { .add(RunfilesProvider.class, runfilesProvider); } - /** - * Returns {@code true} if the given rule context has a launch storyboard set and the given - * {@code iosMinimumOs} supports launch storyboards. - */ - static boolean useLaunchStoryboard(RuleContext ruleContext, DottedVersion iosMinimumOs) { - if (!ruleContext.attributes().has("launch_storyboard", LABEL)) { - return false; - } - Artifact launchStoryboard = - ruleContext.getPrerequisiteArtifact("launch_storyboard", Mode.TARGET); - return launchStoryboard != null - && iosMinimumOs.compareTo(MIN_LAUNCH_STORYBOARD_OS_VERSION) >= 0; - } - - /** - * Returns {@code true} if the given rule context has a launch storyboard set and its - * configuration (--ios_minimum_os) supports launch storyboards. - */ - static boolean useLaunchStoryboard(RuleContext ruleContext) { - // We check launch_storyboard before retrieving the minimum os from the configuration, - // allowing this to be invoked even in contexts which do not depend on ObjcConfiguration. - return (ruleContext.attributes().has("launch_storyboard", LABEL) - && useLaunchStoryboard(ruleContext, objcConfiguration(ruleContext).getMinimumOs())); - } - /** * Attributes for {@code objc_*} rules that have compiler options. */ 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 64109672e5..795b967369 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 @@ -226,8 +226,6 @@ public final class ReleaseBundlingSupport { ruleContext.attributeError("families", INVALID_FAMILIES_ERROR); } - validateLaunchScreen(); - AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); if (attributes.provisioningProfile() == null && appleConfiguration.getBundlingPlatform() != Platform.IOS_SIMULATOR) { @@ -237,30 +235,6 @@ public final class ReleaseBundlingSupport { return this; } - private void validateLaunchScreen() { - if (ruleContext.attributes().isAttributeValueExplicitlySpecified("launch_storyboard")) { - DottedVersion minimumOs = bundling.getMinimumOsVersion(); - if (ObjcRuleClasses.useLaunchStoryboard(ruleContext, bundling.getMinimumOsVersion())) { - if (ruleContext.attributes().isAttributeValueExplicitlySpecified("launch_image")) { - ruleContext.attributeWarning( - "launch_image", - String.format( - "launch_image was specified but since --ios_minimum_os=%s (>=8.0), the also " - + "specified launch_storyboard will be used instead", - minimumOs)); - } - } else { - if (!ruleContext.attributes().isAttributeValueExplicitlySpecified("launch_image")) { - ruleContext.attributeWarning( - "launch_storyboard", - String.format( - "launch_storyboard was specified but since --ios_minimum_os=%s (<8.0) and no " - + "launch_image was specified instead it will be ignored", - minimumOs)); - } - } - } - } /** * Validates that resources defined in this rule and its dependencies and written to this bundle @@ -293,7 +267,7 @@ public final class ReleaseBundlingSupport { registerEnvironmentPlistAction(); registerAutomaticPlistAction(); - if (ObjcRuleClasses.useLaunchStoryboard(ruleContext, bundling.getMinimumOsVersion())) { + if (attributes.launchStoryboard() != null) { registerLaunchStoryboardPlistAction(); } @@ -624,8 +598,7 @@ public final class ReleaseBundlingSupport { if (attributes.appIcon() != null) { extraArgs.add("--app-icon", attributes.appIcon()); } - if (attributes.launchImage() != null - && !ObjcRuleClasses.useLaunchStoryboard(ruleContext, bundling.getMinimumOsVersion())) { + if (attributes.launchImage() != null) { extraArgs.add("--launch-image", attributes.launchImage()); } return new ExtraActoolArgs(extraArgs.build()); @@ -673,7 +646,7 @@ public final class ReleaseBundlingSupport { .setFallbackBundleId(fallbackBundleId) .setMinimumOsVersion(minimumOsVersion); - if (ObjcRuleClasses.useLaunchStoryboard(ruleContext, minimumOsVersion)) { + if (attributes.launchStoryboard() != null) { bundling.addInfoplistInput(getLaunchStoryboardPlist()); } @@ -715,8 +688,7 @@ public final class ReleaseBundlingSupport { .setValue(attributes.appIcon()) .build()); } - if (attributes.launchImage() != null - && !ObjcRuleClasses.useLaunchStoryboard(ruleContext, bundling.getMinimumOsVersion())) { + if (attributes.launchImage() != null) { buildSettings.add(XcodeprojBuildSetting.newBuilder() .setName("ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME") .setValue(attributes.launchImage()) -- cgit v1.2.3