Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.4.0] Add visionOS support #19436

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ bazel_dep(name = "rules_license", version = "0.0.3")
bazel_dep(name = "bazel_skylib", version = "1.2.0")
bazel_dep(name = "protobuf", version = "3.19.6", repo_name = "com_google_protobuf")
bazel_dep(name = "grpc", version = "1.47.0", repo_name = "com_github_grpc_grpc")
bazel_dep(name = "platforms", version = "0.0.5")
bazel_dep(name = "platforms", version = "0.0.7")
bazel_dep(name = "rules_pkg", version = "0.7.0")
bazel_dep(name = "stardoc", version = "0.5.0", repo_name = "io_bazel_skydoc")
bazel_dep(name = "zstd-jni", version = "1.5.2-3")
Expand Down
9 changes: 5 additions & 4 deletions distdir_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ DIST_DEPS = {
#
########################################
"platforms": {
"archive": "platforms-0.0.5.tar.gz",
"sha256": "379113459b0feaf6bfbb584a91874c065078aa673222846ac765f86661c27407",
"archive": "platforms-0.0.7.tar.gz",
"sha256": "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51",
"urls": [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
],
"used_in": [
"additional_distfiles",
"test_WORKSPACE_files",
],
"package_version": "0.0.7",
},
"bazelci_rules": {
"archive": "bazelci_rules-1.0.0.tar.gz",
Expand Down
2 changes: 1 addition & 1 deletion src/MODULE.tools
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ bazel_dep(name = "rules_license", version = "0.0.3")
bazel_dep(name = "rules_proto", version = "4.0.0")
bazel_dep(name = "rules_python", version = "0.4.0")

bazel_dep(name = "platforms", version = "0.0.4")
bazel_dep(name = "platforms", version = "0.0.7")
bazel_dep(name = "protobuf", version = "3.19.6", repo_name = "com_google_protobuf")
bazel_dep(name = "zlib", version = "1.2.13")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#end

<li><a href="${bazelbuildGithub}/rules_appengine" target="_blank" rel="noopener">AppEngine</a></li>
<li><a href="${bazelbuildGithub}/rules_apple" target="_blank" rel="noopener">Apple (Swift, iOS, macOS, tvOS, watchOS)</a></li>
<li><a href="${bazelbuildGithub}/rules_apple" target="_blank" rel="noopener">Apple (Swift, iOS, macOS, tvOS, visionOS, watchOS)</a></li>
<li><a href="${bazelbuildGithub}/rules_dotnet" target="_blank" rel="noopener">C#</a></li>
<li><a href="${bazelbuildGithub}/rules_d" target="_blank" rel="noopener">D</a></li>
<li><a href="${bazelbuildGithub}/rules_docker" target="_blank" rel="noopener">Docker</a></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ toc:
- title: AppEngine
path: https://github.com/bazelbuild/rules_appengine
status: external
- title: Apple (Swift, iOS, macOS, tvOS, watchOS)
- title: Apple (Swift, iOS, macOS, tvOS, visionOS, watchOS)
path: https://github.com/bazelbuild/rules_apple
status: external
- title: C#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private static String moduleFileContent(String repositoryName) {
"module(name = \"%s\")",
// Try to keep this updated with the src/MODULE.tools file. (Due to MVS, even if this is
// not kept up to date, we'll use the latest version anyhow)
"bazel_dep(name = \"platforms\", version = \"0.0.4\")"),
"bazel_dep(name = \"platforms\", version = \"0.0.7\")"),
repositoryName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ public class AppleCommandLineOptions extends FragmentOptions {
@VisibleForTesting public static final String DEFAULT_TVOS_SDK_VERSION = "9.0";
@VisibleForTesting static final String DEFAULT_IOS_CPU = "x86_64";

/** The default visionOS CPU value. */
public static final String DEFAULT_VISIONOS_CPU =
CPU.getCurrent() == CPU.AARCH64 ? "sim_arm64" : "x86_64";

/** The default watchos CPU value. */
public static final String DEFAULT_WATCHOS_CPU =
CPU.getCurrent() == CPU.AARCH64 ? "arm64" : "i386";
Expand Down Expand Up @@ -297,6 +301,16 @@ public class AppleCommandLineOptions extends FragmentOptions {
+ "is a universal binary containing all specified architectures.")
public List<String> iosMultiCpus;

@Option(
name = "visionos_cpus",
allowMultiple = true,
converter = CommaSeparatedOptionListConverter.class,
defaultValue = "null",
documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
effectTags = {OptionEffectTag.LOSES_INCREMENTAL_STATE, OptionEffectTag.LOADING_AND_ANALYSIS},
help = "Comma-separated list of architectures for which to build Apple visionOS binaries.")
public List<String> visionosCpus;

@Option(
name = "watchos_cpus",
allowMultiple = true,
Expand Down Expand Up @@ -420,6 +434,10 @@ public DottedVersion getMinimumOsVersion() {
case TVOS:
option = tvosMinimumOs;
break;
case VISIONOS:
// TODO: Replace with CppOptions.minimumOsVersion
option = DottedVersion.option(DottedVersion.fromStringUnchecked("1.0"));
break;
case WATCHOS:
option = watchosMinimumOs;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ public static AppleCpus create(AppleCommandLineOptions options, CoreOptions core
(options.iosMultiCpus == null || options.iosMultiCpus.isEmpty())
? ImmutableList.of(iosCpuFromCpu(coreOptions.cpu))
: ImmutableList.copyOf(options.iosMultiCpus);
ImmutableList<String> visionosCpus =
(options.visionosCpus == null || options.visionosCpus.isEmpty())
? ImmutableList.of(AppleCommandLineOptions.DEFAULT_VISIONOS_CPU)
: ImmutableList.copyOf(options.visionosCpus);
ImmutableList<String> watchosCpus =
(options.watchosCpus == null || options.watchosCpus.isEmpty())
? ImmutableList.of(AppleCommandLineOptions.DEFAULT_WATCHOS_CPU)
Expand All @@ -133,13 +137,21 @@ public static AppleCpus create(AppleCommandLineOptions options, CoreOptions core
: ImmutableList.copyOf(options.catalystCpus);

return new AutoValue_AppleConfiguration_AppleCpus(
appleSplitCpu, iosMultiCpus, watchosCpus, tvosCpus, macosCpus, catalystCpus);
appleSplitCpu,
iosMultiCpus,
visionosCpus,
watchosCpus,
tvosCpus,
macosCpus,
catalystCpus);
}

abstract String appleSplitCpu();

abstract ImmutableList<String> iosMultiCpus();

abstract ImmutableList<String> visionosCpus();

abstract ImmutableList<String> watchosCpus();

abstract ImmutableList<String> tvosCpus();
Expand Down Expand Up @@ -248,6 +260,8 @@ private static String getPrefixedAppleCpu(PlatformType applePlatformType, AppleC
switch (applePlatformType) {
case IOS:
return appleCpus.iosMultiCpus().get(0);
case VISIONOS:
return appleCpus.visionosCpus().get(0);
case WATCHOS:
return appleCpus.watchosCpus().get(0);
case TVOS:
Expand Down Expand Up @@ -296,6 +310,8 @@ public List<String> getMultiArchitectures(PlatformType platformType) {
switch (platformType) {
case IOS:
return appleCpus.iosMultiCpus();
case VISIONOS:
return appleCpus.visionosCpus();
case WATCHOS:
return appleCpus.watchosCpus();
case TVOS:
Expand Down Expand Up @@ -341,6 +357,14 @@ public ApplePlatform getMultiArchPlatform(PlatformType platformType) {
}
}
return ApplePlatform.IOS_SIMULATOR;
case VISIONOS:
for (String arch : architectures) {
if (ApplePlatform.forTarget(PlatformType.VISIONOS, arch)
== ApplePlatform.VISIONOS_DEVICE) {
return ApplePlatform.VISIONOS_DEVICE;
}
}
return ApplePlatform.VISIONOS_SIMULATOR;
case WATCHOS:
for (String arch : architectures) {
if (ApplePlatform.forTarget(PlatformType.WATCHOS, arch) == ApplePlatform.WATCHOS_DEVICE) {
Expand Down Expand Up @@ -500,6 +524,8 @@ public enum ConfigurationDistinguisher implements StarlarkValue {
UNKNOWN("unknown"),
/** Distinguisher for {@code apple_binary} rule with "ios" platform_type. */
APPLEBIN_IOS("applebin_ios"),
/** Distinguisher for {@code apple_binary} rule with "visionos" platform_type. */
APPLEBIN_VISIONOS("applebin_visionos"),
/** Distinguisher for {@code apple_binary} rule with "watchos" platform_type. */
APPLEBIN_WATCHOS("applebin_watchos"),
/** Distinguisher for {@code apple_binary} rule with "tvos" platform_type. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public enum ApplePlatform implements ApplePlatformApi {
MACOS("macos", "MacOSX", PlatformType.MACOS, true),
TVOS_DEVICE("tvos_device", "AppleTVOS", PlatformType.TVOS, true),
TVOS_SIMULATOR("tvos_simulator", "AppleTVSimulator", PlatformType.TVOS, false),
VISIONOS_DEVICE("visionos_device", "XROS", PlatformType.VISIONOS, true),
VISIONOS_SIMULATOR("visionos_simulator", "XRSimulator", PlatformType.VISIONOS, false),
WATCHOS_DEVICE("watchos_device", "WatchOS", PlatformType.WATCHOS, true),
WATCHOS_SIMULATOR("watchos_simulator", "WatchSimulator", PlatformType.WATCHOS, false),
CATALYST("catalyst", "MacOSX", PlatformType.CATALYST, true);
Expand All @@ -45,6 +47,10 @@ public enum ApplePlatform implements ApplePlatformApi {
ImmutableSet.of("ios_x86_64", "ios_i386", "ios_sim_arm64");
private static final ImmutableSet<String> IOS_DEVICE_TARGET_CPUS =
ImmutableSet.of("ios_armv6", "ios_arm64", "ios_armv7", "ios_armv7s", "ios_arm64e");
private static final ImmutableSet<String> VISIONOS_SIMULATOR_TARGET_CPUS =
ImmutableSet.of("visionos_x86_64", "visionos_sim_arm64");
private static final ImmutableSet<String> VISIONOS_DEVICE_TARGET_CPUS =
ImmutableSet.of("visionos_arm64");
private static final ImmutableSet<String> WATCHOS_SIMULATOR_TARGET_CPUS =
ImmutableSet.of("watchos_i386", "watchos_x86_64", "watchos_arm64");
private static final ImmutableSet<String> WATCHOS_DEVICE_TARGET_CPUS =
Expand Down Expand Up @@ -138,6 +144,10 @@ private static ApplePlatform forTargetCpuNullable(String targetCpu) {
return IOS_SIMULATOR;
} else if (IOS_DEVICE_TARGET_CPUS.contains(targetCpu)) {
return IOS_DEVICE;
} else if (VISIONOS_SIMULATOR_TARGET_CPUS.contains(targetCpu)) {
return VISIONOS_SIMULATOR;
} else if (VISIONOS_DEVICE_TARGET_CPUS.contains(targetCpu)) {
return VISIONOS_DEVICE;
} else if (WATCHOS_SIMULATOR_TARGET_CPUS.contains(targetCpu)) {
return WATCHOS_SIMULATOR;
} else if (WATCHOS_DEVICE_TARGET_CPUS.contains(targetCpu)) {
Expand Down Expand Up @@ -245,6 +255,7 @@ public UnsupportedPlatformTypeException(String msg) {
@Immutable
public enum PlatformType implements ApplePlatformTypeApi {
IOS("ios"),
VISIONOS("visionos"),
WATCHOS("watchos"),
TVOS("tvos"),
MACOS("macos"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public static String sdkFrameworkDir(ApplePlatform targetPlatform, XcodeConfigIn
}
break;
case MACOS:
case VISIONOS_DEVICE:
case VISIONOS_SIMULATOR:
case WATCHOS_DEVICE:
case WATCHOS_SIMULATOR:
case TVOS_DEVICE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ public ConfiguredTarget create(RuleContext ruleContext)
(appleOptions.iosMinimumOs != null)
? DottedVersion.maybeUnwrap(appleOptions.iosMinimumOs)
: iosSdkVersion;
DottedVersion visionosSdkVersion = xcodeVersionProperties.getDefaultVisionosSdkVersion();
// TODO: Replace with CppOptions.minimumOsVersion
DottedVersion visionosMinimumOsVersion = DottedVersion.fromStringUnchecked("1.0");
DottedVersion watchosSdkVersion =
(appleOptions.watchOsSdkVersion != null)
? DottedVersion.maybeUnwrap(appleOptions.watchOsSdkVersion)
Expand Down Expand Up @@ -155,6 +158,8 @@ public ConfiguredTarget create(RuleContext ruleContext)
new XcodeConfigInfo(
iosSdkVersion,
iosMinimumOsVersion,
visionosSdkVersion,
visionosMinimumOsVersion,
watchosSdkVersion,
watchosMinimumOsVersion,
tvosSdkVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class XcodeConfigInfo extends NativeInfo

private final DottedVersion iosSdkVersion;
private final DottedVersion iosMinimumOsVersion;
private final DottedVersion visionosSdkVersion;
private final DottedVersion visionosMinimumOsVersion;
private final DottedVersion watchosSdkVersion;
private final DottedVersion watchosMinimumOsVersion;
private final DottedVersion tvosSdkVersion;
Expand All @@ -52,6 +54,8 @@ public class XcodeConfigInfo extends NativeInfo
public XcodeConfigInfo(
DottedVersion iosSdkVersion,
DottedVersion iosMinimumOsVersion,
DottedVersion visionosSdkVersion,
DottedVersion visionosMinimumOsVersion,
DottedVersion watchosSdkVersion,
DottedVersion watchosMinimumOsVersion,
DottedVersion tvosSdkVersion,
Expand All @@ -64,6 +68,8 @@ public XcodeConfigInfo(
boolean includeXcodeReqs) {
this.iosSdkVersion = Preconditions.checkNotNull(iosSdkVersion);
this.iosMinimumOsVersion = Preconditions.checkNotNull(iosMinimumOsVersion);
this.visionosSdkVersion = Preconditions.checkNotNull(visionosSdkVersion);
this.visionosMinimumOsVersion = Preconditions.checkNotNull(visionosMinimumOsVersion);
this.watchosSdkVersion = Preconditions.checkNotNull(watchosSdkVersion);
this.watchosMinimumOsVersion = Preconditions.checkNotNull(watchosMinimumOsVersion);
this.tvosSdkVersion = Preconditions.checkNotNull(tvosSdkVersion);
Expand Down Expand Up @@ -135,6 +141,8 @@ private XcodeConfigProvider() {
public XcodeConfigInfoApi<?, ?> xcodeConfigInfo(
String iosSdkVersion,
String iosMinimumOsVersion,
String visionosSdkVersion,
String visionosMinimumOsVersion,
String watchosSdkVersion,
String watchosMinimumOsVersion,
String tvosSdkVersion,
Expand All @@ -147,6 +155,8 @@ private XcodeConfigProvider() {
return new XcodeConfigInfo(
DottedVersion.fromString(iosSdkVersion),
DottedVersion.fromString(iosMinimumOsVersion),
DottedVersion.fromString(visionosSdkVersion),
DottedVersion.fromString(visionosMinimumOsVersion),
DottedVersion.fromString(watchosSdkVersion),
DottedVersion.fromString(watchosMinimumOsVersion),
DottedVersion.fromString(tvosSdkVersion),
Expand Down Expand Up @@ -195,6 +205,9 @@ public DottedVersion getMinimumOsForPlatformType(ApplePlatform.PlatformType plat
return iosMinimumOsVersion;
case TVOS:
return tvosMinimumOsVersion;
case VISIONOS:
// TODO: Replace with CppOptions.minimumOsVersion
return DottedVersion.fromStringUnchecked("1.0");
case WATCHOS:
return watchosMinimumOsVersion;
case MACOS:
Expand All @@ -216,6 +229,9 @@ public DottedVersion getSdkVersionForPlatform(ApplePlatform platform) {
case TVOS_DEVICE:
case TVOS_SIMULATOR:
return tvosSdkVersion;
case VISIONOS_DEVICE:
case VISIONOS_SIMULATOR:
return visionosSdkVersion;
case WATCHOS_DEVICE:
case WATCHOS_SIMULATOR:
return watchosSdkVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ public class XcodeVersionProperties extends NativeInfo implements XcodePropertie
new BuiltinProvider<XcodeVersionProperties>(STARLARK_NAME, XcodeVersionProperties.class) {};

@VisibleForTesting public static final String DEFAULT_IOS_SDK_VERSION = "8.4";
@VisibleForTesting public static final String DEFAULT_VISIONOS_SDK_VERSION = "1.0";
@VisibleForTesting public static final String DEFAULT_WATCHOS_SDK_VERSION = "2.0";
@VisibleForTesting public static final String DEFAULT_MACOS_SDK_VERSION = "10.11";
@VisibleForTesting public static final String DEFAULT_TVOS_SDK_VERSION = "9.0";

private final Optional<DottedVersion> xcodeVersion;
private final DottedVersion defaultIosSdkVersion;
private final DottedVersion defaultVisionosSdkVersion;
private final DottedVersion defaultWatchosSdkVersion;
private final DottedVersion defaultTvosSdkVersion;
private final DottedVersion defaultMacosSdkVersion;
Expand All @@ -63,7 +65,7 @@ public static XcodeVersionProperties unknownXcodeVersionProperties() {
* specified.
*/
XcodeVersionProperties(DottedVersion xcodeVersion) {
this(xcodeVersion, null, null, null, null);
this(xcodeVersion, null, null, null, null, null);
}

/**
Expand All @@ -73,6 +75,7 @@ public static XcodeVersionProperties unknownXcodeVersionProperties() {
XcodeVersionProperties(
DottedVersion xcodeVersion,
@Nullable String defaultIosSdkVersion,
@Nullable String defaultVisionosSdkVersion,
@Nullable String defaultWatchosSdkVersion,
@Nullable String defaultTvosSdkVersion,
@Nullable String defaultMacosSdkVersion) {
Expand All @@ -81,6 +84,10 @@ public static XcodeVersionProperties unknownXcodeVersionProperties() {
Strings.isNullOrEmpty(defaultIosSdkVersion)
? DottedVersion.fromStringUnchecked(DEFAULT_IOS_SDK_VERSION)
: DottedVersion.fromStringUnchecked(defaultIosSdkVersion);
this.defaultVisionosSdkVersion =
Strings.isNullOrEmpty(defaultVisionosSdkVersion)
? DottedVersion.fromStringUnchecked(DEFAULT_VISIONOS_SDK_VERSION)
: DottedVersion.fromStringUnchecked(defaultVisionosSdkVersion);
this.defaultWatchosSdkVersion =
Strings.isNullOrEmpty(defaultWatchosSdkVersion)
? DottedVersion.fromStringUnchecked(DEFAULT_WATCHOS_SDK_VERSION)
Expand Down Expand Up @@ -117,6 +124,13 @@ public String getDefaultIosSdkVersionString() {
return defaultIosSdkVersion != null ? defaultIosSdkVersion.toString() : null;
}

/** Returns the default visionOS sdk version to use if this xcode version is in use. */
@Nullable
@Override
public String getDefaultVisionosSdkVersionString() {
return defaultVisionosSdkVersion != null ? defaultVisionosSdkVersion.toString() : null;
}

/** Returns the default watchos sdk version to use if this xcode version is in use. */
@Nullable
@Override
Expand Down Expand Up @@ -148,6 +162,11 @@ public DottedVersion getDefaultIosSdkVersion() {
return defaultIosSdkVersion;
}

@Nullable
public DottedVersion getDefaultVisionosSdkVersion() {
return defaultVisionosSdkVersion;
}

@Nullable
public DottedVersion getDefaultWatchosSdkVersion() {
return defaultWatchosSdkVersion;
Expand All @@ -174,6 +193,7 @@ public boolean equals(Object other) {
XcodeVersionProperties otherData = (XcodeVersionProperties) other;
return xcodeVersion.equals(otherData.getXcodeVersion())
&& defaultIosSdkVersion.equals(otherData.getDefaultIosSdkVersion())
&& defaultVisionosSdkVersion.equals(otherData.getDefaultVisionosSdkVersion())
&& defaultWatchosSdkVersion.equals(otherData.getDefaultWatchosSdkVersion())
&& defaultTvosSdkVersion.equals(otherData.getDefaultTvosSdkVersion())
&& defaultMacosSdkVersion.equals(otherData.getDefaultMacosSdkVersion());
Expand All @@ -184,6 +204,7 @@ public int hashCode() {
return Objects.hash(
xcodeVersion,
defaultIosSdkVersion,
defaultVisionosSdkVersion,
defaultWatchosSdkVersion,
defaultTvosSdkVersion,
defaultMacosSdkVersion);
Expand Down
Loading