Skip to content

Commit

Permalink
* XrOS support: separate set of native VM code have to build speciall…
Browse files Browse the repository at this point in the history
…y for xrOS/xrOS-simulator.
  • Loading branch information
dkimitsa committed Jul 1, 2023
1 parent 8884e14 commit 4d832b5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
47 changes: 45 additions & 2 deletions compiler/vm/CMakeLists.txt
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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 <OBJECT> <SOURCE>")
enable_language(ASM)

Expand Down Expand Up @@ -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")
Expand Down
9 changes: 7 additions & 2 deletions compiler/vm/build.sh
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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=""
;;
Expand Down

0 comments on commit 4d832b5

Please sign in to comment.