Skip to content

Commit 924fb3d

Browse files
okwasniewskifacebook-github-bot
authored andcommitted
feat: build visionos hermes binary on the CI (#44691)
Summary: As discussed with cipolleschi offline, this PR adds visionOS to the prebuilt Hermes binary for the CI. ## Changelog: [IOS] [ADDED] - Prebuilt version of Hermes for visionOS Pull Request resolved: #44691 Test Plan: Check if CI builds xcframework for visionOS. Reviewed By: cortinico Differential Revision: D58189271 Pulled By: cipolleschi fbshipit-source-id: dc76746b2c1e22670bef4c21411a598e43dad577
1 parent 38bae4b commit 924fb3d

File tree

10 files changed

+76
-23
lines changed

10 files changed

+76
-23
lines changed

.circleci/configurations/jobs.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ jobs:
762762
default: "iphoneos"
763763
description: The Hermes Slice that this job has to build
764764
type: enum
765-
enum: ["macosx", "iphoneos", "iphonesimulator", "catalyst"]
765+
enum: ["macosx", "iphoneos", "iphonesimulator", "catalyst", "xros", "xrsimulator"]
766766
executor: reactnativeios
767767
environment:
768768
- HERMES_WS_DIR: *hermes_workspace_root
@@ -867,6 +867,10 @@ jobs:
867867
key: << parameters.slice_base_cache_key >>-iphonesimulator-<< parameters.flavor >>
868868
- restore_cache:
869869
key: << parameters.slice_base_cache_key >>-catalyst-<< parameters.flavor >>
870+
- restore_cache:
871+
key: << parameters.slice_base_cache_key >>-xros-<< parameters.flavor >>
872+
- restore_cache:
873+
key: << parameters.slice_base_cache_key >>-xrsimulator-<< parameters.flavor >>
870874
- run:
871875
name: "Move back build folders"
872876
command: |
@@ -875,6 +879,8 @@ jobs:
875879
mv build_iphoneos_<< parameters.flavor >> build_iphoneos
876880
mv build_iphonesimulator_<< parameters.flavor >> build_iphonesimulator
877881
mv build_catalyst_<< parameters.flavor >> build_catalyst
882+
mv build_xros_<< parameters.flavor >> build_xros
883+
mv build_xrsimulator_<< parameters.flavor >> build_xrsimulator
878884
- run:
879885
name: "Prepare destroot folder"
880886
command: |
@@ -925,6 +931,8 @@ jobs:
925931
mkdir -p "$WORKING_DIR/catalyst"
926932
mkdir -p "$WORKING_DIR/iphoneos"
927933
mkdir -p "$WORKING_DIR/iphonesimulator"
934+
mkdir -p "$WORKING_DIR/xros"
935+
mkdir -p "$WORKING_DIR/xrsimulator"
928936
929937
cd ./packages/react-native/sdks/hermes || exit 1
930938
@@ -933,6 +941,8 @@ jobs:
933941
cp -r build_catalyst/$DSYM_FILE_PATH "$WORKING_DIR/catalyst/"
934942
cp -r build_iphoneos/$DSYM_FILE_PATH "$WORKING_DIR/iphoneos/"
935943
cp -r build_iphonesimulator/$DSYM_FILE_PATH "$WORKING_DIR/iphonesimulator/"
944+
cp -r build_xrsimulator/$DSYM_FILE_PATH "$WORKING_DIR/xrsimulator/"
945+
cp -r build_xros/$DSYM_FILE_PATH "$WORKING_DIR/xros/"
936946
937947
DEST_DIR="/tmp/hermes/dSYM/$FLAVOR"
938948
tar -C "$WORKING_DIR" -czvf "hermes.framework.dSYM" .

.circleci/configurations/test_workflows/testAll.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
matrix:
2626
parameters:
2727
flavor: ["Debug", "Release"]
28-
slice: ["macosx", "iphoneos", "iphonesimulator", "catalyst"]
28+
slice: ["macosx", "iphoneos", "iphonesimulator", "catalyst", "xros", "xrsimulator"]
2929
- build_hermes_macos:
3030
requires:
3131
- build_apple_slices_hermes

.circleci/configurations/test_workflows/testAndroid.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
matrix:
2626
parameters:
2727
flavor: ["Debug", "Release"]
28-
slice: ["macosx", "iphoneos", "iphonesimulator", "catalyst"]
28+
slice: ["macosx", "iphoneos", "iphonesimulator", "catalyst", "xros", "xrsimulator"]
2929
- build_hermes_macos:
3030
requires:
3131
- build_apple_slices_hermes

.circleci/configurations/test_workflows/testIOS.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
matrix:
2626
parameters:
2727
flavor: ["Debug", "Release"]
28-
slice: ["macosx", "iphoneos", "iphonesimulator", "catalyst"]
28+
slice: ["macosx", "iphoneos", "iphonesimulator", "catalyst", "xros", "xrsimulator"]
2929
- build_hermes_macos:
3030
requires:
3131
- build_apple_slices_hermes

.github/workflows/test-all.yml

+22-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ jobs:
112112
. ./utils/build-apple-framework.sh
113113
build_host_hermesc_if_needed
114114
build_apple_slices_hermes:
115-
runs-on: macos-13
115+
runs-on: macos-14
116116
needs: [build_hermesc_apple, prepare_hermes_workspace]
117117
env:
118118
HERMES_WS_DIR: /tmp/hermes
@@ -123,10 +123,12 @@ jobs:
123123
fail-fast: false
124124
matrix:
125125
flavor: [Debug, Release]
126-
slice: [macosx, iphoneos, iphonesimulator, catalyst]
126+
slice: [macosx, iphoneos, iphonesimulator, catalyst, xros, xrsimulator]
127127
steps:
128128
- name: Checkout
129129
uses: actions/checkout@v4.1.1
130+
- name: Setup xcode
131+
uses: ./.github/actions/setup-xcode
130132
- name: Cache setup
131133
id: cache_setup
132134
uses: ./.github/actions/cache_setup
@@ -267,6 +269,18 @@ jobs:
267269
with:
268270
path: ./packages/react-native/sdks/hermes/build_catalyst_${{ matrix.flavor }}
269271
key: v4-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-catalyst-${{ matrix.flavor }}
272+
- name: Slice cache xros
273+
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != true }}
274+
uses: actions/cache@v4.0.0
275+
with:
276+
path: ./packages/react-native/sdks/hermes/build_xros_${{ matrix.flavor }}
277+
key: v4-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-xros-${{ matrix.flavor }}
278+
- name: Slice cache xrsimulator
279+
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != true }}
280+
uses: actions/cache@v4.0.0
281+
with:
282+
path: ./packages/react-native/sdks/hermes/build_xrsimulator_${{ matrix.flavor }}
283+
key: v4-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-xrsimulator-${{ matrix.flavor }}
270284
- name: Move back build folders
271285
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != true }}
272286
run: |
@@ -276,6 +290,8 @@ jobs:
276290
mv build_iphoneos_${{ matrix.flavor }} build_iphoneos
277291
mv build_iphonesimulator_${{ matrix.flavor }} build_iphonesimulator
278292
mv build_catalyst_${{ matrix.flavor }} build_catalyst
293+
mv build_xros_${{ matrix.flavor }} build_xros
294+
mv build_xrsimulator_${{ matrix.flavor }} build_xrsimulator
279295
- name: Prepare destroot folder
280296
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != true }}
281297
run: |
@@ -333,6 +349,8 @@ jobs:
333349
mkdir -p "$WORKING_DIR/catalyst"
334350
mkdir -p "$WORKING_DIR/iphoneos"
335351
mkdir -p "$WORKING_DIR/iphonesimulator"
352+
mkdir -p "$WORKING_DIR/xros"
353+
mkdir -p "$WORKING_DIR/xrsimulator"
336354
337355
cd ./packages/react-native/sdks/hermes || exit 1
338356
@@ -341,6 +359,8 @@ jobs:
341359
cp -r build_catalyst/$DSYM_FILE_PATH "$WORKING_DIR/catalyst/"
342360
cp -r build_iphoneos/$DSYM_FILE_PATH "$WORKING_DIR/iphoneos/"
343361
cp -r build_iphonesimulator/$DSYM_FILE_PATH "$WORKING_DIR/iphonesimulator/"
362+
cp -r build_xros/$DSYM_FILE_PATH "$WORKING_DIR/xros/"
363+
cp -r build_xrsimulator/$DSYM_FILE_PATH "$WORKING_DIR/xrsimulator/"
344364
345365
DEST_DIR="/tmp/hermes/dSYM/$FLAVOR"
346366
tar -C "$WORKING_DIR" -czvf "hermes.framework.dSYM" .

packages/react-native/sdks/hermes-engine/hermes-engine.podspec

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Pod::Spec.new do |spec|
2424
spec.license = package['license']
2525
spec.author = "Facebook"
2626
spec.source = source
27-
spec.platforms = { :osx => "10.13", :ios => "13.4" }
27+
spec.platforms = { :osx => "10.13", :ios => "13.4", :visionos => "1.0" }
2828

2929
spec.preserve_paths = '**/*.*'
3030
spec.source_files = ''
@@ -44,6 +44,7 @@ Pod::Spec.new do |spec|
4444
ss.source_files = "destroot/include/hermes/**/*.h"
4545
ss.header_mappings_dir = "destroot/include"
4646
ss.ios.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework"
47+
ss.visionos.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework"
4748
ss.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework"
4849
end
4950

packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh

+11-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ REACT_NATIVE_PATH=${REACT_NATIVE_PATH:-$CURR_SCRIPT_DIR/../../..}
1717

1818
NUM_CORES=$(sysctl -n hw.ncpu)
1919

20+
PLATFORMS=("macosx" "iphoneos" "iphonesimulator" "catalyst" "xros" "xrsimulator")
21+
2022
if [[ -z "$JSI_PATH" ]]; then
2123
JSI_PATH="$REACT_NATIVE_PATH/ReactCommon/jsi"
2224
fi
@@ -37,6 +39,10 @@ function get_ios_deployment_target {
3739
use_env_var_or_ruby_prop "${IOS_DEPLOYMENT_TARGET}" "deployment_target('ios')"
3840
}
3941

42+
function get_visionos_deployment_target {
43+
use_env_var_or_ruby_prop "${XROS_DEPLOYMENT_TARGET}" "deployment_target('visionos')"
44+
}
45+
4046
function get_mac_deployment_target {
4147
use_env_var_or_ruby_prop "${MAC_DEPLOYMENT_TARGET}" "deployment_target('osx')"
4248
}
@@ -150,12 +156,12 @@ function build_apple_framework {
150156
}
151157

152158
function prepare_dest_root_for_ci {
153-
mkdir -p "destroot/Library/Frameworks/macosx" "destroot/bin" "destroot/Library/Frameworks/iphoneos" "destroot/Library/Frameworks/iphonesimulator" "destroot/Library/Frameworks/catalyst"
159+
mkdir -p "destroot/bin"
160+
for platform in "${PLATFORMS[@]}"; do
161+
mkdir -p "destroot/Library/Frameworks/$platform"
162+
cp -R "./build_$platform/API/hermes/hermes.framework"* "destroot/Library/Frameworks/$platform"
163+
done
154164

155-
cp -R "./build_macosx/API/hermes/hermes.framework"* "destroot/Library/Frameworks/macosx"
156-
cp -R "./build_iphoneos/API/hermes/hermes.framework"* "destroot/Library/Frameworks/iphoneos"
157-
cp -R "./build_iphonesimulator/API/hermes/hermes.framework"* "destroot/Library/Frameworks/iphonesimulator"
158-
cp -R "./build_catalyst/API/hermes/hermes.framework"* "destroot/Library/Frameworks/catalyst"
159165
cp "./build_macosx/bin/"* "destroot/bin"
160166

161167
# Copy over Hermes and JSI API headers.

packages/react-native/sdks/hermes-engine/utils/build-hermes-xcode.sh

+11-5
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,30 @@ release_version="$1"; shift
1010
hermesc_path="$1"; shift
1111
jsi_path="$1"; shift
1212

13-
# Based on platform name returns the framework copy destination. Used later by `vendored_frameworks` in Podspec.
13+
# Based on platform name returns the framework copy destination. Used later by `vendored_frameworks` in Podspec.
1414
# Fallbacks to "ios" if platform is not recognized.
1515
function get_platform_copy_destination {
1616
if [[ $1 == "macosx" ]]; then
1717
echo "macosx"
1818
return
19+
elif [[ $1 == "xros" || $1 == "xrsimulator" ]]; then
20+
echo "xros"
21+
return
1922
fi
20-
23+
2124
echo "ios"
2225
}
2326

2427
function get_deployment_target {
2528
if [[ $1 == "macosx" ]]; then
26-
echo ${MACOSX_DEPLOYMENT_TARGET}
29+
echo "${MACOSX_DEPLOYMENT_TARGET}"
30+
return
31+
elif [[ $1 == "xrsimulator" || $1 == "xros" ]]; then
32+
echo "${XROS_DEPLOYMENT_TARGET}"
2733
return
2834
fi
29-
30-
echo ${IPHONEOS_DEPLOYMENT_TARGET}
35+
36+
echo "${IPHONEOS_DEPLOYMENT_TARGET}"
3137
}
3238

3339
enable_debugger="false"

packages/react-native/sdks/hermes-engine/utils/build-ios-framework.sh

+15-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ fi
1010
set -e
1111

1212
# Given a specific target, retrieve the right architecture for it
13-
# $1 the target you want to build. Allowed values: iphoneos, iphonesimulator, catalyst
13+
# $1 the target you want to build. Allowed values: iphoneos, iphonesimulator, catalyst, xros, xrsimulator
1414
function get_architecture {
15-
if [[ $1 == "iphoneos" ]]; then
15+
if [[ $1 == "iphoneos" || $1 == "xros" || $1 == "xrsimulator" ]]; then
1616
echo "arm64"
1717
elif [[ $1 == "iphonesimulator" ]]; then
1818
echo "x86_64;arm64"
@@ -24,15 +24,23 @@ function get_architecture {
2424
fi
2525
}
2626

27+
function get_deployment_target {
28+
if [[ $1 == "xros" || $1 == "xrsimulator" ]]; then
29+
"$(get_visionos_deployment_target)"
30+
else
31+
"$(get_ios_deployment_target)"
32+
fi
33+
}
34+
2735
# build a single framework
2836
# $1 is the target to build
2937
function build_framework {
3038
if [ ! -d destroot/Library/Frameworks/universal/hermes.xcframework ]; then
31-
ios_deployment_target=$(get_ios_deployment_target)
39+
deployment_target=$(get_deployment_target "$1")
3240

3341
architecture=$(get_architecture "$1")
3442

35-
build_apple_framework "$1" "$architecture" "$ios_deployment_target"
43+
build_apple_framework "$1" "$architecture" "$deployment_target"
3644
else
3745
echo "Skipping; Clean \"destroot\" to rebuild".
3846
fi
@@ -41,7 +49,7 @@ function build_framework {
4149
# group the frameworks together to create a universal framework
4250
function build_universal_framework {
4351
if [ ! -d destroot/Library/Frameworks/universal/hermes.xcframework ]; then
44-
create_universal_framework "iphoneos" "iphonesimulator" "catalyst"
52+
create_universal_framework "iphoneos" "iphonesimulator" "catalyst" "xros" "xrsimulator"
4553
else
4654
echo "Skipping; Clean \"destroot\" to rebuild".
4755
fi
@@ -56,6 +64,8 @@ function create_framework {
5664
build_framework "iphoneos"
5765
build_framework "iphonesimulator"
5866
build_framework "catalyst"
67+
build_framework "xros"
68+
build_framework "xrsimulator"
5969

6070
build_universal_framework
6171
else

packages/react-native/sdks/hermes-engine/utils/create-dummy-hermes-xcframework.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pushd destroot/Library/Frameworks > /dev/null || exit 1
1919

2020
echo '' > dummy.c
2121

22-
platforms=( "macosx" "ios" ) # Add other platforms here if needed
22+
platforms=( "macosx" "ios" "xros" ) # Add other platforms here if needed
2323

2424
for platform in "${platforms[@]}"
2525
do

0 commit comments

Comments
 (0)