Skip to content

Commit d4b4c53

Browse files
committed
Apple: Core visionOS Support
This PR builds on the [Core iOS support PR](#2949) to add support for building the USD core for visionOS. Thanks to Valentin Roussellet for the basis of the TBB patch. It includes the following changes: * Use CMake 3.28 (which adds visionOS support) * Patch TBB to support visionOS. Note that clang requires new platforms to be provided via the target triplet. * Add visionOS to the accepted platforms. Note that visionOS's SDK is called xros, much like how the iOS SDK is iphoneos for historical reasons.
1 parent cad5058 commit d4b4c53

3 files changed

Lines changed: 41 additions & 7 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ then build and install USD into `/path/to/my_usd_install_dir`.
141141
> python OpenUSD/build_scripts/build_usd.py /path/to/my_usd_install_dir
142142
```
143143

144-
###### iOS
144+
###### iOS and visionOS
145145

146146
When building from a macOS system, you can cross compile for iOS based platforms.
147147

148148
iOS builds currently do not support Imaging.
149149
Additionally, they will not support Python bindings or command line tools.
150150

151-
To build for iOS, add the `--build-target iOS` parameter.
152-
151+
* To build for iOS, add the `--build-target iOS` parameter.
152+
* To build for visionOS, add the `--build-target visionOS` parameter.
153153

154154
##### Windows:
155155

build_scripts/apple_utils.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,17 @@
4343
TARGET_ARM64 = "arm64"
4444
TARGET_UNIVERSAL = "universal"
4545
TARGET_IOS = "iOS"
46+
TARGET_VISIONOS = "visionOS"
4647

47-
EMBEDDED_PLATFORMS = [TARGET_IOS]
48+
EMBEDDED_PLATFORMS = [TARGET_IOS, TARGET_VISIONOS]
4849

4950
def GetBuildTargets():
5051
return [TARGET_NATIVE,
5152
TARGET_X86,
5253
TARGET_ARM64,
5354
TARGET_UNIVERSAL,
54-
TARGET_IOS]
55+
TARGET_IOS,
56+
TARGET_VISIONOS]
5557

5658
def GetBuildTargetDefault():
5759
return TARGET_NATIVE
@@ -135,6 +137,8 @@ def GetSDKRoot(context) -> Optional[str]:
135137
sdk = "macosx"
136138
if context.buildTarget == TARGET_IOS:
137139
sdk = "iphoneos"
140+
elif context.buildTarget == TARGET_VISIONOS:
141+
sdk = "xros"
138142

139143
for arg in (context.cmakeBuildArgs or '').split():
140144
if "CMAKE_OSX_SYSROOT" in arg:
@@ -150,6 +154,7 @@ def SetTarget(context, targetName):
150154
context.targetARM64 = (targetName == GetTargetArmArch())
151155
context.targetUniversal = (targetName == TARGET_UNIVERSAL)
152156
context.targetIos = (targetName == TARGET_IOS)
157+
context.targetVisionos = (targetName == TARGET_VISIONOS)
153158
if context.targetUniversal and not SupportsMacOSUniversalBinaries():
154159
context.targetUniversal = False
155160
raise ValueError(
@@ -279,8 +284,8 @@ def CreateUniversalBinaries(context, libNames, x86Dir, armDir):
279284

280285
def ConfigureCMakeExtraArgs(context, args:List[str]) -> List[str]:
281286
system_name = None
282-
if context.buildTarget == TARGET_IOS:
283-
system_name = "iOS"
287+
if context.buildTarget in EMBEDDED_PLATFORMS:
288+
system_name = context.buildTarget
284289

285290
if system_name:
286291
args.append(f"-DCMAKE_SYSTEM_NAME={system_name}")

build_scripts/build_usd.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,31 @@ def InstallTBB_MacOS(context, force, buildArgs):
10091009
"ifeq ($(arch),$(filter $(arch),armv7 armv7s {0}))"
10101010
.format(apple_utils.GetTargetArmArch()))])
10111011

1012+
if context.buildTarget == apple_utils.TARGET_VISIONOS:
1013+
# Create visionOS config from iOS config
1014+
shutil.copy(
1015+
src="build/ios.macos.inc",
1016+
dst="build/visionos.macos.inc")
1017+
1018+
PatchFile("build/visionos.macos.inc",
1019+
[("ios","visionos"),
1020+
("iOS", "visionOS"),
1021+
("iPhone", "XR"),
1022+
("IPHONEOS","XROS"),
1023+
("?= 8.0", "?= 1.0")])
1024+
1025+
# iOS clang just reuses the macOS one, so it's easier to copy it directly
1026+
shutil.copy(src="build/macos.clang.inc",
1027+
dst="build/visionos.clang.inc")
1028+
1029+
1030+
PatchFile("build/visionos.clang.inc",
1031+
[("ios","visionos"),
1032+
("-miphoneos-version-min=", "-target arm64-apple-xros"),
1033+
("iOS", "visionOS"),
1034+
("iPhone", "XR"),
1035+
("IPHONEOS","XROS")])
1036+
10121037
(primaryArch, secondaryArch) = apple_utils.GetTargetArchPair(context)
10131038

10141039
# tbb uses different arch names
@@ -2399,6 +2424,10 @@ def ForceBuildDependency(self, dep):
23992424
elif MacOS():
24002425
# Apple Silicon is not supported prior to 3.19
24012426
cmake_required_version = (3, 19)
2427+
2428+
# visionOS support was added in CMake 3.28
2429+
if context.buildTarget == apple_utils.TARGET_VISIONOS:
2430+
cmake_required_version = (3, 28)
24022431
else:
24032432
# Linux, and vfx platform CY2020, are verified to work correctly with 3.14
24042433
cmake_required_version = (3, 14)

0 commit comments

Comments
 (0)