Skip to content

Commit

Permalink
Add support for XROS (aka visionOS) (#53)
Browse files Browse the repository at this point in the history
Co-authored-by: Davide De Rosa <[email protected]>
  • Loading branch information
nferruzzi and keeshux authored Jan 11, 2024
1 parent 026702f commit ab3f2bc
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 1 deletion.
24 changes: 24 additions & 0 deletions assets/XROS/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>openssl</string>
<key>CFBundleIdentifier</key>
<string>org.openssl.OpenSSL</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>openssl</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>$(OPENSSL_VERSION)</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>MinimumOSVersion</key>
<string>$(MIN_SDK_VERSION)</string>
</dict>
</plist>
1 change: 1 addition & 0 deletions assets/XRSimulator
28 changes: 28 additions & 0 deletions build-libssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ macos64-x86_64 macos64-arm64
mac-catalyst-x86_64 mac-catalyst-arm64
watchos-cross-armv7k watchos-cross-arm64_32 watchos-sim-cross-x86_64 watchos-sim-cross-i386 watchos-sim-cross-arm64
tvos-sim-cross-x86_64 tvos-sim-cross-arm64 tvos-cross-arm64
xros-sim-cross-arm64 xros-cross-arm64
TARGETS`
# Minimum iOS/tvOS SDK version to build for
Expand All @@ -42,6 +43,7 @@ MACOS_MIN_SDK_VERSION="10.14"
CATALYST_MIN_SDK_VERSION="10.14"
WATCHOS_MIN_SDK_VERSION="4.0"
TVOS_MIN_SDK_VERSION="12.0"
XROS_MIN_SDK_VERSION="1.0"
# Init optional env variables (use available variable or default to empty string)
CURL_OPTIONS="${CURL_OPTIONS:-}"
Expand All @@ -60,6 +62,7 @@ echo_help()
echo " --catalyst-sdk=SDKVERSION Override macOS SDK version for Catalyst"
echo " --watchos-sdk=SDKVERSION Override watchOS SDK version"
echo " --tvos-sdk=SDKVERSION Override tvOS SDK version"
echo " --xros-sdk=SDKVERSION Override xrOS SDK version"
echo " --min-ios-sdk=SDKVERSION Set minimum iOS SDK version (default: $IOS_MIN_SDK_VERSION)"
echo " --min-macos-sdk=SDKVERSION Set minimum macOS SDK version (default: $MACOS_MIN_SDK_VERSION)"
echo " --min-watchos-sdk=SDKVERSION Set minimum watchOS SDK version (default: $WATCHOS_MIN_SDK_VERSION)"
Expand Down Expand Up @@ -180,6 +183,14 @@ finish_build_loop()
else
OPENSSLCONF_SUFFIX="ios_${ARCH}"
fi
elif [[ "${PLATFORM}" == XR* ]]; then
LIBSSL_XROS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_XROS+=("${TARGETDIR}/lib/libcrypto.a")
if [[ "${PLATFORM}" == XRSimulator* ]]; then
OPENSSLCONF_SUFFIX="xros_sim_${ARCH}"
else
OPENSSLCONF_SUFFIX="xros_${ARCH}"
fi
elif [[ "${PLATFORM}" == Watch* ]]; then
LIBSSL_WATCHOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_WATCHOS+=("${TARGETDIR}/lib/libcrypto.a")
Expand Down Expand Up @@ -243,6 +254,7 @@ MACOS_SDKVERSION=""
CATALYST_SDKVERSION=""
WATCHOS_SDKVERSION=""
TVOS_SDKVERSION=""
XROS_SDKVERSION=""
LOG_VERBOSE=""
PARALLEL=""
TARGETS=""
Expand Down Expand Up @@ -305,6 +317,10 @@ case $i in
TVOS_MIN_SDK_VERSION="${i#*=}"
shift
;;
--min-xros-sdk=*)
XROS_MIN_SDK_VERSION="${i#*=}"
shift
;;
--noparallel)
PARALLEL="false"
;;
Expand Down Expand Up @@ -392,6 +408,9 @@ fi
if [ ! -n "${TVOS_SDKVERSION}" ]; then
TVOS_SDKVERSION=$(xcrun -sdk appletvos --show-sdk-version)
fi
if [ ! -n "${XROS_SDKVERSION}" ]; then
XROS_SDKVERSION=$(xcrun -sdk xros --show-sdk-version)
fi
# Truncate to minor version
MINOR_VERSION=(${MACOS_SDKVERSION//./ })
Expand Down Expand Up @@ -446,6 +465,7 @@ echo " macOS SDK: ${MACOS_SDKVERSION} (min ${MACOS_MIN_SDK_VERSION})"
echo " macOS SDK (Catalyst): ${CATALYST_SDKVERSION} (min ${CATALYST_MIN_SDK_VERSION})"
echo " watchOS SDK: ${WATCHOS_SDKVERSION} (min ${WATCHOS_MIN_SDK_VERSION})"
echo " tvOS SDK: ${TVOS_SDKVERSION} (min ${TVOS_MIN_SDK_VERSION})"
echo " xrOS SDK: ${XROS_SDKVERSION} (min ${XROS_MIN_SDK_VERSION})"
if [ "${CONFIG_DISABLE_BITCODE}" == "true" ]; then
echo " Bitcode embedding disabled"
fi
Expand Down Expand Up @@ -547,6 +567,8 @@ LIBSSL_WATCHOS=()
LIBCRYPTO_WATCHOS=()
LIBSSL_TVOS=()
LIBCRYPTO_TVOS=()
LIBSSL_XROS=()
LIBCRYPTO_XROS=()
source "${SCRIPTDIR}/scripts/build-loop-targets.sh"
Expand Down Expand Up @@ -619,6 +641,12 @@ if [ ${#OPENSSLCONF_ALL[@]} -gt 1 ]; then
*_tvos_sim_x86_64.h)
DEFINE_CONDITION="TARGET_OS_TV && TARGET_OS_SIMULATOR && TARGET_CPU_X86_64"
;;
*_xros_sim_arm64.h)
DEFINE_CONDITION="TARGET_OS_VISION && TARGET_OS_SIMULATOR && TARGET_CPU_ARM64"
;;
*_xros_arm64.h)
DEFINE_CONDITION="TARGET_OS_VISION && TARGET_CPU_ARM64"
;;
*)
# Don't run into unexpected cases by setting the default condition to false
DEFINE_CONDITION="0"
Expand Down
27 changes: 27 additions & 0 deletions config/20-all-platforms.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ my %targets = ();
cflags => add(sub { defined($ENV{'TVOS_MIN_SDK_VERSION'}) ? '-mtvos-version-min=$(TVOS_MIN_SDK_VERSION)' : '-mtvos-version-min=12.0'; }),
defines => [ "HAVE_FORK=0" ],
},
"xros-cross-base" => {
inherit_from => [ "all-base" ],
template => 1,
# cflags => add(sub { defined($ENV{'XROS_MIN_SDK_VERSION'}) ? '-mxros-version-min=$(XROS_MIN_SDK_VERSION)' : '-mxros-version-min=1.0'; }),
},

## Apple iOS

Expand Down Expand Up @@ -151,4 +156,26 @@ my %targets = ();
inherit_from => [ "darwin64-x86_64-cc", "tvos-cross-base" ],
sys_id => "tvOS",
},

## Vision OS

# Device
"xros-cross-arm64" => {
inherit_from => [ "darwin64-arm64-cc", "xros-cross-base" ],
cflags => add("-arch arm64"),
bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
sys_id => "xros",
},
# Simulator
"xros-sim-cross-arm64" => {
inherit_from => [ "darwin64-arm64-cc", "xros-cross-base" ],
cflags => add("-arch arm64"),
bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
sys_id => "xros",
},
"xros-sim-cross-x86_64" => {
inherit_from => [ "darwin64-x86_64-cc", "xros-cross-base" ],
sys_id => "xros",
},

);
6 changes: 5 additions & 1 deletion create-openssl-framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [ -d $FWROOT ]; then
fi

#ALL_SYSTEMS=("iPhone" "AppleTV" "MacOSX" "Catalyst" "Watch")
ALL_SYSTEMS=("iPhoneOS" "iPhoneSimulator" "AppleTVOS" "AppleTVSimulator" "MacOSX" "Catalyst" "WatchOS" "WatchSimulator")
ALL_SYSTEMS=("iPhoneOS" "iPhoneSimulator" "AppleTVOS" "AppleTVSimulator" "MacOSX" "Catalyst" "WatchOS" "WatchSimulator" "XROS" "XRSimulator")

# Inspect Mach-O load commands to get minimum SDK version.
#
Expand Down Expand Up @@ -123,6 +123,10 @@ for TARGETDIR in `ls -d *.sdk`; do
MIN_SDK="-platform_version watchos $MIN_SDK_VERSION $SDKVERSION"
elif [[ $PLATFORM == WatchSimulator* ]]; then
MIN_SDK="-platform_version watchos-simulator $MIN_SDK_VERSION $SDKVERSION"
elif [[ $PLATFORM == XRSimulator* ]]; then
MIN_SDK="-platform_version xros-simulator $MIN_SDK_VERSION $SDKVERSION"
elif [[ $PLATFORM == XR* ]]; then
MIN_SDK="-platform_version xros $MIN_SDK_VERSION $SDKVERSION"
else
MIN_SDK="-platform_version ios $MIN_SDK_VERSION $SDKVERSION"
fi
Expand Down
7 changes: 7 additions & 0 deletions scripts/build-loop-targets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ do
SDKVERSION="${WATCHOS_SDKVERSION}"
elif [[ "${TARGET}" == tvos* ]]; then
SDKVERSION="${TVOS_SDKVERSION}"
elif [[ "${TARGET}" == xr* ]]; then
SDKVERSION="${XROS_SDKVERSION}"
else
SDKVERSION="${IOS_SDKVERSION}"
fi
Expand All @@ -41,6 +43,7 @@ do
export CATALYST_MIN_SDK_VERSION
export WATCHOS_MIN_SDK_VERSION
export TVOS_MIN_SDK_VERSION
export XROS_MIN_SDK_VERSION
export CONFIG_DISABLE_BITCODE

# Determine platform
Expand All @@ -61,6 +64,10 @@ do
PLATFORM="AppleTVOS"
elif [[ "${TARGET}" == "ios-sim-cross-"* ]]; then
PLATFORM="iPhoneSimulator"
elif [[ "${TARGET}" == "xros-sim-cross"* ]]; then
PLATFORM="XRSimulator"
elif [[ "${TARGET}" == "xros"* ]]; then
PLATFORM="XROS"
else
PLATFORM="iPhoneOS"
fi
Expand Down

0 comments on commit ab3f2bc

Please sign in to comment.