Skip to content

Commit 4e586b6

Browse files
committed
Apple: Core visionOS Support
This PR builds on the [Core iOS support PR](PixarAnimationStudios#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 fe9724d commit 4e586b6

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
@@ -26,15 +26,17 @@
2626
TARGET_ARM64 = "arm64"
2727
TARGET_UNIVERSAL = "universal"
2828
TARGET_IOS = "iOS"
29+
TARGET_VISIONOS = "visionOS"
2930

30-
EMBEDDED_PLATFORMS = [TARGET_IOS]
31+
EMBEDDED_PLATFORMS = [TARGET_IOS, TARGET_VISIONOS]
3132

3233
def GetBuildTargets():
3334
return [TARGET_NATIVE,
3435
TARGET_X86,
3536
TARGET_ARM64,
3637
TARGET_UNIVERSAL,
37-
TARGET_IOS]
38+
TARGET_IOS,
39+
TARGET_VISIONOS]
3840

3941
def GetBuildTargetDefault():
4042
return TARGET_NATIVE
@@ -118,6 +120,8 @@ def GetSDKRoot(context) -> Optional[str]:
118120
sdk = "macosx"
119121
if context.buildTarget == TARGET_IOS:
120122
sdk = "iphoneos"
123+
elif context.buildTarget == TARGET_VISIONOS:
124+
sdk = "xros"
121125

122126
for arg in (context.cmakeBuildArgs or '').split():
123127
if "CMAKE_OSX_SYSROOT" in arg:
@@ -133,6 +137,7 @@ def SetTarget(context, targetName):
133137
context.targetARM64 = (targetName == GetTargetArmArch())
134138
context.targetUniversal = (targetName == TARGET_UNIVERSAL)
135139
context.targetIos = (targetName == TARGET_IOS)
140+
context.targetVisionos = (targetName == TARGET_VISIONOS)
136141
if context.targetUniversal and not SupportsMacOSUniversalBinaries():
137142
context.targetUniversal = False
138143
raise ValueError(
@@ -262,8 +267,8 @@ def CreateUniversalBinaries(context, libNames, x86Dir, armDir):
262267

263268
def ConfigureCMakeExtraArgs(context, args:List[str]) -> List[str]:
264269
system_name = None
265-
if context.buildTarget == TARGET_IOS:
266-
system_name = "iOS"
270+
if context.buildTarget in EMBEDDED_PLATFORMS:
271+
system_name = context.buildTarget
267272

268273
if system_name:
269274
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
@@ -992,6 +992,31 @@ def InstallTBB_MacOS(context, force, buildArgs):
992992
"ifeq ($(arch),$(filter $(arch),armv7 armv7s {0}))"
993993
.format(apple_utils.GetTargetArmArch()))])
994994

995+
if context.buildTarget == apple_utils.TARGET_VISIONOS:
996+
# Create visionOS config from iOS config
997+
shutil.copy(
998+
src="build/ios.macos.inc",
999+
dst="build/visionos.macos.inc")
1000+
1001+
PatchFile("build/visionos.macos.inc",
1002+
[("ios","visionos"),
1003+
("iOS", "visionOS"),
1004+
("iPhone", "XR"),
1005+
("IPHONEOS","XROS"),
1006+
("?= 8.0", "?= 1.0")])
1007+
1008+
# iOS clang just reuses the macOS one, so it's easier to copy it directly
1009+
shutil.copy(src="build/macos.clang.inc",
1010+
dst="build/visionos.clang.inc")
1011+
1012+
1013+
PatchFile("build/visionos.clang.inc",
1014+
[("ios","visionos"),
1015+
("-miphoneos-version-min=", "-target arm64-apple-xros"),
1016+
("iOS", "visionOS"),
1017+
("iPhone", "XR"),
1018+
("IPHONEOS","XROS")])
1019+
9951020
(primaryArch, secondaryArch) = apple_utils.GetTargetArchPair(context)
9961021

9971022
# tbb uses different arch names
@@ -2378,6 +2403,10 @@ def ForceBuildDependency(self, dep):
23782403
elif MacOS():
23792404
# Apple Silicon is not supported prior to 3.19
23802405
cmake_required_version = (3, 19)
2406+
2407+
# visionOS support was added in CMake 3.28
2408+
if context.buildTarget == apple_utils.TARGET_VISIONOS:
2409+
cmake_required_version = (3, 28)
23812410
else:
23822411
# Linux, and vfx platform CY2020, are verified to work correctly with 3.14
23832412
cmake_required_version = (3, 14)

0 commit comments

Comments
 (0)