diff options
author | 2016-03-22 18:10:28 +0000 | |
---|---|---|
committer | 2016-03-23 12:19:50 +0000 | |
commit | a65d0ee1f9376820f87309a3b81502ad14614583 (patch) | |
tree | ff9d3c512e91aad8878ee2fbff98f46b59b648b1 /src/main/java | |
parent | 044adedc70de040475443e52eb1a3c692159790e (diff) |
ios_device's attribute ios_version defaults to the configuration iOS SDK version
--
MOS_MIGRATED_REVID=117841917
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/IosDevice.java | 15 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/IosDeviceRule.java | 7 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosDevice.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosDevice.java index 6b5d4e20da..8d3bd78221 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosDevice.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IosDevice.java @@ -16,12 +16,15 @@ package com.google.devtools.build.lib.rules.objc; import static com.google.devtools.build.lib.syntax.Type.STRING; +import com.google.common.base.Strings; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.RunfilesProvider; import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory; +import com.google.devtools.build.lib.rules.apple.AppleConfiguration; import com.google.devtools.build.lib.rules.apple.DottedVersion; +import com.google.devtools.build.lib.rules.apple.Platform; /** * Implementation for the "ios_device" rule. @@ -29,11 +32,19 @@ import com.google.devtools.build.lib.rules.apple.DottedVersion; public final class IosDevice implements RuleConfiguredTargetFactory { @Override public ConfiguredTarget create(RuleContext context) throws InterruptedException { + String iosVersionAttribute = context.attributes().get("ios_version", STRING); + DottedVersion iosVersion; + if (!Strings.isNullOrEmpty(iosVersionAttribute)) { + iosVersion = DottedVersion.fromString(iosVersionAttribute); + } else { + iosVersion = context.getFragment(AppleConfiguration.class) + .getSdkVersionForPlatform(Platform.IOS_SIMULATOR); + } + IosDeviceProvider provider = new IosDeviceProvider.Builder() .setType(context.attributes().get("type", STRING)) - .setIosVersion( - DottedVersion.fromString(context.attributes().get("ios_version", STRING))) + .setIosVersion(iosVersion) .setLocale(context.attributes().get("locale", STRING)) .build(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosDeviceRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosDeviceRule.java index 44de5695f4..87a11bad50 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosDeviceRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IosDeviceRule.java @@ -22,6 +22,7 @@ import com.google.devtools.build.lib.analysis.RuleDefinition; import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment; import com.google.devtools.build.lib.packages.RuleClass; import com.google.devtools.build.lib.packages.RuleClass.Builder; +import com.google.devtools.build.lib.rules.apple.AppleConfiguration; /** * Rule definition for ios_device. @@ -30,12 +31,12 @@ public final class IosDeviceRule implements RuleDefinition { @Override public RuleClass build(Builder builder, RuleDefinitionEnvironment env) { return builder + .requiresConfigurationFragments(AppleConfiguration.class) /* <!-- #BLAZE_RULE(ios_device).ATTRIBUTE(ios_version) --> The operating system version of the device. This corresponds to the - <code>simctl</code> runtime. + <code>simctl</code> runtime. Defaults to the ios sdk version configuration value. <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/ - .add(attr("ios_version", STRING) - .mandatory()) + .add(attr("ios_version", STRING)) /* <!-- #BLAZE_RULE(ios_device).ATTRIBUTE(type) --> The hardware type. This corresponds to the <code>simctl</code> device type. |