aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Dave MacLachlan <dmaclach@google.com>2016-03-01 18:41:40 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-03-01 19:13:48 +0000
commit3f611ab4ee905c09aff05f8fd8f19517be54efa6 (patch)
tree8cca002a67c1ddf156a5abbcf4440ebc6f8f7b74 /src/main/java/com
parent4c285cad728b6f51bc8ed45dab5951b5ee8e663b (diff)
Start adding support for passing in SDK versions for Mac OS, Watch OS, TV OS.
-- MOS_MIGRATED_REVID=116020389
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java35
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java43
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java3
3 files changed, 75 insertions, 6 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 de868a123f..815687c8f0 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
@@ -55,8 +55,41 @@ public class AppleCommandLineOptions extends FragmentOptions {
)
public DottedVersion iosSdkVersion;
+ @Option(
+ name = "watchos_sdk_version",
+ // TODO(bazel-team): Make this flag optional, and infer SDKROOT based on executor default.
+ defaultValue = DEFAULT_WATCHOS_SDK_VERSION,
+ converter = DottedVersionConverter.class,
+ category = "build",
+ help = "Specifies the version of the WatchOS SDK to use to build WatchOS applications."
+ )
+ public DottedVersion watchOsSdkVersion;
+
+ @Option(
+ name = "tvos_sdk_version",
+ // TODO(bazel-team): Make this flag optional, and infer SDKROOT based on executor default.
+ defaultValue = DEFAULT_APPLETVOS_SDK_VERSION,
+ converter = DottedVersionConverter.class,
+ category = "build",
+ help = "Specifies the version of the AppleTVOS SDK to use to build AppleTVOS applications."
+ )
+ public DottedVersion tvOsSdkVersion;
+
+ @Option(
+ name = "macosx_sdk_version",
+ // TODO(bazel-team): Make this flag optional, and infer SDKROOT based on executor default.
+ defaultValue = DEFAULT_MACOSX_SDK_VERSION,
+ converter = DottedVersionConverter.class,
+ category = "build",
+ help = "Specifies the version of the Mac OS X SDK to use to build Mac OS X applications."
+ )
+ public DottedVersion macOsXSdkVersion;
+
@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_APPLETVOS_SDK_VERSION = "1.0";
+
@Option(name = "ios_cpu",
defaultValue = DEFAULT_IOS_CPU,
category = "build",
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 6a7a9d8ac4..1ce38d3b36 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
@@ -56,6 +56,9 @@ public class AppleConfiguration extends BuildConfiguration.Fragment {
private static final DottedVersion MINIMUM_BITCODE_XCODE_VERSION = DottedVersion.fromString("7");
private final DottedVersion iosSdkVersion;
+ private final DottedVersion watchOsSdkVersion;
+ private final DottedVersion tvOsSdkVersion;
+ private final DottedVersion macOsXSdkVersion;
private final String iosCpu;
private final Optional<DottedVersion> xcodeVersion;
private final ImmutableList<String> iosMultiCpus;
@@ -66,6 +69,13 @@ public class AppleConfiguration extends BuildConfiguration.Fragment {
AppleConfiguration(AppleCommandLineOptions appleOptions,
Optional<DottedVersion> xcodeVersionOverride) {
this.iosSdkVersion = Preconditions.checkNotNull(appleOptions.iosSdkVersion, "iosSdkVersion");
+ this.watchOsSdkVersion =
+ Preconditions.checkNotNull(appleOptions.watchOsSdkVersion, "watchOsSdkVersion");
+ this.tvOsSdkVersion =
+ Preconditions.checkNotNull(appleOptions.tvOsSdkVersion, "tvOsSdkVersion");
+ this.macOsXSdkVersion =
+ Preconditions.checkNotNull(appleOptions.macOsXSdkVersion, "macOsXSdkVersion");
+
this.xcodeVersion = Preconditions.checkNotNull(xcodeVersionOverride);
this.iosCpu = Preconditions.checkNotNull(appleOptions.iosCpu, "iosCpu");
this.iosMultiCpus = ImmutableList.copyOf(
@@ -78,10 +88,34 @@ public class AppleConfiguration extends BuildConfiguration.Fragment {
/**
* Returns the SDK version for ios SDKs (whether they be for simulator or device). This is
- * directly derived from --ios_sdk_version. Format "x.y" (for example, "6.4").
+ * directly derived from --ios_sdk_version.
+ *
+ * @deprecated - use {@link #getSdkVersionForPlatform()}
+ */
+ @Deprecated public DottedVersion getIosSdkVersion() {
+ return getSdkVersionForPlatform(Platform.IOS_DEVICE);
+ }
+
+ /**
+ * Returns the SDK version for a platform (whether they be for simulator or device). This is
+ * directly derived from command line args.
*/
- public DottedVersion getIosSdkVersion() {
- return iosSdkVersion;
+ public DottedVersion getSdkVersionForPlatform(Platform platform) {
+ switch (platform) {
+ case IOS_DEVICE:
+ case IOS_SIMULATOR:
+ return iosSdkVersion;
+ case TVOS_DEVICE:
+ case TVOS_SIMULATOR:
+ return tvOsSdkVersion;
+ case WATCHOS_DEVICE:
+ case WATCHOS_SIMULATOR:
+ return watchOsSdkVersion;
+ case MACOS_X:
+ return macOsXSdkVersion;
+ }
+ throw new AssertionError();
+
}
/**
@@ -137,7 +171,8 @@ public class AppleConfiguration extends BuildConfiguration.Fragment {
// TODO(bazel-team): Handle non-ios platforms.
if (platform == Platform.IOS_DEVICE || platform == Platform.IOS_SIMULATOR) {
- builder.put(AppleConfiguration.APPLE_SDK_VERSION_ENV_NAME, getIosSdkVersion().toString())
+ String sdkVersion = getSdkVersionForPlatform(platform).toString();
+ builder.put(AppleConfiguration.APPLE_SDK_VERSION_ENV_NAME, sdkVersion)
.put(AppleConfiguration.APPLE_SDK_PLATFORM_ENV_NAME, platform.getNameInPlist());
}
return builder.build();
diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java
index 7e74dfb65a..3100aff062 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java
@@ -122,7 +122,8 @@ public class AppleToolchain {
switch (targetPlatform) {
case IOS_DEVICE:
case IOS_SIMULATOR:
- if (configuration.getIosSdkVersion().compareTo(DottedVersion.fromString("9.0")) >= 0) {
+ if (configuration.getSdkVersionForPlatform(targetPlatform)
+ .compareTo(DottedVersion.fromString("9.0")) >= 0) {
relativePath = SYSTEM_FRAMEWORK_PATH;
} else {
relativePath = DEVELOPER_FRAMEWORK_PATH;