From 4d832b5bc048cc44863b5e94f994afda14d5e9d6 Mon Sep 17 00:00:00 2001 From: dkimitsa Date: Sat, 1 Jul 2023 15:41:30 +0300 Subject: [PATCH] * XrOS support: separate set of native VM code have to build specially for xrOS/xrOS-simulator. --- compiler/vm/CMakeLists.txt | 47 ++++++++++++++++++++++++++++++++++++-- compiler/vm/build.sh | 9 ++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/compiler/vm/CMakeLists.txt b/compiler/vm/CMakeLists.txt index e4904b1e3..9bb79472b 100755 --- a/compiler/vm/CMakeLists.txt +++ b/compiler/vm/CMakeLists.txt @@ -9,6 +9,8 @@ set(MACOSX_ARM64_MIN_VERSION 13.0) set(IOS_MIN_VERSION 8.0) # The minimum m1 Arm64 iOS simulator version needed by apps built by RoboVM set(IOS_ARM64_SIM_MIN_VERSION 14.0) +# The minimum m1 Arm64 xrOS version needed by apps built by RoboVM +set(XROS_MIN_VERSION 1.0) project(build) @@ -96,6 +98,33 @@ elseif(OS STREQUAL "ios") message(FATAL_ERROR "Unsupported ARCH: ${ARCH}") endif() set(CPLATFORM_MIN_VERSION ${IOS_MIN_VERSION}) +elseif(OS STREQUAL "xros") + set(XROS YES) + set(DARWIN YES) + set(OS_FAMILY darwin) + if (ARCH STREQUAL "x86_64-simulator") + set(X86_64 YES) + set(64_BIT YES) + set(CTARGET "x86_64-apple-xros${XROS_MIN_VERSION}-simulator") + set(CARCH x86_64) + set(CPLATFORM xros-simulator) + elseif (ARCH STREQUAL "arm64-simulator") + set(ARM64 YES) + set(64_BIT YES) + set(CTARGET "arm64-apple-xros${XROS_MIN_VERSION}-simulator") + set(CARCH arm64) + set(CPLATFORM xros-simulator) + elseif (ARCH STREQUAL "arm64") + set(ARM YES) + set(ARM64 YES) + set(64_BIT YES) + set(CTARGET "arm64-apple-xros${XROS_MIN_VERSION}") + set(CARCH arm64) + set(CPLATFORM xros) + else() + message(FATAL_ERROR "Unsupported ARCH: ${ARCH}") + endif() + set(CPLATFORM_MIN_VERSION ${XROS_MIN_VERSION}) else() message(FATAL_ERROR "Unsupported OS: ${OS}") endif() @@ -121,9 +150,20 @@ if(DARWIN) message(FATAL_ERROR "Failed to locate iPhoneOS SDK") endif() endif() + elseif(XROS) + if(ARCH MATCHES "^(x86_64-simulator|arm64-simulator)$") + set(SYSROOT "${XCODE_PATH}/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator.sdk") + if(NOT IS_DIRECTORY ${SYSROOT}) + message(FATAL_ERROR "Failed to locate XRSimulator SDK") + endif() + else() + set(SYSROOT "${XCODE_PATH}/Platforms/XROS.platform/Developer/SDKs/XROS.sdk") + if(NOT IS_DIRECTORY ${SYSROOT}) + message(FATAL_ERROR "Failed to locate XROS.sdk SDK") + endif() + endif() endif() endif() - set(CPLATFORM_MIN_VERSION ${IOS_MIN_VERSION}) else() message(FATAL_ERROR "Unsupported OS: ${OS}") endif() @@ -195,6 +235,9 @@ if(IOS) set(ASM_FLAGS "${ASM_FLAGS} -fembed-bitcode") endif() endif() +if(XROS) + set(ASM_FLAGS "${ASM_FLAGS} -target ${CTARGET}") +endif() set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} ${ASM_FLAGS} -o ") enable_language(ASM) @@ -271,7 +314,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "debug") set(EXTGC_C_FLAGS "${EXTGC_C_FLAGS} -g") set(EXTGC_PARAMS "${EXTGC_PARAMS} --enable-gc-debug=yes") endif() -if (IOS OR MACOSX) +if (IOS OR MACOSX OR XROS) if (ARCH STREQUAL "x86_64") set(EXT_HOST --host=x86_64-apple-darwin7) elseif (ARCH STREQUAL "arm64-simulator") diff --git a/compiler/vm/build.sh b/compiler/vm/build.sh index 855fead39..a5d5bf737 100755 --- a/compiler/vm/build.sh +++ b/compiler/vm/build.sh @@ -21,6 +21,8 @@ Options: ios-arm64-simulator Linux: linux-x86_64 + xrOS: + xros-arm64, xros-arm64-simulator, xros-x86_64-simulator Enclose multiple targets in quotes and separate with spaces or specify --target multiple times. If not set the current host OS determines the @@ -58,7 +60,7 @@ if [ "x$TARGETS" = 'x' ]; then OS=$(uname) case $OS in Darwin) - TARGETS="macosx-x86_64 macosx-arm64 ios-x86_64-simulator ios-arm64-simulator ios-thumbv7 ios-arm64" + TARGETS="macosx-x86_64 macosx-arm64 ios-x86_64-simulator ios-arm64-simulator ios-thumbv7 ios-arm64 xros-x86_64-simulator xros-arm64-simulator xros-arm64" ;; Linux) TARGETS="linux-x86_64" @@ -75,7 +77,7 @@ fi # Validate targets for T in $TARGETS; do - if ! [[ $T =~ (macosx-(x86_64|arm64))|(ios-(x86_64-simulator|arm64-simulator|thumbv7|arm64))|(linux-(x86_64)) ]] ; then + if ! [[ $T =~ (macosx-(x86_64|arm64))|(ios-(x86_64-simulator|arm64-simulator|thumbv7|arm64))|(xros-(x86_64-simulator|arm64-simulator|arm64))|(linux-(x86_64)) ]] ; then echo "Unsupported target: $T" exit 1 fi @@ -125,6 +127,9 @@ for T in $TARGETS; do ios) SYSTEM_NAME_PARAM="-DCMAKE_SYSTEM_NAME=iOS" ;; + xros) + SYSTEM_NAME_PARAM="-DCMAKE_SYSTEM_NAME=Darwin" + ;; *) SYSTEM_NAME_PARAM="" ;;