Skip to content

Commit 36d17e9

Browse files
Add support for visionOS (#52)
Adds support for building dependencies for visionOS (neé xrOS). Signed-off-by: Xinyuan Zhou <[email protected]> Co-authored-by: John Zhou <[email protected]>
1 parent 097fdaa commit 36d17e9

File tree

6 files changed

+154
-37
lines changed

6 files changed

+154
-37
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: macOS-latest
2121
strategy:
2222
matrix:
23-
target: [ "iOS", "tvOS", "watchOS" ]
23+
target: [ "iOS", "tvOS", "watchOS", "visionOS" ]
2424
steps:
2525
- name: Checkout
2626
uses: actions/[email protected]

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
BUILD_NUMBER: ${{ steps.build-vars.outputs.BUILD_NUMBER }}
1717
strategy:
1818
matrix:
19-
target: [ "iOS", "tvOS", "watchOS" ]
19+
target: [ "iOS", "tvOS", "watchOS", "visionOS" ]
2020
steps:
2121
- name: Checkout
2222
uses: actions/[email protected]

Makefile

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,41 @@
11
#
22
# Useful targets:
3-
# - all - build everything
4-
# - iOS - build everything for iOS
5-
# - tvOS - build everything for tvOS
6-
# - watchOS - build everything for watchOS
7-
# - BZip2 - build BZip2 for all platforms
8-
# - BZip2-iOS - build BZip2 for iOS
9-
# - BZip2-tvOS - build BZip2 for tvOS
10-
# - BZip2-watchOS - build BZip2 for watchOS
11-
# - XZ - build XZ for all platforms
12-
# - XZ-iOS - build XZ for iOS
13-
# - XZ-tvOS - build XZ for tvOS
14-
# - XZ-watchOS - build XZ for watchOS
15-
# - OpenSSL - build OpenSSL for all platforms
16-
# - OpenSSL-iOS - build OpenSSL for iOS
17-
# - OpenSSL-tvOS - build OpenSSL for tvOS
18-
# - OpenSSL-watchOS - build OpenSSL for watchOS
19-
# - mpdecimal - build mpdecimal for all platforms
20-
# - mpdecimal-iOS - build mpdecimal for iOS
21-
# - mpdecimal-tvOS - build mpdecimal for tvOS
22-
# - mpdecimal-watchOS - build mpdecimal for watchOS
23-
# - libFFI-iOS - build libFFI for iOS
24-
# - libFFI-tvOS - build libFFI for tvOS
25-
# - libFFI-watchOS - build libFFI for watchOS
3+
# - all - build everything
4+
# - iOS - build everything for iOS
5+
# - tvOS - build everything for tvOS
6+
# - watchOS - build everything for watchOS
7+
# - visionOS - build everything for visionOS
8+
# - BZip2 - build BZip2 for all platforms
9+
# - BZip2-iOS - build BZip2 for iOS
10+
# - BZip2-tvOS - build BZip2 for tvOS
11+
# - BZip2-watchOS - build BZip2 for watchOS
12+
# - BZip2-visionOS - build BZip2 for visionOS
13+
# - XZ - build XZ for all platforms
14+
# - XZ-iOS - build XZ for iOS
15+
# - XZ-tvOS - build XZ for tvOS
16+
# - XZ-watchOS - build XZ for watchOS
17+
# - XZ-visionOS - build XZ for xrOS
18+
# - OpenSSL - build OpenSSL for all platforms
19+
# - OpenSSL-iOS - build OpenSSL for iOS
20+
# - OpenSSL-tvOS - build OpenSSL for tvOS
21+
# - OpenSSL-watchOS - build OpenSSL for watchOS
22+
# - OpenSSL-visionOS - build OpenSSL for visionOS
23+
# - mpdecimal - build mpdecimal for all platforms
24+
# - mpdecimal-iOS - build mpdecimal for iOS
25+
# - mpdecimal-tvOS - build mpdecimal for tvOS
26+
# - mpdecimal-watchOS - build mpdecimal for watchOS
27+
# - mpdecimal-visionOS - build mpdecimal for visionOS
28+
# - libFFI-iOS - build libFFI for iOS
29+
# - libFFI-tvOS - build libFFI for tvOS
30+
# - libFFI-watchOS - build libFFI for watchOS
31+
# - libFFI-visionOS - build libFFI for visionOS
2632

2733
# Current directory
2834
PROJECT_DIR=$(shell pwd)
2935

3036
# Supported OS and products
3137
PRODUCTS=BZip2 XZ OpenSSL libFFI
32-
OS_LIST=iOS tvOS watchOS
38+
OS_LIST=iOS tvOS watchOS visionOS
3339

3440
# The versions to compile by default.
3541
# In practice, these should be
@@ -58,21 +64,34 @@ CURL_FLAGS=--disable --fail --location --create-dirs --progress-bar
5864

5965
# iOS targets
6066
TARGETS-iOS=iphonesimulator.x86_64 iphonesimulator.arm64 iphoneos.arm64
67+
TRIPLE_OS-iOS=ios
6168
VERSION_MIN-iOS=13.0
6269
CFLAGS-iOS=-mios-version-min=$(VERSION_MIN-iOS)
6370

6471
# tvOS targets
6572
TARGETS-tvOS=appletvsimulator.x86_64 appletvsimulator.arm64 appletvos.arm64
73+
TRIPLE_OS-tvOS=tvos
6674
VERSION_MIN-tvOS=9.0
6775
CFLAGS-tvOS=-mtvos-version-min=$(VERSION_MIN-tvOS)
6876
PYTHON_CONFIGURE-tvOS=ac_cv_func_sigaltstack=no
6977

7078
# watchOS targets
7179
TARGETS-watchOS=watchsimulator.x86_64 watchsimulator.arm64 watchos.arm64_32
80+
TRIPLE_OS-watchOS=watchos
7281
VERSION_MIN-watchOS=4.0
7382
CFLAGS-watchOS=-mwatchos-version-min=$(VERSION_MIN-watchOS)
7483
PYTHON_CONFIGURE-watchOS=ac_cv_func_sigaltstack=no
7584

85+
# visionOS targets
86+
TARGETS-visionOS=xrsimulator.arm64 xros.arm64
87+
TRIPLE_OS-visionOS=xros
88+
VERSION_MIN-visionOS=2.0
89+
# visionOS doesn't expose -mxros-version-min or similar; it uses the version
90+
# number in the -target triple, or a definition like:
91+
# CFLAGS-visionOS=-arch arm64 -mtargetos=xros$(VERSION_MIN-visionOS)
92+
# For consistency with existing tooling, we use the -target form.
93+
PYTHON_CONFIGURE-visionOS=ac_cv_func_sigaltstack=no
94+
7695
# The architecture of the machine doing the build
7796
HOST_ARCH=$(shell uname -m)
7897

@@ -165,16 +184,14 @@ define build-target
165184
target=$1
166185
os=$2
167186

168-
OS_LOWER-$(target)=$(shell echo $(os) | tr '[:upper:]' '[:lower:]')
169-
170187
# $(target) can be broken up into is composed of $(SDK).$(ARCH)
171188
SDK-$(target)=$$(basename $(target))
172189
ARCH-$(target)=$$(subst .,,$$(suffix $(target)))
173190

174191
ifeq ($$(findstring simulator,$$(SDK-$(target))),)
175-
TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os))
192+
TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(TRIPLE_OS-$(os))$$(VERSION_MIN-$(os))
176193
else
177-
TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os))-simulator
194+
TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(TRIPLE_OS-$(os))$$(VERSION_MIN-$(os))-simulator
178195
endif
179196

180197
SDK_ROOT-$(target)=$$(shell xcrun --sdk $$(SDK-$(target)) --show-sdk-path)
@@ -428,7 +445,7 @@ $$(LIBFFI_LIB-$(target)): $$(LIBFFI_BUILD_LIB-$(target))
428445
# Copy the set of platform headers
429446
cp -f -r $$(LIBFFI_SRCDIR-$(os))/darwin_common/include \
430447
$$(LIBFFI_INSTALL-$(target))
431-
cp -f -r $$(LIBFFI_SRCDIR-$(os))/darwin_$$(OS_LOWER-$(sdk))/include/* \
448+
cp -f -r $$(LIBFFI_SRCDIR-$(os))/darwin_$$(TRIPLE_OS-$(os))/include/* \
432449
$$(LIBFFI_INSTALL-$(target))/include
433450

434451
$$(LIBFFI_DIST-$(target)): $$(LIBFFI_LIB-$(target))
@@ -492,10 +509,6 @@ define build-sdk
492509
sdk=$1
493510
os=$2
494511

495-
OS_LOWER-$(sdk)=$(shell echo $(os) | tr '[:upper:]' '[:lower:]')
496-
497-
WHEEL_TAG-$(sdk)=py3-none-$$(shell echo $$(OS_LOWER-$(sdk))_$$(VERSION_MIN-$(os))_$(sdk) | sed "s/\./_/g")
498-
499512
SDK_TARGETS-$(sdk)=$$(filter $(sdk).%,$$(TARGETS-$(os)))
500513
SDK_ARCHES-$(sdk)=$$(sort $$(subst .,,$$(suffix $$(SDK_TARGETS-$(sdk)))))
501514

@@ -550,6 +563,7 @@ $$(LIBFFI_SRCDIR-$(os))/darwin_common/include/ffi.h: downloads/libffi-$(LIBFFI_V
550563
@echo ">>> Unpack and configure libFFI sources on $(os)"
551564
mkdir -p $$(LIBFFI_SRCDIR-$(os))
552565
tar zxf $$< --strip-components 1 -C $$(LIBFFI_SRCDIR-$(os))
566+
cd $$(LIBFFI_SRCDIR-$(os)) && patch -p1 < $(PROJECT_DIR)/patch/libffi.patch
553567
# Configure the build
554568
cd $$(LIBFFI_SRCDIR-$(os)) && \
555569
python3 generate-darwin-source-and-headers.py --only-$(shell echo $(os) | tr '[:upper:]' '[:lower:]') \

patch/libffi.patch

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
diff -ur libffi-3.4.7 2/config.sub libffi-3.4.7/config.sub
2+
--- libffi-3.4.7 2/config.sub 2024-12-13 04:38:19
3+
+++ libffi-3.4.7/config.sub 2025-04-12 17:44:40
4+
@@ -1742,7 +1742,7 @@
5+
| hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
6+
| sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \
7+
| hiux* | abug | nacl* | netware* | windows* \
8+
- | os9* | macos* | osx* | ios* | tvos* | watchos* \
9+
+ | os9* | macos* | osx* | ios* | tvos* | watchos* | xros* \
10+
| mpw* | magic* | mmixware* | mon960* | lnews* \
11+
| amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
12+
| aos* | aros* | cloudabi* | sortix* | twizzler* \
13+
@@ -1864,7 +1864,7 @@
14+
;;
15+
os2-emx-)
16+
;;
17+
- ios*-simulator* | tvos*-simulator* | watchos*-simulator*)
18+
+ ios*-simulator* | tvos*-simulator* | watchos*-simulator* | xros*-simulator*)
19+
;;
20+
*-eabi*- | *-gnueabi*-)
21+
;;
22+
diff -ur libffi-3.4.7 2/generate-darwin-source-and-headers.py libffi-3.4.7/generate-darwin-source-and-headers.py
23+
--- libffi-3.4.7 2/generate-darwin-source-and-headers.py 2024-06-01 12:42:02
24+
+++ libffi-3.4.7/generate-darwin-source-and-headers.py 2025-04-12 18:02:51
25+
@@ -152,8 +152,22 @@
26+
sdk = 'watchos'
27+
arch = 'arm64_32'
28+
version_min = '-mwatchos-version-min=4.0'
29+
+
30+
+class visionos_simulator_arm64_platform(arm64_platform):
31+
+ target = 'arm64-apple-xros2.0-simulator'
32+
+ directory = 'darwin_xros'
33+
+ sdk = 'xrsimulator'
34+
+ version_min = ''
35+
36+
37+
+class visionos_device_arm64_platform(arm64_platform):
38+
+ target = 'arm64-apple-xros2.0'
39+
+ directory = 'darwin_xros'
40+
+ sdk = 'xros'
41+
+ arch = 'arm64'
42+
+ version_min = ''
43+
+
44+
+
45+
def mkdir_p(path):
46+
try:
47+
os.makedirs(path)
48+
@@ -243,6 +257,7 @@
49+
generate_ios=True,
50+
generate_tvos=True,
51+
generate_watchos=True,
52+
+ generate_visionos=True
53+
):
54+
copy_files('src', 'darwin_common/src', pattern='*.c')
55+
copy_files('include', 'darwin_common/include', pattern='*.h')
56+
@@ -266,6 +281,9 @@
57+
copy_src_platform_files(watchos_simulator_arm64_platform)
58+
copy_src_platform_files(watchos_device_armv7k_platform)
59+
copy_src_platform_files(watchos_device_arm64_32_platform)
60+
+ if generate_visionos:
61+
+ copy_src_platform_files(visionos_simulator_arm64_platform)
62+
+ copy_src_platform_files(visionos_device_arm64_platform)
63+
64+
platform_headers = collections.defaultdict(set)
65+
66+
@@ -288,6 +306,9 @@
67+
build_target(watchos_simulator_arm64_platform, platform_headers)
68+
build_target(watchos_device_armv7k_platform, platform_headers)
69+
build_target(watchos_device_arm64_32_platform, platform_headers)
70+
+ if generate_visionos:
71+
+ build_target(visionos_simulator_arm64_platform, platform_headers)
72+
+ build_target(visionos_device_arm64_platform, platform_headers)
73+
74+
mkdir_p('darwin_common/include')
75+
for header_name, tag_tuples in platform_headers.items():
76+
@@ -302,11 +323,13 @@
77+
parser.add_argument('--only-osx', action='store_true', default=False)
78+
parser.add_argument('--only-tvos', action='store_true', default=False)
79+
parser.add_argument('--only-watchos', action='store_true', default=False)
80+
+ parser.add_argument('--only-visionos', action='store_true', default=False)
81+
args = parser.parse_args()
82+
83+
generate_source_and_headers(
84+
- generate_osx=not args.only_ios and not args.only_tvos and not args.only_watchos,
85+
- generate_ios=not args.only_osx and not args.only_tvos and not args.only_watchos,
86+
- generate_tvos=not args.only_ios and not args.only_osx and not args.only_watchos,
87+
- generate_watchos=not args.only_ios and not args.only_osx and not args.only_tvos,
88+
+ generate_osx=not args.only_ios and not args.only_tvos and not args.only_watchos and not args.only_visionos,
89+
+ generate_ios=not args.only_osx and not args.only_tvos and not args.only_watchos and not args.only_visionos,
90+
+ generate_tvos=not args.only_ios and not args.only_osx and not args.only_watchos and not args.only_visionos,
91+
+ generate_watchos=not args.only_ios and not args.only_osx and not args.only_tvos and not args.only_visionos,
92+
+ generate_visionos=not args.only_ios and not args.only_osx and not args.only_tvos and not args.only_watchos,
93+
)
94+

patch/mpdecimal.patch

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ diff -ur mpdecimal-4.0.0-orig/config.sub mpdecimal-4.0.0/config.sub
1010
cpu=aarch64
1111
;;
1212

13+
@@ -1713,3 +1713,3 @@
14+
| hiux* | abug | nacl* | netware* | windows* \
15+
- | os9* | macos* | osx* | ios* | tvos* | watchos* \
16+
+ | os9* | macos* | osx* | ios* | tvos* | watchos* | xros* \
17+
| mpw* | magic* | mmixware* | mon960* | lnews* \
1318
@@ -1792,6 +1792,8 @@
1419
os2-emx)
1520
;;
1621
*-eabi* | *-gnueabi*)
1722
+ ;;
18-
+ ios*-simulator | tvos*-simulator | watchos*-simulator)
23+
+ ios*-simulator | tvos*-simulator | watchos*-simulator | xros*-simulator)
1924
;;
2025
none-coff* | none-elf*)
2126
# None (no kernel, i.e. freestanding / bare metal),

patch/xz.patch

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ diff -ru xz-5.4.7-orig/build-aux/config.sub xz-5.4.7/build-aux/config.sub
1010
cpu=aarch64
1111
;;
1212

13+
@@ -2150,2 +2150,3 @@
14+
| xray* \
15+
+ | xros* \
16+
| zephyr* \
1317
@@ -1865,6 +1865,8 @@
1418
os2-emx-)
1519
;;
1620
*-eabi*- | *-gnueabi*-)
1721
+ ;;
18-
+ ios*-simulator- | tvos*-simulator- | watchos*-simulator- )
22+
+ ios*-simulator- | tvos*-simulator- | watchos*-simulator- | xros*-simulator-)
1923
;;
2024
none--*)
2125
# None (no kernel, i.e. freestanding / bare metal),

0 commit comments

Comments
 (0)