diff options
author | 2016-03-22 22:07:47 +0000 | |
---|---|---|
committer | 2016-03-23 12:19:53 +0000 | |
commit | 9ad1a32a8b2c45b28fc45c331b9461f7c8539ec1 (patch) | |
tree | 9555f3ca85e05ec2688d1f8cb47ec771d4614f3b /src/main/java/com/google/devtools/build/lib | |
parent | 81c5bd88bed02f7541cf56dd27d96867a560c4b7 (diff) |
Implement default_{tvos,watchos,macosx}_sdk_version attributes for the xcode_version rule.
--{tvos,watchos,macosx}_sdk_version flags may be used to override defaults specified in these attributes.
--
MOS_MIGRATED_REVID=117869146
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
5 files changed, 95 insertions, 17 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 e85a7f0658..93e54def4b 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 @@ -56,8 +56,7 @@ public class AppleCommandLineOptions extends FragmentOptions { @Option( name = "watchos_sdk_version", - // TODO(bazel-team): Make this flag optional, and infer SDKROOT based on executor default. - defaultValue = DEFAULT_WATCHOS_SDK_VERSION, + defaultValue = "null", converter = DottedVersionConverter.class, category = "build", help = "Specifies the version of the WatchOS SDK to use to build WatchOS applications." @@ -66,8 +65,7 @@ public class AppleCommandLineOptions extends FragmentOptions { @Option( name = "tvos_sdk_version", - // TODO(bazel-team): Make this flag optional, and infer SDKROOT based on executor default. - defaultValue = DEFAULT_APPLETVOS_SDK_VERSION, + defaultValue = "null", converter = DottedVersionConverter.class, category = "build", help = "Specifies the version of the AppleTVOS SDK to use to build AppleTVOS applications." @@ -76,8 +74,7 @@ public class AppleCommandLineOptions extends FragmentOptions { @Option( name = "macosx_sdk_version", - // TODO(bazel-team): Make this flag optional, and infer SDKROOT based on executor default. - defaultValue = DEFAULT_MACOSX_SDK_VERSION, + defaultValue = "null", converter = DottedVersionConverter.class, category = "build", help = "Specifies the version of the Mac OS X SDK to use to build Mac OS X applications." @@ -229,6 +226,9 @@ public class AppleCommandLineOptions extends FragmentOptions { host.xcodeVersionConfig = xcodeVersionConfig; host.xcodeVersion = xcodeVersion; host.iosSdkVersion = iosSdkVersion; + host.watchOsSdkVersion = watchOsSdkVersion; + host.tvOsSdkVersion = tvOsSdkVersion; + host.macOsXSdkVersion = macOsXSdkVersion; host.appleBitcodeMode = appleBitcodeMode; return host; 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 1bd969ed7e..5f8b4cac5f 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 @@ -68,14 +68,17 @@ public class AppleConfiguration extends BuildConfiguration.Fragment { AppleConfiguration(AppleCommandLineOptions appleOptions, Optional<DottedVersion> xcodeVersionOverride, - DottedVersion iosSdkVersion) { + DottedVersion iosSdkVersion, + DottedVersion watchOsSdkVersion, + DottedVersion tvOsSdkVersion, + DottedVersion macOsXSdkVersion) { this.iosSdkVersion = Preconditions.checkNotNull(iosSdkVersion, "iosSdkVersion"); this.watchOsSdkVersion = - Preconditions.checkNotNull(appleOptions.watchOsSdkVersion, "watchOsSdkVersion"); + Preconditions.checkNotNull(watchOsSdkVersion, "watchOsSdkVersion"); this.tvOsSdkVersion = - Preconditions.checkNotNull(appleOptions.tvOsSdkVersion, "tvOsSdkVersion"); + Preconditions.checkNotNull(tvOsSdkVersion, "tvOsSdkVersion"); this.macOsXSdkVersion = - Preconditions.checkNotNull(appleOptions.macOsXSdkVersion, "macOsXSdkVersion"); + Preconditions.checkNotNull(macOsXSdkVersion, "macOsXSdkVersion"); this.xcodeVersion = Preconditions.checkNotNull(xcodeVersionOverride); this.iosCpu = Preconditions.checkNotNull(appleOptions.iosCpu, "iosCpu"); @@ -266,9 +269,15 @@ public class AppleConfiguration extends BuildConfiguration.Fragment { DottedVersion iosSdkVersion = (appleOptions.iosSdkVersion != null) ? appleOptions.iosSdkVersion : xcodeVersionProperties.getDefaultIosSdkVersion(); + DottedVersion watchosSdkVersion = (appleOptions.watchOsSdkVersion != null) + ? appleOptions.watchOsSdkVersion : xcodeVersionProperties.getDefaultWatchosSdkVersion(); + DottedVersion tvosSdkVersion = (appleOptions.tvOsSdkVersion != null) + ? appleOptions.tvOsSdkVersion : xcodeVersionProperties.getDefaultTvosSdkVersion(); + DottedVersion macosxSdkVersion = (appleOptions.macOsXSdkVersion != null) + ? appleOptions.macOsXSdkVersion : xcodeVersionProperties.getDefaultMacosxSdkVersion(); AppleConfiguration configuration = new AppleConfiguration(appleOptions, xcodeVersionProperties.getXcodeVersion(), - iosSdkVersion); + iosSdkVersion, watchosSdkVersion, tvosSdkVersion, macosxSdkVersion); validate(configuration); return configuration; diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionProperties.java b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionProperties.java index 9194a33e45..5da51a5b41 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionProperties.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionProperties.java @@ -25,9 +25,15 @@ import javax.annotation.Nullable; */ public class XcodeVersionProperties { @VisibleForTesting public static final String DEFAULT_IOS_SDK_VERSION = "8.4"; + @VisibleForTesting public static final String DEFAULT_WATCHOS_SDK_VERSION = "2.0"; + @VisibleForTesting public static final String DEFAULT_MACOSX_SDK_VERSION = "10.10"; + @VisibleForTesting public static final String DEFAULT_TVOS_SDK_VERSION = "1.0"; private final Optional<DottedVersion> xcodeVersion; private final DottedVersion defaultIosSdkVersion; + private final DottedVersion defaultWatchosSdkVersion; + private final DottedVersion defaultTvosSdkVersion; + private final DottedVersion defaultMacosxSdkVersion; /** * Creates and returns a tuple representing no known xcode property information (defaults are @@ -46,7 +52,7 @@ public class XcodeVersionProperties { * is specified. */ XcodeVersionProperties(DottedVersion xcodeVersion) { - this(xcodeVersion, null); + this(xcodeVersion, null, null, null, null); } /** @@ -54,11 +60,23 @@ public class XcodeVersionProperties { * a semi-sensible default will be assigned to the property value. */ XcodeVersionProperties(DottedVersion xcodeVersion, - @Nullable String defaultIosSdkVersion) { + @Nullable String defaultIosSdkVersion, + @Nullable String defaultWatchosSdkVersion, + @Nullable String defaultTvosSdkVersion, + @Nullable String defaultMacosxSdkVersion) { this.xcodeVersion = Optional.fromNullable(xcodeVersion); this.defaultIosSdkVersion = (Strings.isNullOrEmpty(defaultIosSdkVersion)) ? DottedVersion.fromString(DEFAULT_IOS_SDK_VERSION) : DottedVersion.fromString(defaultIosSdkVersion); + this.defaultWatchosSdkVersion = (Strings.isNullOrEmpty(defaultWatchosSdkVersion)) + ? DottedVersion.fromString(DEFAULT_WATCHOS_SDK_VERSION) + : DottedVersion.fromString(defaultWatchosSdkVersion); + this.defaultTvosSdkVersion = (Strings.isNullOrEmpty(defaultTvosSdkVersion)) + ? DottedVersion.fromString(DEFAULT_TVOS_SDK_VERSION) + : DottedVersion.fromString(defaultTvosSdkVersion); + this.defaultMacosxSdkVersion = (Strings.isNullOrEmpty(defaultMacosxSdkVersion)) + ? DottedVersion.fromString(DEFAULT_MACOSX_SDK_VERSION) + : DottedVersion.fromString(defaultMacosxSdkVersion); } /** @@ -74,4 +92,25 @@ public class XcodeVersionProperties { public DottedVersion getDefaultIosSdkVersion() { return defaultIosSdkVersion; } + + /** + * Returns the default watchos sdk version to use if this xcode version is in use. + */ + public DottedVersion getDefaultWatchosSdkVersion() { + return defaultWatchosSdkVersion; + } + + /** + * Returns the default tvos sdk version to use if this xcode version is in use. + */ + public DottedVersion getDefaultTvosSdkVersion() { + return defaultTvosSdkVersion; + } + + /** + * Returns the default macosx sdk version to use if this xcode version is in use. + */ + public DottedVersion getDefaultMacosxSdkVersion() { + return defaultMacosxSdkVersion; + } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRule.java b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRule.java index d0ac5b5441..214ba8ae99 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRule.java @@ -32,6 +32,9 @@ public class XcodeVersionRule implements RuleDefinition { static final String VERSION_ATTR_NAME = "version"; static final String ALIASES_ATTR_NAME = "aliases"; static final String DEFAULT_IOS_SDK_VERSION_ATTR_NAME = "default_ios_sdk_version"; + static final String DEFAULT_WATCHOS_SDK_VERSION_ATTR_NAME = "default_watchos_sdk_version"; + static final String DEFAULT_TVOS_SDK_VERSION_ATTR_NAME = "default_tvos_sdk_version"; + static final String DEFAULT_MACOSX_SDK_VERSION_ATTR_NAME = "default_macosx_sdk_version"; @Override public RuleClass build(Builder builder, RuleDefinitionEnvironment env) { @@ -58,6 +61,24 @@ public class XcodeVersionRule implements RuleDefinition { <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ .add(attr(DEFAULT_IOS_SDK_VERSION_ATTR_NAME, STRING) .nonconfigurable("this rule determines configuration")) + /* <!-- #BLAZE_RULE(xcode_version).ATTRIBUTE(default_watchos_sdk_version) --> + The watchos sdk version that is used by default when this version of xcode is being used. + The <code>watchos_sdk_version</code> build flag will override the value specified here. + <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ + .add(attr(DEFAULT_WATCHOS_SDK_VERSION_ATTR_NAME, STRING) + .nonconfigurable("this rule determines configuration")) + /* <!-- #BLAZE_RULE(xcode_version).ATTRIBUTE(default_tvos_sdk_version) --> + The tvos sdk version that is used by default when this version of xcode is being used. + The <code>tvos_sdk_version</code> build flag will override the value specified here. + <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ + .add(attr(DEFAULT_TVOS_SDK_VERSION_ATTR_NAME, STRING) + .nonconfigurable("this rule determines configuration")) + /* <!-- #BLAZE_RULE(xcode_version).ATTRIBUTE(default_macosx_sdk_version) --> + The macosx sdk version that is used by default when this version of xcode is being used. + The <code>macosx_sdk_version</code> build flag will override the value specified here. + <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ + .add(attr(DEFAULT_MACOSX_SDK_VERSION_ATTR_NAME, STRING) + .nonconfigurable("this rule determines configuration")) .build(); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRuleData.java b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRuleData.java index 8bc9baeec6..020caf34e2 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRuleData.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRuleData.java @@ -24,11 +24,13 @@ import java.util.List; /** * A tuple containing the information in a single target of the {@code xcode_version} rule. - * A single target of this rule contains an official version label decided by Apple and a number - * of supported aliases one might use to reference this version. + * A single target of this rule contains an official version label decided by Apple, a number + * of supported aliases one might use to reference this version, and various properties of + * the xcode version (such as default SDK versions). * * <p>For example, one may want to reference official xcode version 7.0.1 using the "7" or - * "7.0" aliases. + * "7.0" aliases. This official version of xcode may have a default supported iOS SDK of + * 9.0. */ public class XcodeVersionRuleData { private final Label label; @@ -45,8 +47,15 @@ public class XcodeVersionRuleData { attrMapper.get(XcodeVersionRule.VERSION_ATTR_NAME, Type.STRING)); String iosSdkVersionString = attrMapper.get(XcodeVersionRule.DEFAULT_IOS_SDK_VERSION_ATTR_NAME, Type.STRING); + String watchosSdkVersionString = + attrMapper.get(XcodeVersionRule.DEFAULT_WATCHOS_SDK_VERSION_ATTR_NAME, Type.STRING); + String tvosSdkVersionString = + attrMapper.get(XcodeVersionRule.DEFAULT_TVOS_SDK_VERSION_ATTR_NAME, Type.STRING); + String macosxSdkVersionString = + attrMapper.get(XcodeVersionRule.DEFAULT_MACOSX_SDK_VERSION_ATTR_NAME, Type.STRING); this.version = xcodeVersion; - this.xcodeVersionProperties = new XcodeVersionProperties(xcodeVersion, iosSdkVersionString); + this.xcodeVersionProperties = new XcodeVersionProperties(xcodeVersion, iosSdkVersionString, + watchosSdkVersionString, tvosSdkVersionString, macosxSdkVersionString); this.aliases = ImmutableList.copyOf( attrMapper.get(XcodeVersionRule.ALIASES_ATTR_NAME, Type.STRING_LIST)); } |