xcodeConfigInfo(
String iosSdkVersion,
String iosMinimumOsVersion,
+ String visionosSdkVersion,
+ String visionosMinimumOsVersion,
String watchosSdkVersion,
String watchosMinimumOsVersion,
String tvosSdkVersion,
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodePropertiesApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodePropertiesApi.java
index 4ad4b565dbe5f8..bedfbb42da2d7b 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodePropertiesApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodePropertiesApi.java
@@ -45,6 +45,16 @@ public interface XcodePropertiesApi extends StructApi {
@Nullable
String getDefaultIosSdkVersionString();
+ @StarlarkMethod(
+ name = "default_visionos_sdk_version",
+ doc =
+ "The default visionOS sdk version for this version of xcode, or None
if "
+ + "unknown.",
+ structField = true,
+ allowReturnNones = true)
+ @Nullable
+ String getDefaultVisionosSdkVersionString();
+
@StarlarkMethod(
name = "default_watchos_sdk_version",
doc =
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/objc/AppleCommonApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/objc/AppleCommonApi.java
index fe9ca8d212d44e..75acdb30475dad 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/objc/AppleCommonApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/objc/AppleCommonApi.java
@@ -69,6 +69,7 @@ public interface AppleCommonApi<
+ "ios
" //
+ "macos
" //
+ "tvos
" //
+ + "visionos
" //
+ "watchos
" //
+ "" //
+ "These values can be passed to methods that expect a platform type, like the"
@@ -97,6 +98,8 @@ public interface AppleCommonApi<
+ "
macos
" //
+ "tvos_device
" //
+ "tvos_simulator
" //
+ + "visionos_device
" //
+ + "visionos_simulator
" //
+ "watchos_device
" //
+ "watchos_simulator
" //
+ "" //
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl
index 945a21f53bf548..9b4f7db95e1e1f 100644
--- a/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl
+++ b/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl
@@ -29,6 +29,8 @@ _DYNAMIC_LIBRARY = "dynamic_library"
_IOS_SIMULATOR_TARGET_CPUS = ["ios_x86_64", "ios_i386", "ios_sim_arm64"]
_IOS_DEVICE_TARGET_CPUS = ["ios_armv6", "ios_arm64", "ios_armv7", "ios_armv7s", "ios_arm64e"]
+_VISIONOS_SIMULATOR_TARGET_CPUS = ["visionos_x86_64", "visionos_sim_arm64"]
+_VISIONOS_DEVICE_TARGET_CPUS = ["visionos_arm64"]
_WATCHOS_SIMULATOR_TARGET_CPUS = ["watchos_i386", "watchos_x86_64", "watchos_arm64"]
_WATCHOS_DEVICE_TARGET_CPUS = ["watchos_armv7k", "watchos_arm64_32"]
_TVOS_SIMULATOR_TARGET_CPUS = ["tvos_x86_64", "tvos_sim_arm64"]
@@ -554,7 +556,7 @@ def _is_link_shared(ctx):
return hasattr(ctx.attr, "linkshared") and ctx.attr.linkshared
def _is_apple_platform(target_cpu):
- if target_cpu in _IOS_SIMULATOR_TARGET_CPUS or target_cpu in _IOS_DEVICE_TARGET_CPUS or target_cpu in _WATCHOS_SIMULATOR_TARGET_CPUS or target_cpu in _WATCHOS_DEVICE_TARGET_CPUS or target_cpu in _TVOS_SIMULATOR_TARGET_CPUS or target_cpu in _TVOS_DEVICE_TARGET_CPUS or target_cpu in _CATALYST_TARGET_CPUS or target_cpu in _MACOS_TARGET_CPUS:
+ if target_cpu in _IOS_SIMULATOR_TARGET_CPUS or target_cpu in _IOS_DEVICE_TARGET_CPUS or target_cpu in _VISIONOS_SIMULATOR_TARGET_CPUS or target_cpu in _VISIONOS_DEVICE_TARGET_CPUS or target_cpu in _WATCHOS_SIMULATOR_TARGET_CPUS or target_cpu in _WATCHOS_DEVICE_TARGET_CPUS or target_cpu in _TVOS_SIMULATOR_TARGET_CPUS or target_cpu in _TVOS_DEVICE_TARGET_CPUS or target_cpu in _CATALYST_TARGET_CPUS or target_cpu in _MACOS_TARGET_CPUS:
return True
return False
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_test.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_test.bzl
index ca8aad88b21e82..6130fdddf40603 100644
--- a/src/main/starlark/builtins_bzl/common/cc/cc_test.bzl
+++ b/src/main/starlark/builtins_bzl/common/cc/cc_test.bzl
@@ -103,6 +103,7 @@ def make_cc_test(with_linkstatic = False, with_aspects = False):
"@" + paths.join(semantics.get_platforms_root(), "os:ios"),
"@" + paths.join(semantics.get_platforms_root(), "os:macos"),
"@" + paths.join(semantics.get_platforms_root(), "os:tvos"),
+ "@" + paths.join(semantics.get_platforms_root(), "os:visionos"),
"@" + paths.join(semantics.get_platforms_root(), "os:watchos"),
],
),
diff --git a/src/main/starlark/builtins_bzl/common/java/java_binary.bzl b/src/main/starlark/builtins_bzl/common/java/java_binary.bzl
index c2178b226d56c8..676eb77f895ec4 100644
--- a/src/main/starlark/builtins_bzl/common/java/java_binary.bzl
+++ b/src/main/starlark/builtins_bzl/common/java/java_binary.bzl
@@ -554,6 +554,7 @@ BASE_TEST_ATTRIBUTES = {
"@" + paths.join(cc_semantics.get_platforms_root(), "os:ios"),
"@" + paths.join(cc_semantics.get_platforms_root(), "os:macos"),
"@" + paths.join(cc_semantics.get_platforms_root(), "os:tvos"),
+ "@" + paths.join(cc_semantics.get_platforms_root(), "os:visionos"),
"@" + paths.join(cc_semantics.get_platforms_root(), "os:watchos"),
],
),
diff --git a/src/main/starlark/builtins_bzl/common/objc/objc_common.bzl b/src/main/starlark/builtins_bzl/common/objc/objc_common.bzl
index 25ddb56bc4311d..4f2ba0c3b14c3a 100644
--- a/src/main/starlark/builtins_bzl/common/objc/objc_common.bzl
+++ b/src/main/starlark/builtins_bzl/common/objc/objc_common.bzl
@@ -34,6 +34,8 @@ NON_ARC_SRCS = [".m", ".mm"]
ios_cpus = struct(
IOS_SIMULATOR_TARGET_CPUS = ["ios_x86_64", "ios_i386", "ios_sim_arm64"],
IOS_DEVICE_TARGET_CPUS = ["ios_armv6", "ios_arm64", "ios_armv7", "ios_armv7s", "ios_arm64e"],
+ VISIONOS_SIMULATOR_TARGET_CPUS = ["visionos_x86_64", "visionos_sim_arm64"],
+ VISIONOS_DEVICE_TARGET_CPUS = ["visionos_arm64"],
WATCHOS_SIMULATOR_TARGET_CPUS = ["watchos_i386", "watchos_x86_64", "watchos_arm64"],
WATCHOS_DEVICE_TARGET_CPUS = ["watchos_armv7k", "watchos_arm64_32", "watchos_device_arm64", "watchos_device_arm64e"],
TVOS_SIMULATOR_TARGET_CPUS = ["tvos_x86_64", "tvos_sim_arm64"],
@@ -238,6 +240,8 @@ def _add_linkopts(sdk_linking_info, linkopts):
def _is_apple_platform(cpu):
return cpu in ios_cpus.IOS_SIMULATOR_TARGET_CPUS or \
cpu in ios_cpus.IOS_DEVICE_TARGET_CPUS or \
+ cpu in ios_cpus.VISIONOS_SIMULATOR_TARGET_CPUS or \
+ cpu in ios_cpus.VISIONOS_DEVICE_TARGET_CPUS or \
cpu in ios_cpus.WATCHOS_SIMULATOR_TARGET_CPUS or \
cpu in ios_cpus.WATCHOS_DEVICE_TARGET_CPUS or \
cpu in ios_cpus.TVOS_SIMULATOR_TARGET_CPUS or \
@@ -275,6 +279,8 @@ def _sdk_framework_dir(target_platform, xcode_config):
relative_path = "/Developer/Library/Frameworks"
return "__BAZEL_XCODE_SDKROOT__" + relative_path
if target_platform == apple_common.platform.macos or \
+ target_platform == apple_common.platform.visionos_device or \
+ target_platform == apple_common.platform.visionos_simulator or \
target_platform == apple_common.platform.watchos_device or \
target_platform == apple_common.platform.watchos_simulator or \
target_platform == apple_common.platform.tvos_device or \
@@ -293,6 +299,10 @@ def _platform_name_from_apple_target_cpu(cpu):
return "iPhoneSimulator"
elif cpu in ios_cpus.IOS_DEVICE_TARGET_CPUS:
return "iPhoneOS"
+ elif cpu in ios_cpus.VISIONOS_SIMULATOR_TARGET_CPUS:
+ return "XRSimulator"
+ elif cpu in ios_cpus.VISIONOS_DEVICE_TARGET_CPUS:
+ return "XROS"
elif cpu in ios_cpus.WATCHOS_SIMULATOR_TARGET_CPUS:
return "WatchSimulator"
elif cpu in ios_cpus.WATCHOS_DEVICE_TARGET_CPUS:
@@ -313,6 +323,8 @@ def _sdk_version_for_platform(xcode_config, platform_name):
return xcode_config.ios_sdk_version()
elif platform_name == "AppleTVOS" or platform_name == "AppleTVSimulator":
return xcode_config.tvos_sdk_version()
+ elif platform_name == "XROS" or platform_name == "XRSimulator":
+ return xcode_config.visionos_sdk_version()
elif platform_name == "WatchOS" or platform_name == "WatchSimulator":
return xcode_config.watchos_sdk_version()
elif platform_name == "MacOSX":
@@ -348,6 +360,7 @@ def _apple_cc_toolchain_build_variables(xcode_config):
variables["ios_sdk_version"] = _to_string_with_minimum_components(str(xcode_config.sdk_version_for_platform(apple_common.platform.ios_simulator)), 2)
variables["macos_sdk_version"] = _to_string_with_minimum_components(str(xcode_config.sdk_version_for_platform(apple_common.platform.macos)), 2)
variables["tvos_sdk_version"] = _to_string_with_minimum_components(str(xcode_config.sdk_version_for_platform(apple_common.platform.tvos_simulator)), 2)
+ variables["visionos_sdk_version"] = _to_string_with_minimum_components(str(xcode_config.sdk_version_for_platform(apple_common.platform.visionos_simulator)), 2)
variables["watchos_sdk_version"] = _to_string_with_minimum_components(str(xcode_config.sdk_version_for_platform(apple_common.platform.watchos_simulator)), 2)
variables["sdk_dir"] = "__BAZEL_XCODE_SDKROOT__"
variables["sdk_framework_dir"] = _sdk_framework_dir(platform, xcode_config)
diff --git a/src/main/starlark/builtins_bzl/common/objc/transitions.bzl b/src/main/starlark/builtins_bzl/common/objc/transitions.bzl
index 88aec6da87282b..b9c44e4661a228 100644
--- a/src/main/starlark/builtins_bzl/common/objc/transitions.bzl
+++ b/src/main/starlark/builtins_bzl/common/objc/transitions.bzl
@@ -37,6 +37,16 @@ def _determine_single_architecture(platform_type, settings):
if cpu_value == "darwin_arm64":
return "sim_arm64"
return DEFAULT_IOS_CPU
+ if platform_type == VISIONOS:
+ cpus = settings["//command_line_option:visionos_cpus"]
+ if len(cpus) > 0:
+ return cpus[0]
+ cpu_value = settings["//command_line_option:cpu"]
+ if cpu_value.startswith(VISIONOS_CPU_PREFIX):
+ return cpu_value[len(VISIONOS_CPU_PREFIX):]
+ if cpu_value == "darwin_arm64":
+ return "sim_arm64"
+ return DEFAULT_VISIONOS_CPU
if platform_type == WATCHOS:
watchos_cpus = settings["//command_line_option:watchos_cpus"]
if len(watchos_cpus) == 0:
@@ -64,13 +74,16 @@ def _determine_single_architecture(platform_type, settings):
fail("ERROR: Unhandled platform type {}".format(platform_type))
IOS = "ios"
+VISIONOS = "visionos"
WATCHOS = "watchos"
TVOS = "tvos"
MACOS = "macos"
CATALYST = "catalyst"
IOS_CPU_PREFIX = "ios_"
+VISIONOS_CPU_PREFIX = "visionos_"
DARWIN_CPU_PREFIX = "darwin_"
DEFAULT_IOS_CPU = "x86_64"
+DEFAULT_VISIONOS_CPU = "x86_64"
DEFAULT_WATCHOS_CPU = "i386"
DEFAULT_TVOS_CPU = "x86_64"
DEFAULT_MACOS_CPU = "x86_64"
@@ -122,6 +135,7 @@ _apple_rule_base_transition_inputs = [
"//command_line_option:ios_multi_cpus",
"//command_line_option:macos_cpus",
"//command_line_option:tvos_cpus",
+ "//command_line_option:visionos_cpus",
"//command_line_option:watchos_cpus",
"//command_line_option:catalyst_cpus",
"//command_line_option:platforms",
diff --git a/src/main/starlark/builtins_bzl/common/python/attributes.bzl b/src/main/starlark/builtins_bzl/common/python/attributes.bzl
index f9de1ff3037767..919d629a28b7c9 100644
--- a/src/main/starlark/builtins_bzl/common/python/attributes.bzl
+++ b/src/main/starlark/builtins_bzl/common/python/attributes.bzl
@@ -174,6 +174,7 @@ environment when the test is executed by bazel test.
PLATFORMS_LOCATION + "/os:ios",
PLATFORMS_LOCATION + "/os:macos",
PLATFORMS_LOCATION + "/os:tvos",
+ PLATFORMS_LOCATION + "/os:visionos",
PLATFORMS_LOCATION + "/os:watchos",
],
),
diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/MockPlatformSupport.java b/src/test/java/com/google/devtools/build/lib/packages/util/MockPlatformSupport.java
index 80360be3ccc6ad..778e6458f1a436 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/util/MockPlatformSupport.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/util/MockPlatformSupport.java
@@ -111,6 +111,10 @@ public static void setup(
" constraint_setting = ':os',",
")",
"constraint_value(",
+ " name = 'visionos',",
+ " constraint_setting = ':os',",
+ ")",
+ "constraint_value(",
" name = 'watchos',",
" constraint_setting = ':os',",
")",
diff --git a/src/test/java/com/google/devtools/build/lib/rules/apple/XcodeConfigTest.java b/src/test/java/com/google/devtools/build/lib/rules/apple/XcodeConfigTest.java
index 4d689bb6f56736..4f67606ce4eaa3 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/apple/XcodeConfigTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/apple/XcodeConfigTest.java
@@ -445,7 +445,9 @@ public void xcodeVersionConfig_isFunction() throws Exception {
+ " tvosMinimumOsVersion='1.6',"
+ " macosSdkVersion='1.7',"
+ " macosMinimumOsVersion='1.8',"
- + " xcodeVersion='1.9'))]",
+ + " visionosSdkVersion='1.9',"
+ + " visionosMinimumOsVersion='1.10',"
+ + " xcodeVersion='1.11'))]",
"my_rule = rule(_impl, attrs = { 'dep' : attr.label() })");
scratch.file("foo/BUILD", "load(':extension.bzl', 'my_rule')", "my_rule(name='test')");
assertNoEvents();
@@ -466,6 +468,8 @@ public void xcodeVersionConfig_isFunction() throws Exception {
DottedVersion.fromStringUnchecked("1.7"),
DottedVersion.fromStringUnchecked("1.8"),
DottedVersion.fromStringUnchecked("1.9"),
+ DottedVersion.fromStringUnchecked("1.10"),
+ DottedVersion.fromStringUnchecked("1.11"),
XcodeConfigInfo.Availability.UNKNOWN,
/* xcodeVersionFlagValue= */ "",
/* includeXcodeReqs= */ false));
@@ -487,7 +491,9 @@ public void xcodeVersionConfig_throwsOnBadInput() throws Exception {
+ " tvosMinimumOsVersion='1.6',"
+ " macosSdkVersion='1.7',"
+ " macosMinimumOsVersion='1.8',"
- + " xcodeVersion='1.9'))]",
+ + " visionosSdkVersion='1.9',"
+ + " visionosMinimumOsVersion='1.10',"
+ + " xcodeVersion='1.11'))]",
"my_rule = rule(_impl, attrs = { 'dep' : attr.label() })");
scratch.file("foo/BUILD", "load(':extension.bzl', 'my_rule')", "my_rule(name='test')");
assertNoEvents();
@@ -507,12 +513,14 @@ public void xcodeVersionConfig_exposesExpectedAttributes() throws Exception {
+ " iosSdkVersion='1.1',"
+ " iosMinimumOsVersion='1.2',"
+ " watchosSdkVersion='1.3',"
- + " watchosMinimumOsVersion='1.4',"
+ + " watchosMinimumOsVersion='2.4',"
+ " tvosSdkVersion='1.5',"
+ " tvosMinimumOsVersion='1.6',"
+ " macosSdkVersion='1.7',"
+ " macosMinimumOsVersion='1.8',"
- + " xcodeVersion='1.9')",
+ + " visionosSdkVersion='1.9',"
+ + " visionosMinimumOsVersion='1.10',"
+ + " xcodeVersion='1.11')",
" return [result(xcode_version=xcode_version.xcode_version(),"
+ "min_os=xcode_version.minimum_os_for_platform_type(ctx.fragments.apple.single_arch_platform.platform_type)),]",
"my_rule = rule(_impl, attrs = { 'dep' : attr.label() }, fragments = ['apple'])");
@@ -523,7 +531,7 @@ public void xcodeVersionConfig_exposesExpectedAttributes() throws Exception {
(StructImpl)
myRuleTarget.get(
new StarlarkProvider.Key(Label.parseCanonical("//foo:extension.bzl"), "result"));
- assertThat(info.getValue("xcode_version").toString()).isEqualTo("1.9");
+ assertThat(info.getValue("xcode_version").toString()).isEqualTo("1.11");
assertThat(info.getValue("min_os").toString()).isEqualTo("1.8");
}
diff --git a/tools/osx/BUILD b/tools/osx/BUILD
index fb3d60551bfa76..0358fb0ffe0961 100644
--- a/tools/osx/BUILD
+++ b/tools/osx/BUILD
@@ -3,6 +3,7 @@ load(
"ios_sdk_version_flag",
"macos_sdk_version_flag",
"tvos_sdk_version_flag",
+ "visionos_sdk_version_flag",
"watchos_sdk_version_flag",
"xcode_version_flag",
)
@@ -86,6 +87,8 @@ ios_sdk_version_flag(name = "ios_sdk_version_flag")
tvos_sdk_version_flag(name = "tvos_sdk_version_flag")
+visionos_sdk_version_flag(name = "visionos_sdk_version_flag")
+
watchos_sdk_version_flag(name = "watchos_sdk_version_flag")
macos_sdk_version_flag(name = "macos_sdk_version_flag")
diff --git a/tools/osx/xcode_configure.bzl b/tools/osx/xcode_configure.bzl
index a7fb7ba560fb9e..419eeb80637851 100644
--- a/tools/osx/xcode_configure.bzl
+++ b/tools/osx/xcode_configure.bzl
@@ -71,6 +71,7 @@ def _xcode_version_output(repository_ctx, name, version, aliases, developer_dir,
ios_sdk_version = _search_sdk_output(xcodebuild_result.stdout, "iphoneos")
tvos_sdk_version = _search_sdk_output(xcodebuild_result.stdout, "appletvos")
macos_sdk_version = _search_sdk_output(xcodebuild_result.stdout, "macosx")
+ visionos_sdk_version = _search_sdk_output(xcodebuild_result.stdout, "xros")
watchos_sdk_version = _search_sdk_output(xcodebuild_result.stdout, "watchos")
build_contents += "xcode_version(\n name = '%s'," % name
build_contents += "\n version = '%s'," % version
@@ -82,6 +83,8 @@ def _xcode_version_output(repository_ctx, name, version, aliases, developer_dir,
build_contents += "\n default_tvos_sdk_version = '%s'," % tvos_sdk_version
if macos_sdk_version:
build_contents += "\n default_macos_sdk_version = '%s'," % macos_sdk_version
+ if visionos_sdk_version:
+ build_contents += "\n default_visionos_sdk_version = '%s'," % visionos_sdk_version
if watchos_sdk_version:
build_contents += "\n default_watchos_sdk_version = '%s'," % watchos_sdk_version
build_contents += "\n)\n"
diff --git a/tools/osx/xcode_version_flag.bzl b/tools/osx/xcode_version_flag.bzl
index a7ede5f54dd95a..1578a731b8fe32 100644
--- a/tools/osx/xcode_version_flag.bzl
+++ b/tools/osx/xcode_version_flag.bzl
@@ -98,6 +98,16 @@ def _tvos_sdk_version_flag_impl(ctx):
),
))
+def _visionos_sdk_version_flag_impl(ctx):
+ """A rule that allows select() to select based on the visionOS SDK version."""
+ xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig]
+
+ return config_common.FeatureFlagInfo(value = _strip_version(
+ xcode_config.sdk_version_for_platform(
+ apple_common.platform.visionos_device,
+ ),
+ ))
+
def _watchos_sdk_version_flag_impl(ctx):
"""A rule that allows select() to select based on the watchOS SDK version."""
xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig]
@@ -200,6 +210,16 @@ tvos_sdk_version_flag = rule(
},
)
+visionos_sdk_version_flag = rule(
+ implementation = _visionos_sdk_version_flag_impl,
+ attrs = {
+ "_xcode_config": attr.label(default = configuration_field(
+ fragment = "apple",
+ name = "xcode_config_label",
+ )),
+ },
+)
+
watchos_sdk_version_flag = rule(
implementation = _watchos_sdk_version_flag_impl,
attrs = {