From e63dfe7348adb52b44baca00a1b3e79d947699d4 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Wed, 2 Aug 2023 15:32:02 -0700 Subject: [PATCH] [6.4.0] Add visionOS support This cherry picks https://github.com/bazelbuild/bazel/pull/18905 and https://github.com/bazelbuild/bazel/pull/19133 --- MODULE.bazel | 2 +- distdir_deps.bzl | 9 +++--- src/MODULE.tools | 2 +- .../build/docgen/templates/be/be-nav.vm | 2 +- .../build/docgen/templates/be/be-toc.vm | 2 +- .../LocalConfigPlatformFunction.java | 2 +- .../rules/apple/AppleCommandLineOptions.java | 18 ++++++++++++ .../lib/rules/apple/AppleConfiguration.java | 28 ++++++++++++++++++- .../build/lib/rules/apple/ApplePlatform.java | 11 ++++++++ .../build/lib/rules/apple/AppleToolchain.java | 2 ++ .../build/lib/rules/apple/XcodeConfig.java | 5 ++++ .../lib/rules/apple/XcodeConfigInfo.java | 16 +++++++++++ .../rules/apple/XcodeVersionProperties.java | 23 ++++++++++++++- .../lib/rules/apple/XcodeVersionRule.java | 8 ++++++ .../lib/rules/apple/XcodeVersionRuleData.java | 6 ++++ .../lib/rules/objc/CompilationSupport.java | 3 +- .../rules/objc/MultiArchBinarySupport.java | 16 +++++++++++ .../build/lib/rules/objc/ObjcRuleClasses.java | 4 +-- .../apple/ApplePlatformTypeApi.java | 3 +- .../apple/XcodeConfigInfoApi.java | 12 ++++++++ .../apple/XcodePropertiesApi.java | 10 +++++++ .../builtins_bzl/common/cc/cc_binary.bzl | 4 ++- .../builtins_bzl/common/objc/transitions.bzl | 12 ++++++++ .../packages/util/MockPlatformSupport.java | 4 +++ .../lib/rules/apple/XcodeConfigTest.java | 18 ++++++++---- .../bazel/android/android_integration_test.sh | 2 +- tools/osx/BUILD | 3 ++ tools/osx/xcode_configure.bzl | 3 ++ tools/osx/xcode_version_flag.bzl | 20 +++++++++++++ 29 files changed, 228 insertions(+), 22 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index dd3094f00effb9..f7ad0d88a95817 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -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") diff --git a/distdir_deps.bzl b/distdir_deps.bzl index 712d75cffa8acd..4598ea7803e94c 100644 --- a/distdir_deps.bzl +++ b/distdir_deps.bzl @@ -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", diff --git a/src/MODULE.tools b/src/MODULE.tools index b82be48982cb08..65937922ecfa73 100644 --- a/src/MODULE.tools +++ b/src/MODULE.tools @@ -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") diff --git a/src/main/java/com/google/devtools/build/docgen/templates/be/be-nav.vm b/src/main/java/com/google/devtools/build/docgen/templates/be/be-nav.vm index 38d7385cf630cd..fb745de8d49aab 100644 --- a/src/main/java/com/google/devtools/build/docgen/templates/be/be-nav.vm +++ b/src/main/java/com/google/devtools/build/docgen/templates/be/be-nav.vm @@ -33,7 +33,7 @@ #end
  • AppEngine
  • -
  • Apple (Swift, iOS, macOS, tvOS, watchOS)
  • +
  • Apple (Swift, iOS, macOS, tvOS, visionOS, watchOS)
  • C#
  • D
  • Docker
  • diff --git a/src/main/java/com/google/devtools/build/docgen/templates/be/be-toc.vm b/src/main/java/com/google/devtools/build/docgen/templates/be/be-toc.vm index bb0d01f416fbea..3821dc6d00fbc6 100644 --- a/src/main/java/com/google/devtools/build/docgen/templates/be/be-toc.vm +++ b/src/main/java/com/google/devtools/build/docgen/templates/be/be-toc.vm @@ -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# diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java index eecf41a30ecd59..04907ba1d2da6c 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java @@ -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); } 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 794df2293f98a1..55dc7595c95a6c 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 @@ -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"; @@ -297,6 +301,16 @@ public class AppleCommandLineOptions extends FragmentOptions { + "is a universal binary containing all specified architectures.") public List 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 visionosCpus; + @Option( name = "watchos_cpus", allowMultiple = true, @@ -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; 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 dc7abdb202d7b8..beb2d9f2c000aa 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 @@ -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 visionosCpus = + (options.visionosCpus == null || options.visionosCpus.isEmpty()) + ? ImmutableList.of(AppleCommandLineOptions.DEFAULT_VISIONOS_CPU) + : ImmutableList.copyOf(options.visionosCpus); ImmutableList watchosCpus = (options.watchosCpus == null || options.watchosCpus.isEmpty()) ? ImmutableList.of(AppleCommandLineOptions.DEFAULT_WATCHOS_CPU) @@ -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 iosMultiCpus(); + abstract ImmutableList visionosCpus(); + abstract ImmutableList watchosCpus(); abstract ImmutableList tvosCpus(); @@ -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: @@ -296,6 +310,8 @@ public List getMultiArchitectures(PlatformType platformType) { switch (platformType) { case IOS: return appleCpus.iosMultiCpus(); + case VISIONOS: + return appleCpus.visionosCpus(); case WATCHOS: return appleCpus.watchosCpus(); case TVOS: @@ -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) { @@ -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. */ diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java b/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java index a050bbd4fcfd5f..b7af54fb6a9923 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java @@ -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); @@ -45,6 +47,10 @@ public enum ApplePlatform implements ApplePlatformApi { ImmutableSet.of("ios_x86_64", "ios_i386", "ios_sim_arm64"); private static final ImmutableSet IOS_DEVICE_TARGET_CPUS = ImmutableSet.of("ios_armv6", "ios_arm64", "ios_armv7", "ios_armv7s", "ios_arm64e"); + private static final ImmutableSet VISIONOS_SIMULATOR_TARGET_CPUS = + ImmutableSet.of("visionos_x86_64", "visionos_sim_arm64"); + private static final ImmutableSet VISIONOS_DEVICE_TARGET_CPUS = + ImmutableSet.of("visionos_arm64"); private static final ImmutableSet WATCHOS_SIMULATOR_TARGET_CPUS = ImmutableSet.of("watchos_i386", "watchos_x86_64", "watchos_arm64"); private static final ImmutableSet WATCHOS_DEVICE_TARGET_CPUS = @@ -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)) { @@ -245,6 +255,7 @@ public UnsupportedPlatformTypeException(String msg) { @Immutable public enum PlatformType implements ApplePlatformTypeApi { IOS("ios"), + VISIONOS("visionos"), WATCHOS("watchos"), TVOS("tvos"), MACOS("macos"), 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 d042ab80462c72..241a7ecdce91bd 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 @@ -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: diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfig.java b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfig.java index 5df242200393a5..b2ed13fc09a22d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfig.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfig.java @@ -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) @@ -155,6 +158,8 @@ public ConfiguredTarget create(RuleContext ruleContext) new XcodeConfigInfo( iosSdkVersion, iosMinimumOsVersion, + visionosSdkVersion, + visionosMinimumOsVersion, watchosSdkVersion, watchosMinimumOsVersion, tvosSdkVersion, diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfigInfo.java b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfigInfo.java index e5692368f3d940..d4ce9fbd2411d4 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfigInfo.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfigInfo.java @@ -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; @@ -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, @@ -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); @@ -135,6 +141,8 @@ private XcodeConfigProvider() { public XcodeConfigInfoApi xcodeConfigInfo( String iosSdkVersion, String iosMinimumOsVersion, + String visionosSdkVersion, + String visionosMinimumOsVersion, String watchosSdkVersion, String watchosMinimumOsVersion, String tvosSdkVersion, @@ -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), @@ -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: @@ -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; 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 f3e6e39e175423..22410e9887f0ab 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 @@ -36,12 +36,14 @@ public class XcodeVersionProperties extends NativeInfo implements XcodePropertie new BuiltinProvider(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 xcodeVersion; private final DottedVersion defaultIosSdkVersion; + private final DottedVersion defaultVisionosSdkVersion; private final DottedVersion defaultWatchosSdkVersion; private final DottedVersion defaultTvosSdkVersion; private final DottedVersion defaultMacosSdkVersion; @@ -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); } /** @@ -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) { @@ -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) @@ -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 @@ -148,6 +162,11 @@ public DottedVersion getDefaultIosSdkVersion() { return defaultIosSdkVersion; } + @Nullable + public DottedVersion getDefaultVisionosSdkVersion() { + return defaultVisionosSdkVersion; + } + @Nullable public DottedVersion getDefaultWatchosSdkVersion() { return defaultWatchosSdkVersion; @@ -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()); @@ -184,6 +204,7 @@ public int hashCode() { return Objects.hash( xcodeVersion, defaultIosSdkVersion, + defaultVisionosSdkVersion, defaultWatchosSdkVersion, defaultTvosSdkVersion, defaultMacosSdkVersion); 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 41609a36f41ef6..e813fa03d8b7b0 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 @@ -31,6 +31,7 @@ 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_VISIONOS_SDK_VERSION_ATTR_NAME = "default_visionos_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_MACOS_SDK_VERSION_ATTR_NAME = "default_macos_sdk_version"; @@ -64,6 +65,13 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) .add( attr(DEFAULT_IOS_SDK_VERSION_ATTR_NAME, STRING) .nonconfigurable("this rule determines configuration")) + /* + The visionos sdk version that is used by default when this version of xcode is being used. + The visionos_sdk_version build flag will override the value specified here. + */ + .add( + attr(DEFAULT_VISIONOS_SDK_VERSION_ATTR_NAME, STRING) + .nonconfigurable("this rule determines configuration")) /* The watchos sdk version that is used by default when this version of xcode is being used. The watchos_sdk_version build flag will override the value specified here. 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 ff8cc3549c254a..266265911ac652 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 @@ -52,6 +52,8 @@ public class XcodeVersionRuleData implements TransitiveInfoProvider { attrMapper.get(XcodeVersionRule.VERSION_ATTR_NAME, Type.STRING)); String iosSdkVersionString = attrMapper.get(XcodeVersionRule.DEFAULT_IOS_SDK_VERSION_ATTR_NAME, Type.STRING); + String visionosSdkVersionString = + attrMapper.get(XcodeVersionRule.DEFAULT_VISIONOS_SDK_VERSION_ATTR_NAME, Type.STRING); String watchosSdkVersionString = attrMapper.get(XcodeVersionRule.DEFAULT_WATCHOS_SDK_VERSION_ATTR_NAME, Type.STRING); String tvosSdkVersionString = @@ -63,6 +65,7 @@ public class XcodeVersionRuleData implements TransitiveInfoProvider { new XcodeVersionProperties( xcodeVersion, iosSdkVersionString, + visionosSdkVersionString, watchosSdkVersionString, tvosSdkVersionString, macosxSdkVersionString); @@ -114,6 +117,9 @@ public boolean equals(Object other) { && xcodeVersionProperties .getDefaultIosSdkVersion() .equals(otherData.getXcodeVersionProperties().getDefaultIosSdkVersion()) + && xcodeVersionProperties + .getDefaultVisionosSdkVersion() + .equals(otherData.getXcodeVersionProperties().getDefaultVisionosSdkVersion()) && xcodeVersionProperties .getDefaultWatchosSdkVersion() .equals(otherData.getXcodeVersionProperties().getDefaultWatchosSdkVersion()) 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 ed504331cffdf8..f991a687359a18 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 @@ -134,7 +134,8 @@ public class CompilationSupport implements StarlarkValue { "-fexceptions", "-fasm-blocks", "-fobjc-abi-version=2", "-fobjc-legacy-dispatch"); /** - * Frameworks implicitly linked to iOS, watchOS, and tvOS binaries when using legacy compilation. + * Frameworks implicitly linked to iOS, visionOS, watchOS, and tvOS binaries when using legacy + * compilation. */ @VisibleForTesting static final NestedSet AUTOMATIC_SDK_FRAMEWORKS = diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchBinarySupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchBinarySupport.java index a407517c7f84fd..ff636f9cd0bf89 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchBinarySupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchBinarySupport.java @@ -251,6 +251,8 @@ private static ConfigurationDistinguisher configurationDistinguisher(PlatformTyp return ConfigurationDistinguisher.APPLEBIN_IOS; case CATALYST: return ConfigurationDistinguisher.APPLEBIN_CATALYST; + case VISIONOS: + return ConfigurationDistinguisher.APPLEBIN_VISIONOS; case WATCHOS: return ConfigurationDistinguisher.APPLEBIN_WATCHOS; case TVOS: @@ -286,6 +288,10 @@ private static DottedVersion.Option minimumOsVersionOption( case CATALYST: option = buildOptions.get(AppleCommandLineOptions.class).iosMinimumOs; break; + case VISIONOS: + // TODO: Replace with CppOptions.minimumOsVersion + option = DottedVersion.option(DottedVersion.fromStringUnchecked("1.0")); + break; case WATCHOS: option = buildOptions.get(AppleCommandLineOptions.class).watchosMinimumOs; break; @@ -333,6 +339,9 @@ private static BuildOptionsView defaultBuildOptionsForSplit( case MACOS: appleCommandLineOptions.macosMinimumOs = minimumOsVersionOption; break; + case VISIONOS: + // TODO: use CppOptions.minimumOsVersion + break; } return splitOptions; } @@ -461,6 +470,13 @@ public static ImmutableMap handleAppleCpus( } cpus = supportedAppleCpusFromMinimumOs(minimumOsVersionOption, cpus, platformType); break; + case VISIONOS: + cpus = buildOptions.get(AppleCommandLineOptions.class).visionosCpus; + if (cpus.isEmpty()) { + cpus = ImmutableList.of(AppleCommandLineOptions.DEFAULT_VISIONOS_CPU); + } + cpus = supportedAppleCpusFromMinimumOs(minimumOsVersionOption, cpus, platformType); + break; case WATCHOS: cpus = buildOptions.get(AppleCommandLineOptions.class).watchosCpus; if (cpus.isEmpty()) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java index 4b3e044fd740a7..946b3fb728b27d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java @@ -207,8 +207,8 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment envi return builder /* Names of SDK frameworks to link with (e.g. "AddressBook", "QuartzCore"). "UIKit" and - "Foundation" are always included when building for the iOS, tvOS and watchOS platforms. - For macOS, only "Foundation" is always included. + "Foundation" are always included when building for the iOS, tvOS, visionOS, + and watchOS platforms. For macOS, only "Foundation" is always included.

    When linking a top level Apple binary, all SDK frameworks listed in that binary's transitive dependency graph are linked. diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ApplePlatformTypeApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ApplePlatformTypeApi.java index e110ad94c78198..54edcfe31dd764 100644 --- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ApplePlatformTypeApi.java +++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ApplePlatformTypeApi.java @@ -23,7 +23,7 @@ name = "apple_platform_type", category = DocCategory.BUILTIN, doc = - "Describes an Apple \"platform type\", such as iOS, macOS, tvOS, or watchOS. This is" + "Describes an Apple \"platform type\", such as iOS, macOS, tvOS, visionOS, or watchOS. This is" + " distinct from a \"platform\", which is the platform type combined with one or more" + " CPU architectures.

    Specific instances of this type can be retrieved by accessing" + " the fields of the apple_common.platform_type.ios" + "

  • apple_common.platform_type.macos
  • " + "
  • apple_common.platform_type.tvos
  • " + + "
  • apple_common.platform_type.visionos
  • " + "
  • apple_common.platform_type.watchos
  • Likewise, the" + " platform type of an existing platform value can be retrieved using its" + " platform_type field.

    Platform types can be converted to a lowercase" diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodeConfigInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodeConfigInfoApi.java index 781b5aa3b86160..8229f03ac5b423 100644 --- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodeConfigInfoApi.java +++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodeConfigInfoApi.java @@ -103,6 +103,16 @@ interface XcodeConfigProviderApi extends ProviderApi { named = true, positional = false, doc = "The ios minimum os version."), + @Param( + name = "visionosSdkVersion", + named = true, + positional = false, + doc = "The visionOS SDK version."), + @Param( + name = "visionosMinimumOsVersion", + named = true, + positional = false, + doc = "The visionOS minimum os version."), @Param( name = "watchosSdkVersion", named = true, @@ -144,6 +154,8 @@ interface XcodeConfigProviderApi extends ProviderApi { XcodeConfigInfoApi 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/starlark/builtins_bzl/common/cc/cc_binary.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl index 4beca92ef650c1..a657498cff4842 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl @@ -33,6 +33,8 @@ _LINKING_STATIC = "static_linking_mode" _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"] @@ -555,7 +557,7 @@ def _report_invalid_options(ctx, cc_toolchain, cpp_config): fail("The selected toolchain does not support setting --grte_top (it doesn't specify builtin_sysroot).") 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/objc/transitions.bzl b/src/main/starlark/builtins_bzl/common/objc/transitions.bzl index 88aec6da87282b..f886f5933b1448 100644 --- a/src/main/starlark/builtins_bzl/common/objc/transitions.bzl +++ b/src/main/starlark/builtins_bzl/common/objc/transitions.bzl @@ -37,6 +37,14 @@ 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 == "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 +72,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 +133,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/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 ec3d6f2c7d315e..b657474765a2dc 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 @@ -112,6 +112,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 51ea58bddd6337..cd41a807eb30f3 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= */ "", @@ -489,7 +493,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(); @@ -509,12 +515,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'])"); @@ -525,7 +533,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/src/test/shell/bazel/android/android_integration_test.sh b/src/test/shell/bazel/android/android_integration_test.sh index a61fa6f461314e..776a40dbe0514d 100755 --- a/src/test/shell/bazel/android/android_integration_test.sh +++ b/src/test/shell/bazel/android/android_integration_test.sh @@ -232,7 +232,7 @@ android_binary( EOF cat > MODULE.bazel << 'EOF' # Required for android_integration_test_with_platforms -bazel_dep(name = "platforms", version = "0.0.5") +bazel_dep(name = "platforms", version = "0.0.7") EOF bazel clean diff --git a/tools/osx/BUILD b/tools/osx/BUILD index 79344650445338..2a0f44224ce2f2 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", ) @@ -100,6 +101,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 e8b7499a814861..e9c4152b924c01 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 = {