diff --git a/src/MODULE.tools b/src/MODULE.tools index 536285babc83c4..ba2ae270cec29a 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 75a7bb2723ee44..8d0668b631a0d8 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 @@ -28,7 +28,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 bfe32b09f57e3c..e924134a9c87ce 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 @@ -82,6 +82,17 @@ public class AppleCommandLineOptions extends FragmentOptions { + "If unspecified, uses default iOS SDK version from 'xcode_version'.") public DottedVersion.Option iosSdkVersion; + @Option( + name = "visionos_sdk_version", + defaultValue = "null", + converter = DottedVersionConverter.class, + documentationCategory = OptionDocumentationCategory.TOOLCHAIN, + effectTags = {OptionEffectTag.LOSES_INCREMENTAL_STATE}, + help = + "Specifies the version of the visionOS SDK to use to build visionOS applications. " + + "If unspecified, uses default visionOS SDK version from 'xcode_version'.") + public DottedVersion.Option visionOsSdkVersion; + @Option( name = "watchos_sdk_version", defaultValue = "null", @@ -126,6 +137,17 @@ public class AppleCommandLineOptions extends FragmentOptions { + "If unspecified, uses 'ios_sdk_version'.") public DottedVersion.Option iosMinimumOs; + @Option( + name = "visionos_minimum_os", + defaultValue = "null", + converter = DottedVersionConverter.class, + documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS, + effectTags = {OptionEffectTag.LOSES_INCREMENTAL_STATE}, + help = + "Minimum compatible visionOS version for target simulators and devices. " + + "If unspecified, uses 'visionos_sdk_version'.") + public DottedVersion.Option visionosMinimumOs; + @Option( name = "watchos_minimum_os", defaultValue = "null", @@ -182,11 +204,16 @@ public class AppleCommandLineOptions extends FragmentOptions { public boolean preferMutualXcode; @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"; @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" : "x86_64"; @@ -292,6 +319,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, @@ -399,6 +436,9 @@ public DottedVersion getMinimumOsVersion() { case TVOS: option = tvosMinimumOs; break; + case VISIONOS: + option = visionosMinimumOs; + break; case WATCHOS: option = watchosMinimumOs; break; @@ -417,6 +457,7 @@ public FragmentOptions getExec() { exec.xcodeVersionConfig = xcodeVersionConfig; exec.xcodeVersion = xcodeVersion; exec.iosSdkVersion = iosSdkVersion; + exec.visionOsSdkVersion = visionOsSdkVersion; exec.watchOsSdkVersion = watchOsSdkVersion; exec.tvOsSdkVersion = tvOsSdkVersion; exec.macOsSdkVersion = macOsSdkVersion; 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 3bb538ab8e013e..e45338a26caaf5 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 @@ -113,6 +113,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) @@ -131,13 +135,15 @@ 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(); @@ -256,6 +262,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: @@ -304,6 +312,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: @@ -349,6 +359,13 @@ 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) { @@ -453,6 +470,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 ec6862edf638cf..c34d89f62dec7a 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 = @@ -135,6 +141,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)) { @@ -242,6 +252,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 cc2b3fb7c862f2..002997c096876b 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 b22bbf7fc21041..9b772975a26ed1 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 @@ -122,6 +122,14 @@ public ConfiguredTarget create(RuleContext ruleContext) (appleOptions.iosMinimumOs != null) ? DottedVersion.maybeUnwrap(appleOptions.iosMinimumOs) : iosSdkVersion; + DottedVersion visionosSdkVersion = + (appleOptions.visionOsSdkVersion != null) + ? DottedVersion.maybeUnwrap(appleOptions.visionOsSdkVersion) + : xcodeVersionProperties.getDefaultVisionosSdkVersion(); + DottedVersion visionosMinimumOsVersion = + (appleOptions.visionosMinimumOs != null) + ? DottedVersion.maybeUnwrap(appleOptions.visionosMinimumOs) + : visionosSdkVersion; DottedVersion watchosSdkVersion = (appleOptions.watchOsSdkVersion != null) ? DottedVersion.maybeUnwrap(appleOptions.watchOsSdkVersion) @@ -151,6 +159,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 183dc563798f92..be24c4b6e7f5f3 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 @@ -45,6 +45,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; @@ -58,6 +60,8 @@ public class XcodeConfigInfo extends NativeInfo public XcodeConfigInfo( DottedVersion iosSdkVersion, DottedVersion iosMinimumOsVersion, + DottedVersion visionosSdkVersion, + DottedVersion visionosMinimumOsVersion, DottedVersion watchosSdkVersion, DottedVersion watchosMinimumOsVersion, DottedVersion tvosSdkVersion, @@ -70,6 +74,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); @@ -141,6 +147,8 @@ private XcodeConfigProvider() { public XcodeConfigInfoApi xcodeConfigInfo( String iosSdkVersion, String iosMinimumOsVersion, + String visionosSdkVersion, + String visionosMinimumOsVersion, String watchosSdkVersion, String watchosMinimumOsVersion, String tvosSdkVersion, @@ -153,6 +161,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), @@ -199,6 +209,8 @@ public DottedVersion getMinimumOsForPlatformType(ApplePlatform.PlatformType plat return iosMinimumOsVersion; case TVOS: return tvosMinimumOsVersion; + case VISIONOS: + return visionosMinimumOsVersion; case WATCHOS: return watchosMinimumOsVersion; case MACOS: @@ -220,6 +232,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; @@ -283,6 +298,12 @@ public DottedVersion getTvosSdkVersionForStarlark(StarlarkThread thread) throws return tvosSdkVersion; } + @StarlarkMethod(name = "visionos_sdk_version", documented = false, useStarlarkThread = true) + public DottedVersion getVisionosSdkVersionForStarlark(StarlarkThread thread) throws EvalException { + checkAccess(thread); + return visionosSdkVersion; + } + @StarlarkMethod(name = "watchos_sdk_version", documented = false, useStarlarkThread = true) public DottedVersion getWatchosSdkVersionForStarlark(StarlarkThread thread) throws EvalException { checkAccess(thread); 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/AppleCrosstoolTransition.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolTransition.java index c4708de6137d4f..2000e5db7122fb 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolTransition.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolTransition.java @@ -212,6 +212,11 @@ private String determineSingleArchitectureCpu( } else { return AppleConfiguration.iosCpuFromCpu(configOptions.cpu); } + case VISIONOS: + if (appleOptions.visionosCpus.isEmpty()) { + return AppleCommandLineOptions.DEFAULT_VISIONOS_CPU; + } + return appleOptions.visionosCpus.get(0); case WATCHOS: if (appleOptions.watchosCpus.isEmpty()) { return AppleCommandLineOptions.DEFAULT_WATCHOS_CPU; 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 dabfd20f139c52..e980a266b88b27 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 @@ -117,7 +117,7 @@ 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 0c61707d48a3d8..bc381a5639af21 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 @@ -336,6 +336,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: @@ -371,6 +373,9 @@ private static DottedVersion.Option minimumOsVersionOption( case CATALYST: option = buildOptions.get(AppleCommandLineOptions.class).iosMinimumOs; break; + case VISIONOS: + option = buildOptions.get(AppleCommandLineOptions.class).visionosMinimumOs; + break; case WATCHOS: option = buildOptions.get(AppleCommandLineOptions.class).watchosMinimumOs; break; @@ -409,6 +414,9 @@ private static BuildOptionsView defaultBuildOptionsForSplit( case CATALYST: appleCommandLineOptions.iosMinimumOs = minimumOsVersionOption; break; + case VISIONOS: + appleCommandLineOptions.visionosMinimumOs = minimumOsVersionOption; + break; case WATCHOS: appleCommandLineOptions.watchosMinimumOs = minimumOsVersionOption; break; @@ -546,6 +554,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/ObjcCommandLineOptions.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java index 6b92f8a01f0b23..8a5488a9acc4f4 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 @@ -48,6 +48,26 @@ public class ObjcCommandLineOptions extends FragmentOptions { + "devicetypes' on the machine the simulator will be run on.") public String iosSimulatorDevice; + @Option( + name = "visionos_simulator_version", + defaultValue = "null", + converter = DottedVersionConverter.class, + documentationCategory = OptionDocumentationCategory.TESTING, + effectTags = {OptionEffectTag.TEST_RUNNER}, + help = "The version of visionOS to run on the simulator when running or testing.") + public DottedVersion.Option visionosSimulatorVersion; + + @Option( + name = "visionos_simulator_device", + defaultValue = "null", + documentationCategory = OptionDocumentationCategory.TESTING, + effectTags = {OptionEffectTag.TEST_RUNNER}, + help = + "The device to simulate when running a visionOS application in the simulator, e.g. " + + "'Apple Vision Pro'. You can get a list of devices by running 'xcrun simctl list " + + "devicetypes' on the machine the simulator will be run on.") + public String visionosSimulatorDevice; + @Option( name = "watchos_simulator_version", defaultValue = "null", 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 83ee261ed77314..d8926983273e26 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 @@ -58,6 +58,8 @@ public class ObjcConfiguration extends Fragment implements ObjcConfigurationApi< private final DottedVersion iosSimulatorVersion; private final String iosSimulatorDevice; + private final DottedVersion visionosSimulatorVersion; + private final String visionosSimulatorDevice; private final DottedVersion watchosSimulatorVersion; private final String watchosSimulatorDevice; private final DottedVersion tvosSimulatorVersion; @@ -85,6 +87,8 @@ public ObjcConfiguration(BuildOptions buildOptions) { this.iosSimulatorDevice = objcOptions.iosSimulatorDevice; this.iosSimulatorVersion = DottedVersion.maybeUnwrap(objcOptions.iosSimulatorVersion); + this.visionosSimulatorDevice = objcOptions.visionosSimulatorDevice; + this.visionosSimulatorVersion = DottedVersion.maybeUnwrap(objcOptions.visionosSimulatorVersion); this.watchosSimulatorDevice = objcOptions.watchosSimulatorDevice; this.watchosSimulatorVersion = DottedVersion.maybeUnwrap(objcOptions.watchosSimulatorVersion); this.tvosSimulatorDevice = objcOptions.tvosSimulatorDevice; @@ -126,6 +130,8 @@ public String getSimulatorDeviceForPlatformType(PlatformType platformType) { return iosSimulatorDevice; case TVOS: return tvosSimulatorDevice; + case VISIONOS: + return visionosSimulatorDevice; case WATCHOS: return watchosSimulatorDevice; default: @@ -141,6 +147,8 @@ public DottedVersion getSimulatorVersionForPlatformType(PlatformType platformTyp return iosSimulatorVersion; case TVOS: return tvosSimulatorVersion; + case VISIONOS: + return visionosSimulatorVersion; case WATCHOS: return watchosSimulatorVersion; default: 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 1fed55221a6b22..dfe0735272a2e4 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 @@ -171,7 +171,7 @@ 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. + "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 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 8ad811e7176d76..11c29e9d08dd0b 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 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 = {