aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-09-19 17:45:44 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2016-09-20 06:45:47 +0000
commit35b50d26893147c642eeb48b8247350a87f03741 (patch)
tree5cef08fd54cb878a1d3eb3a3d03e6706424fa124 /src
parent2b137e8735fc90d09fc998373e7ae15d34bb9f9c (diff)
Add minimum OS, simulator version, and simulator device flags for tvOS and watchOS.
Currently, the minimum watchOS version is always fixed to the SDK version being used, which may not always be desired (for example, building with the 3.0 SDK but support running on 2.2). The watch flags aren't being used yet (nor are the tvOS flags), but will pave the way for us to fix that. The necessary CROSSTOOL support is in unknown commit. -- MOS_MIGRATED_REVID=133602832
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java16
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java17
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java12
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionProperties.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java20
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchSplitTransitionProvider.java7
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java64
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java74
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcVariablesExtension.java12
10 files changed, 212 insertions, 14 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 b014ecc7fd..57cf37506b 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
@@ -85,7 +85,7 @@ public class AppleCommandLineOptions extends FragmentOptions {
@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";
+ @VisibleForTesting public static final String DEFAULT_TVOS_SDK_VERSION = "9.0";
@VisibleForTesting static final String DEFAULT_IOS_CPU = "x86_64";
/**
@@ -93,6 +93,11 @@ public class AppleCommandLineOptions extends FragmentOptions {
*/
public static final String DEFAULT_WATCHOS_CPU = "i386";
+ /**
+ * The default tvOS CPU value.
+ */
+ public static final String DEFAULT_TVOS_CPU = "x86_64";
+
@Option(name = "ios_cpu",
defaultValue = DEFAULT_IOS_CPU,
category = "build",
@@ -140,9 +145,16 @@ public class AppleCommandLineOptions extends FragmentOptions {
converter = CommaSeparatedOptionListConverter.class,
defaultValue = DEFAULT_WATCHOS_CPU,
category = "flags",
- help = "Comma-separated list of architectures for which to build apple watchos binaries.")
+ help = "Comma-separated list of architectures for which to build Apple watchOS binaries.")
public List<String> watchosCpus;
+ @Option(name = "tvos_cpus",
+ converter = CommaSeparatedOptionListConverter.class,
+ defaultValue = DEFAULT_TVOS_CPU,
+ category = "flags",
+ help = "Comma-separated list of architectures for which to build Apple tvOS binaries.")
+ public List<String> tvosCpus;
+
@Option(name = "default_ios_provisioning_profile",
defaultValue = "",
category = "undocumented",
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 c1d2248eef..8bb609c2e9 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
@@ -78,6 +78,7 @@ public class AppleConfiguration extends BuildConfiguration.Fragment {
private final Optional<DottedVersion> xcodeVersion;
private final ImmutableList<String> iosMultiCpus;
private final ImmutableList<String> watchosCpus;
+ private final ImmutableList<String> tvosCpus;
private final AppleBitcodeMode bitcodeMode;
private final Label xcodeConfigLabel;
@Nullable private final Label defaultProvisioningProfileLabel;
@@ -107,6 +108,9 @@ public class AppleConfiguration extends BuildConfiguration.Fragment {
this.watchosCpus = (appleOptions.watchosCpus == null || appleOptions.watchosCpus.isEmpty())
? ImmutableList.of(AppleCommandLineOptions.DEFAULT_WATCHOS_CPU)
: ImmutableList.copyOf(appleOptions.watchosCpus);
+ this.tvosCpus = (appleOptions.tvosCpus == null || appleOptions.tvosCpus.isEmpty())
+ ? ImmutableList.of(AppleCommandLineOptions.DEFAULT_TVOS_CPU)
+ : ImmutableList.copyOf(appleOptions.tvosCpus);
this.bitcodeMode = appleOptions.appleBitcodeMode;
this.xcodeConfigLabel =
Preconditions.checkNotNull(appleOptions.xcodeVersionConfig, "xcodeConfigLabel");
@@ -265,6 +269,8 @@ public class AppleConfiguration extends BuildConfiguration.Fragment {
}
case WATCHOS:
return watchosCpus.get(0);
+ case TVOS:
+ return tvosCpus.get(0);
// TODO(cparsons): Handle all platform types.
default:
throw new IllegalArgumentException("Unhandled platform type " + applePlatformType);
@@ -307,6 +313,8 @@ public class AppleConfiguration extends BuildConfiguration.Fragment {
}
case WATCHOS:
return watchosCpus;
+ case TVOS:
+ return tvosCpus;
default:
throw new IllegalArgumentException("Unhandled platform type " + platformType);
}
@@ -358,6 +366,13 @@ public class AppleConfiguration extends BuildConfiguration.Fragment {
}
}
return Platform.WATCHOS_SIMULATOR;
+ case TVOS:
+ for (String arch : architectures) {
+ if (Platform.forTarget(PlatformType.TVOS, arch) == Platform.TVOS_DEVICE) {
+ return Platform.TVOS_DEVICE;
+ }
+ }
+ return Platform.TVOS_SIMULATOR;
default:
throw new IllegalArgumentException("Unsupported platform type " + platformType);
}
@@ -545,5 +560,7 @@ public class AppleConfiguration extends BuildConfiguration.Fragment {
APPLEBIN_IOS,
/** Distinguisher for {@code apple_binary} rule with "watchos" platform_type. */
APPLEBIN_WATCHOS,
+ /** Distinguisher for {@code apple_binary} rule with "tvos" platform_type. */
+ APPLEBIN_TVOS,
}
}
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 ad8202b578..226ad79383 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
@@ -129,6 +129,8 @@ public class AppleToolchain {
break;
case WATCHOS_DEVICE:
case WATCHOS_SIMULATOR:
+ case TVOS_DEVICE:
+ case TVOS_SIMULATOR:
relativePath = SYSTEM_FRAMEWORK_PATH;
break;
default:
diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java b/src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java
index c9f9ac956e..19b940ad03 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java
@@ -45,12 +45,16 @@ public enum Platform {
private static final Set<String> IOS_SIMULATOR_TARGET_CPUS =
ImmutableSet.of("ios_x86_64", "ios_i386");
+ private static final Set<String> IOS_DEVICE_TARGET_CPUS =
+ ImmutableSet.of("ios_armv6", "ios_arm64", "ios_armv7", "ios_armv7s");
private static final Set<String> WATCHOS_SIMULATOR_TARGET_CPUS =
ImmutableSet.of("watchos_i386");
private static final Set<String> WATCHOS_DEVICE_TARGET_CPUS =
ImmutableSet.of("watchos_armv7k");
- private static final Set<String> IOS_DEVICE_TARGET_CPUS =
- ImmutableSet.of("ios_armv6", "ios_arm64", "ios_armv7", "ios_armv7s");
+ private static final Set<String> TVOS_SIMULATOR_TARGET_CPUS =
+ ImmutableSet.of("tvos_x86_64");
+ private static final Set<String> TVOS_DEVICE_TARGET_CPUS =
+ ImmutableSet.of("tvos_arm64");
private static final Set<String> MACOSX_TARGET_CPUS =
ImmutableSet.of("darwin_x86_64");
@@ -116,6 +120,10 @@ public enum Platform {
return WATCHOS_SIMULATOR;
} else if (WATCHOS_DEVICE_TARGET_CPUS.contains(targetCpu)) {
return WATCHOS_DEVICE;
+ } else if (TVOS_SIMULATOR_TARGET_CPUS.contains(targetCpu)) {
+ return TVOS_SIMULATOR;
+ } else if (TVOS_DEVICE_TARGET_CPUS.contains(targetCpu)) {
+ return TVOS_DEVICE;
} else if (MACOSX_TARGET_CPUS.contains(targetCpu)) {
return MACOS_X;
} else {
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 572574db1d..13b35814b9 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
@@ -28,7 +28,7 @@ public class XcodeVersionProperties implements TransitiveInfoProvider {
@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";
+ @VisibleForTesting public static final String DEFAULT_TVOS_SDK_VERSION = "9.0";
private final Optional<DottedVersion> xcodeVersion;
private final DottedVersion defaultIosSdkVersion;
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
index 3a5a370491..7faa6a516d 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
@@ -1753,19 +1753,33 @@ public final class CompilationSupport {
Platform platform = appleConfiguration.getSingleArchPlatform();
switch (platform) {
case IOS_SIMULATOR:
- builder.add("-mios-simulator-version-min=" + objcConfiguration.getMinimumOs());
+ builder.add("-mios-simulator-version-min="
+ + objcConfiguration.getMinimumOsForPlatformType(platform.getType()));
break;
case IOS_DEVICE:
- builder.add("-miphoneos-version-min=" + objcConfiguration.getMinimumOs());
+ builder.add("-miphoneos-version-min="
+ + objcConfiguration.getMinimumOsForPlatformType(platform.getType()));
break;
case WATCHOS_SIMULATOR:
+ // TODO(bazel-team): Use the value from --watchos-minimum-os instead of tying to the SDK
+ // version.
builder.add("-mwatchos-simulator-version-min="
+ appleConfiguration.getSdkVersionForPlatform(platform));
break;
case WATCHOS_DEVICE:
+ // TODO(bazel-team): Use the value from --watchos-minimum-os instead of tying to the SDK
+ // version.
builder.add("-mwatchos-version-min="
+ appleConfiguration.getSdkVersionForPlatform(platform));
break;
+ case TVOS_SIMULATOR:
+ builder.add("-mtvos-simulator-version-min="
+ + objcConfiguration.getMinimumOsForPlatformType(platform.getType()));
+ break;
+ case TVOS_DEVICE:
+ builder.add("-mtvos-version-min="
+ + objcConfiguration.getMinimumOsForPlatformType(platform.getType()));
+ break;
default:
throw new IllegalArgumentException("Unhandled platform " + platform);
}
@@ -1827,9 +1841,11 @@ public final class CompilationSupport {
switch (configuration.getSingleArchPlatform()) {
case IOS_DEVICE:
case WATCHOS_DEVICE:
+ case TVOS_DEVICE:
return ImmutableList.of();
case IOS_SIMULATOR:
case WATCHOS_SIMULATOR:
+ case TVOS_SIMULATOR:
return SIMULATOR_COMPILE_FLAGS;
default:
throw new AssertionError();
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchSplitTransitionProvider.java b/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchSplitTransitionProvider.java
index 35026f38a5..d7c7430696 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchSplitTransitionProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchSplitTransitionProvider.java
@@ -141,6 +141,13 @@ public class MultiArchSplitTransitionProvider implements SplitTransitionProvider
}
configurationDistinguisher = ConfigurationDistinguisher.APPLEBIN_WATCHOS;
break;
+ case TVOS:
+ cpus = buildOptions.get(AppleCommandLineOptions.class).tvosCpus;
+ if (cpus.isEmpty()) {
+ cpus = ImmutableList.of(AppleCommandLineOptions.DEFAULT_TVOS_CPU);
+ }
+ configurationDistinguisher = ConfigurationDistinguisher.APPLEBIN_TVOS;
+ break;
default:
throw new IllegalArgumentException("Unsupported platform type " + platformType);
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java
index 0310a6d201..86c0c0734f 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java
@@ -51,6 +51,40 @@ public class ObjcCommandLineOptions extends FragmentOptions {
+ "on the machine the simulator will be run on.")
public String iosSimulatorDevice;
+ @Option(
+ name = "watchos_simulator_version",
+ defaultValue = "2.0",
+ category = "run",
+ converter = DottedVersionConverter.class,
+ help = "The version of watchOS to run on the simulator when running or testing."
+ )
+ public DottedVersion watchosSimulatorVersion;
+
+ @Option(name = "watchos_simulator_device",
+ defaultValue = "Apple Watch - 38mm",
+ category = "run",
+ help = "The device to simulate when running an watchOS application in the simulator, e.g. "
+ + "'Apple Watch - 38mm'. You can get a list of devices by running 'xcrun simctl list "
+ + "devicetypes' on the machine the simulator will be run on.")
+ public String watchosSimulatorDevice;
+
+ @Option(
+ name = "tvos_simulator_version",
+ defaultValue = "9.0",
+ category = "run",
+ converter = DottedVersionConverter.class,
+ help = "The version of tvOS to run on the simulator when running or testing."
+ )
+ public DottedVersion tvosSimulatorVersion;
+
+ @Option(name = "tvos_simulator_device",
+ defaultValue = "Apple TV 1080p",
+ category = "run",
+ help = "The device to simulate when running an tvOS application in the simulator, e.g. "
+ + "'Apple TV 1080p'. You can get a list of devices by running 'xcrun simctl list "
+ + "devicetypes' on the machine the simulator will be run on.")
+ public String tvosSimulatorDevice;
+
@Option(name = "objc_generate_linkmap",
defaultValue = "false",
category = "flags",
@@ -65,14 +99,32 @@ public class ObjcCommandLineOptions extends FragmentOptions {
public List<String> copts;
@Option(
- name = "ios_minimum_os",
- defaultValue = DEFAULT_MINIMUM_IOS,
- category = "flags",
- converter = DottedVersionConverter.class,
- help = "Minimum compatible iOS version for target simulators and devices."
+ name = "ios_minimum_os",
+ defaultValue = DEFAULT_MINIMUM_IOS,
+ category = "flags",
+ converter = DottedVersionConverter.class,
+ help = "Minimum compatible iOS version for target simulators and devices."
)
public DottedVersion iosMinimumOs;
+ @Option(
+ name = "watchos_minimum_os",
+ defaultValue = DEFAULT_MINIMUM_WATCHOS,
+ category = "flags",
+ converter = DottedVersionConverter.class,
+ help = "Minimum compatible watchOS version for target simulators and devices."
+ )
+ public DottedVersion watchosMinimumOs;
+
+ @Option(
+ name = "tvos_minimum_os",
+ defaultValue = DEFAULT_MINIMUM_TVOS,
+ category = "flags",
+ converter = DottedVersionConverter.class,
+ help = "Minimum compatible tvOS version for target simulators and devices."
+ )
+ public DottedVersion tvosMinimumOs;
+
@Option(name = "ios_memleaks",
defaultValue = "false",
category = "misc",
@@ -198,6 +250,8 @@ public class ObjcCommandLineOptions extends FragmentOptions {
public boolean experimentalObjcLibrary;
@VisibleForTesting static final String DEFAULT_MINIMUM_IOS = "7.0";
+ @VisibleForTesting static final String DEFAULT_MINIMUM_WATCHOS = "2.0";
+ @VisibleForTesting static final String DEFAULT_MINIMUM_TVOS = "9.0";
@SuppressWarnings("unchecked")
@Override
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java
index 4478b3e01e..4726669365 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java
@@ -22,6 +22,7 @@ import com.google.devtools.build.lib.analysis.config.CompilationMode;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.rules.apple.DottedVersion;
+import com.google.devtools.build.lib.rules.apple.Platform.PlatformType;
import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
@@ -55,6 +56,12 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment {
private final DottedVersion iosMinimumOs;
private final DottedVersion iosSimulatorVersion;
private final String iosSimulatorDevice;
+ private final DottedVersion watchosMinimumOs;
+ private final DottedVersion watchosSimulatorVersion;
+ private final String watchosSimulatorDevice;
+ private final DottedVersion tvosMinimumOs;
+ private final DottedVersion tvosSimulatorVersion;
+ private final String tvosSimulatorDevice;
private final boolean generateDsym;
private final boolean generateLinkmap;
private final boolean runMemleaks;
@@ -80,6 +87,17 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment {
Preconditions.checkNotNull(objcOptions.iosSimulatorDevice, "iosSimulatorDevice");
this.iosSimulatorVersion =
Preconditions.checkNotNull(objcOptions.iosSimulatorVersion, "iosSimulatorVersion");
+ this.watchosMinimumOs =
+ Preconditions.checkNotNull(objcOptions.watchosMinimumOs, "watchosMinimumOs");
+ this.watchosSimulatorDevice =
+ Preconditions.checkNotNull(objcOptions.watchosSimulatorDevice, "watchosSimulatorDevice");
+ this.watchosSimulatorVersion =
+ Preconditions.checkNotNull(objcOptions.watchosSimulatorVersion, "watchosSimulatorVersion");
+ this.tvosMinimumOs = Preconditions.checkNotNull(objcOptions.tvosMinimumOs, "tvosMinimumOs");
+ this.tvosSimulatorDevice =
+ Preconditions.checkNotNull(objcOptions.tvosSimulatorDevice, "tvosSimulatorDevice");
+ this.tvosSimulatorVersion =
+ Preconditions.checkNotNull(objcOptions.tvosSimulatorVersion, "tvosSimulatorVersion");
this.generateDsym = objcOptions.appleGenerateDsym;
this.generateLinkmap = objcOptions.generateLinkmap;
this.runMemleaks = objcOptions.runMemleaks;
@@ -105,8 +123,9 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment {
* runtime OS supports them.
*/
@SkylarkCallable(name = "ios_minimum_os", structField = true,
- doc = "The minimum compatible iOS version for target simulators and devices..")
+ doc = "The minimum compatible iOS version for target simulators and devices.")
public DottedVersion getMinimumOs() {
+ // TODO(bazel-team): Deprecate in favor of getMinimumOsForPlatformType(IOS).
return iosMinimumOs;
}
@@ -116,15 +135,68 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment {
@SkylarkCallable(name = "ios_simulator_device", structField = true,
doc = "The type of device (e.g. 'iPhone 6') to use when running on the simulator.")
public String getIosSimulatorDevice() {
+ // TODO(bazel-team): Deprecate in favor of getSimulatorDeviceForPlatformType(IOS).
return iosSimulatorDevice;
}
@SkylarkCallable(name = "ios_simulator_version", structField = true,
doc = "The SDK version of the iOS simulator to use when running on the simulator.")
public DottedVersion getIosSimulatorVersion() {
+ // TODO(bazel-team): Deprecate in favor of getSimulatorVersionForPlatformType(IOS).
return iosSimulatorVersion;
}
+ @SkylarkCallable(
+ name = "minimum_os_for_platform_type",
+ doc = "The minimum compatible OS version for target simulator and devices for a particular "
+ + "platform type.")
+ public DottedVersion getMinimumOsForPlatformType(PlatformType platformType) {
+ switch (platformType) {
+ case IOS:
+ return iosMinimumOs;
+ case TVOS:
+ return tvosMinimumOs;
+ case WATCHOS:
+ return watchosMinimumOs;
+ default:
+ throw new IllegalArgumentException("Unhandled platform: " + platformType);
+ }
+ }
+
+ @SkylarkCallable(
+ name = "simulator_device_for_platform_type",
+ doc = "The type of device (e.g., 'iPhone 6' to simulate when running on the simulator.")
+ public String getSimulatorDeviceForPlatformType(PlatformType platformType) {
+ switch (platformType) {
+ case IOS:
+ return iosSimulatorDevice;
+ case TVOS:
+ return tvosSimulatorDevice;
+ case WATCHOS:
+ return watchosSimulatorDevice;
+ default:
+ throw new IllegalArgumentException("Platform type " + platformType + " does not support "
+ + "simulators.");
+ }
+ }
+
+ @SkylarkCallable(
+ name = "simulator_version_for_platform_type",
+ doc = "The SDK version of the simulator to use when running on the simulator.")
+ public DottedVersion getSimulatorVersionForPlatformType(PlatformType platformType) {
+ switch (platformType) {
+ case IOS:
+ return iosSimulatorVersion;
+ case TVOS:
+ return tvosSimulatorVersion;
+ case WATCHOS:
+ return watchosSimulatorVersion;
+ default:
+ throw new IllegalArgumentException("Platform type " + platformType + " does not support "
+ + "simulators.");
+ }
+ }
+
/**
* Returns whether dSYM generation is enabled.
*/
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcVariablesExtension.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcVariablesExtension.java
index 70fc868af9..51b47ef153 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcVariablesExtension.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcVariablesExtension.java
@@ -23,6 +23,7 @@ import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
import com.google.devtools.build.lib.rules.apple.Platform;
+import com.google.devtools.build.lib.rules.apple.Platform.PlatformType;
import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures;
import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Variables.ValueSequence;
import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Variables.VariablesExtension;
@@ -119,9 +120,18 @@ class ObjcVariablesExtension implements VariablesExtension {
Platform platform = appleConfiguration.getSingleArchPlatform();
switch (platform.getType()) {
case IOS:
- builder.addVariable(VERSION_MIN_VARIABLE_NAME, objcConfiguration.getMinimumOs().toString());
+ builder.addVariable(
+ VERSION_MIN_VARIABLE_NAME,
+ objcConfiguration.getMinimumOsForPlatformType(PlatformType.IOS).toString());
+ break;
+ case TVOS:
+ builder.addVariable(
+ VERSION_MIN_VARIABLE_NAME,
+ objcConfiguration.getMinimumOsForPlatformType(PlatformType.TVOS).toString());
break;
case WATCHOS:
+ // TODO(bazel-team): Use the minimum OS version derived from the flag as is done for the
+ // other platform types.
builder.addVariable(
VERSION_MIN_VARIABLE_NAME,
appleConfiguration.getSdkVersionForPlatform(platform).toString());