Skip to content

Commit

Permalink
feat: add visionOS support
Browse files Browse the repository at this point in the history
ci: update to Xcode 15.2
  • Loading branch information
okwasniewski committed Apr 24, 2024
1 parent a58f347 commit 71607be
Show file tree
Hide file tree
Showing 11 changed files with 347 additions and 100 deletions.
48 changes: 33 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ orbs:
android: circleci/android@2.0.3
node: circleci/node@4.7.0

commands:
# Install latest CMake version, needed for building Hermes for visionOS which requires at least CMake 3.29.
brew-install-cmake:
steps:
- run:
name: Install CMake
command: |
brew update
brew install cmake
workflows:
version: 2
build:
Expand Down Expand Up @@ -40,15 +50,12 @@ workflows:
# Default settings for Apple jobs (apple-runtime, test-apple-runtime)
apple_defaults: &apple_defaults
macos:
xcode: 13.4.1
xcode: 15.3
resource_class: macos.m1.medium.gen1
working_directory: ~/hermes
environment:
- TERM: dumb
- HERMES_WS_DIR: /tmp/hermes
# Homebrew currently breaks while updating:
# https://discuss.circleci.com/t/brew-install-fails-while-updating/32992
- HOMEBREW_NO_AUTO_UPDATE: 1

jobs:
android:
Expand Down Expand Up @@ -168,7 +175,8 @@ jobs:
- run:
name: Install dependencies
command: |
brew install cmake ninja
brew install ninja
- brew-install-cmake
- run:
name: Build the test application
command: |
Expand All @@ -189,9 +197,18 @@ jobs:
xcodebuild test \
-workspace ApplePlatformsIntegrationTests.xcworkspace \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 11' \
-destination 'platform=iOS Simulator,name=iPhone 15' \
-scheme ApplePlatformsIntegrationMobileTests
working_directory: test/ApplePlatformsIntegrationTestApp
- run:
name: Test Apple Vision application
command: |
xcodebuild test \
-workspace ApplePlatformsIntegrationTests.xcworkspace \
-configuration Debug \
-destination 'platform=visionOS Simulator,name=Apple Vision Pro' \
-scheme ApplePlatformsIntegrationVisionOSTests
working_directory: test/ApplePlatformsIntegrationTestApp

build-apple-runtime:
<<: *apple_defaults
Expand All @@ -207,8 +224,9 @@ jobs:
- run:
name: Install dependencies
command: |
brew install cmake ninja
brew install ninja
sudo gem install cocoapods
- brew-install-cmake
- run:
name: Build the iOS frameworks
command: ./utils/build-ios-framework.sh
Expand All @@ -222,6 +240,8 @@ jobs:
- ~/hermes/build_catalyst
- ~/hermes/build_iphonesimulator
- ~/hermes/build_macosx
- ~/hermes/build_xros
- ~/hermes/build_xrsimulator
- ~/hermes/destroot

package-apple-runtime:
Expand All @@ -236,8 +256,9 @@ jobs:
- run:
name: Install dependencies
command: |
brew install cmake ninja
brew install cmake
sudo gem install cocoapods
- brew-install-cmake
- run:
name: Package the framework
command: |
Expand Down Expand Up @@ -265,7 +286,7 @@ jobs:

macos:
macos:
xcode: 13.4.1
xcode: 15.3
steps:
- checkout:
path: hermes
Expand Down Expand Up @@ -303,14 +324,11 @@ jobs:

test-macos:
macos:
xcode: 13.4.1
xcode: 15.3
steps:
- checkout:
path: hermes
- run:
name: Install dependencies
command: |
brew install cmake
- brew-install-cmake
- run:
name: Run MacOS regression tests in debug mode
command: |
Expand Down Expand Up @@ -680,7 +698,7 @@ jobs:

test-macos-test262:
macos:
xcode: 13.4.1
xcode: 15.3
steps:
- checkout:
path: hermes
Expand Down
12 changes: 8 additions & 4 deletions API/hermes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ if(APPLE AND HERMES_BUILD_APPLE_FRAMEWORK)
add_custom_command(TARGET libhermes POST_BUILD
COMMAND /usr/libexec/PlistBuddy -c "Add :MinimumOSVersion string ${CMAKE_OSX_DEPLOYMENT_TARGET}" $<TARGET_FILE_DIR:libhermes>/Info.plist
)
elseif(HERMES_APPLE_TARGET_PLATFORM MATCHES "xr")
add_custom_command(TARGET libhermes POST_BUILD
COMMAND /usr/libexec/PlistBuddy -c "Add :MinimumOSVersion string ${CMAKE_OSX_DEPLOYMENT_TARGET}" $<TARGET_FILE_DIR:libhermes>/Info.plist
)
elseif(HERMES_APPLE_TARGET_PLATFORM MATCHES "catalyst")
add_custom_command(TARGET libhermes POST_BUILD
COMMAND /usr/libexec/PlistBuddy -c "Add :LSMinimumSystemVersion string ${CMAKE_OSX_DEPLOYMENT_TARGET}" $<TARGET_FILE_DIR:libhermes>/Resources/Info.plist
Expand All @@ -156,6 +152,14 @@ if(APPLE AND HERMES_BUILD_APPLE_FRAMEWORK)
add_custom_command(TARGET libhermes POST_BUILD
COMMAND /usr/libexec/PlistBuddy -c "Add :LSMinimumSystemVersion string ${CMAKE_OSX_DEPLOYMENT_TARGET}" $<TARGET_FILE_DIR:libhermes>/Resources/Info.plist
)
elseif(HERMES_APPLE_TARGET_PLATFORM MATCHES "xr")
if(CMAKE_VERSION VERSION_LESS 3.28.4)
message("VisionOS Simulator requires CMake version >= 3.28.4")
endif()

add_custom_command(TARGET libhermes POST_BUILD
COMMAND /usr/libexec/PlistBuddy -c "Add :MinimumOSVersion string ${CMAKE_OSX_DEPLOYMENT_TARGET}" $<TARGET_FILE_DIR:libhermes>/Info.plist
)
endif()
endif()

Expand Down
21 changes: 0 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,6 @@ if(HERMES_APPLE_TARGET_PLATFORM MATCHES "catalyst")
set(THREADS_PREFER_PTHREAD_FLAG ON)
endif()


# Workaround for a bug in CMake which passes wrong flag
macro(__xros_unset_target lang)
unset(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG)
endmacro()

if(HERMES_APPLE_TARGET_PLATFORM MATCHES "xr")
__xros_unset_target(ASM)
__xros_unset_target(C)
__xros_unset_target(CXX)
__xros_unset_target(OBJC)
__xros_unset_target(OBJCXX)
endif()

if(HERMES_APPLE_TARGET_PLATFORM MATCHES "xrsimulator")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-target arm64-apple-xros1.0-simulator")
endif()
if(HERMES_APPLE_TARGET_PLATFORM MATCHES "xros")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-target arm64-apple-xros1.0")
endif()

# This must be consistent with the release_version in:
# - android/build.gradle
# - npm/package.json
Expand Down
3 changes: 2 additions & 1 deletion hermes-engine.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ Pod::Spec.new do |spec|
# The podspec would be serialized to JSON and people will download prebuilt binaries instead of the source.
# TODO(use the hash field as a validation mechanism when the process is stable)
spec.source = ENV['hermes-artifact-url'] ? { http: ENV['hermes-artifact-url'] } : { git: "https://github.com/facebook/hermes.git", tag: "v#{spec.version}" }
spec.platforms = { :osx => "10.13", :ios => "11.0", :visionos => "1.0" }
spec.platforms = { :osx => "10.13", :ios => "12.0", :visionos => "1.0" }

spec.preserve_paths = ["destroot/bin/*"].concat(HermesHelper::BUILD_TYPE == :debug ? ["**/*.{h,c,cpp}"] : [])
spec.source_files = "destroot/include/**/*.h"
spec.header_mappings_dir = "destroot/include"

spec.ios.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework"
spec.visionos.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework"
spec.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework"

spec.xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", "CLANG_CXX_LIBRARY" => "compiler-default", "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" }
Expand Down
1 change: 1 addition & 0 deletions lib/Platform/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <android/log.h>
#elif defined(__APPLE__)
#include <os/log.h>
#include <stdio.h>
#else
#include <cstdio>
#endif
Expand Down

0 comments on commit 71607be

Please sign in to comment.