Skip to content

Commit f881974

Browse files
coadofacebook-github-bot
authored andcommitted
Move React Native Hermes build to static_h (#1749)
Summary: This diff moves new builds from main to static_h branch and adjusts/fixes failing jobs which includes: - Fix tvOS and visionOS apple slices build by including missing `stdio.h` in `Logging.cpp`. - Fix Android build by linking `compileJS` with `hermesHBCBackend`. The windows build job is failing because Static Hermes does not currently support builds with MSVC. Pull Request resolved: #1749 Test Plan: Signals Reviewed By: cortinico Differential Revision: D79996969 Pulled By: coado fbshipit-source-id: 4a6c0e7cef77e6bed48e97779aa86c83de9aa1da
1 parent 0d299b3 commit f881974

36 files changed

+1767
-322
lines changed

.github/actions/setup-node/action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Setup node.js
2+
description: 'Set up your GitHub Actions workflow with a specific version of node.js'
3+
inputs:
4+
node-version:
5+
description: 'The node.js version to use'
6+
required: false
7+
default: '22.14.0'
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Setup node.js
12+
uses: actions/setup-node@v4
13+
with:
14+
node-version: ${{ inputs.node-version }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Setup xcode
2+
description: 'Set up your GitHub Actions workflow with a specific version of xcode'
3+
inputs:
4+
xcode-version:
5+
description: 'The xcode version to use'
6+
required: false
7+
default: '16.2.0'
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Setup xcode
12+
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd
13+
with:
14+
xcode-version: ${{ inputs.xcode-version }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: yarn-install
2+
runs:
3+
using: composite
4+
steps:
5+
- name: Setup node.js
6+
uses: ./.github/actions/setup-node
7+
- name: Install dependencies
8+
shell: bash
9+
run: |
10+
cd utils/scripts/hermes
11+
MAX_ATTEMPTS=2
12+
ATTEMPT=0
13+
WAIT_TIME=20
14+
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
15+
yarn install --non-interactive --frozen-lockfile && break
16+
echo "yarn install failed. Retrying in $WAIT_TIME seconds..."
17+
sleep $WAIT_TIME
18+
ATTEMPT=$((ATTEMPT + 1))
19+
done
20+
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
21+
echo "All attempts to invoke yarn install failed - Aborting the workflow"
22+
exit 1
23+
fi

.github/workflows/build-android.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: build-android
2+
3+
on: workflow_call
4+
5+
jobs:
6+
build-android:
7+
runs-on: 8-core-ubuntu
8+
env:
9+
HERMES_WS_DIR: /home/runner/work/hermes/hermes
10+
container:
11+
image: reactnativecommunity/react-native-android:latest
12+
env:
13+
TERM: "dumb"
14+
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
15+
ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}
16+
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }}
17+
ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }}
18+
ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
- name: Build Hermes Compiler
23+
run: |-
24+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
25+
# Build the Hermes compiler so that the cross compiler build can
26+
# access it to build the VM
27+
cmake --build ./build --target hermesc -j 4
28+
- name: Build android
29+
shell: bash
30+
run: |
31+
cd android
32+
TASKS="publishAllToMavenTempLocal build"
33+
./gradlew $TASKS
34+
- name: Upload Maven Artifacts
35+
uses: actions/[email protected]
36+
with:
37+
name: maven-local
38+
path: /tmp/maven-local
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: build-apple-slices-hermes
2+
3+
on: workflow_call
4+
5+
jobs:
6+
build_apple_slices_hermes:
7+
runs-on: macos-14
8+
env:
9+
IOS_DEPLOYMENT_TARGET: "15.1"
10+
XROS_DEPLOYMENT_TARGET: "1.0"
11+
MAC_DEPLOYMENT_TARGET: "10.15"
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
flavor: [Debug, Release]
16+
slice:
17+
[
18+
macosx,
19+
iphoneos,
20+
iphonesimulator,
21+
appletvos,
22+
appletvsimulator,
23+
catalyst,
24+
xros,
25+
xrsimulator,
26+
]
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
- name: Setup xcode
31+
uses: ./.github/actions/setup-xcode
32+
- name: Restore HermesC Artifact
33+
uses: actions/download-artifact@v4
34+
with:
35+
name: hermesc-apple
36+
path: ./build_host_hermesc
37+
- name: Build the Hermes ${{ matrix.slice }} frameworks
38+
shell: bash
39+
run: |
40+
SLICE=${{ matrix.slice }}
41+
FLAVOR=${{ matrix.flavor }}
42+
FINAL_PATH=build_"$SLICE"_"$FLAVOR"
43+
echo "Final path for this slice is: $FINAL_PATH"
44+
45+
# HermesC is used to build hermes, so it has to be executable
46+
chmod +x ./build_host_hermesc/bin/hermesc
47+
48+
if [[ "$SLICE" == "macosx" ]]; then
49+
echo "[HERMES] Building Hermes for MacOS"
50+
51+
chmod +x ./utils/build-mac-framework-rn.sh
52+
BUILD_TYPE="${{ matrix.flavor }}" ./utils/build-mac-framework-rn.sh
53+
else
54+
echo "[HERMES] Building Hermes for iOS: $SLICE"
55+
56+
chmod +x ./utils/build-ios-framework-rn.sh
57+
BUILD_TYPE="${{ matrix.flavor }}" ./utils/build-ios-framework-rn.sh "$SLICE"
58+
fi
59+
60+
echo "Moving from build_$SLICE to $FINAL_PATH"
61+
mv build_"$SLICE" "$FINAL_PATH"
62+
63+
# check whether everything is there
64+
if [[ -d "$FINAL_PATH/lib/hermesvm.framework" ]]; then
65+
echo "Successfully built hermesvm.framework for $SLICE in $FLAVOR"
66+
else
67+
echo "Failed to built hermesvm.framework for $SLICE in $FLAVOR"
68+
exit 1
69+
fi
70+
71+
if [[ -d "$FINAL_PATH/lib/hermesvm.framework.dSYM" ]]; then
72+
echo "Successfully built hermesvm.framework.dSYM for $SLICE in $FLAVOR"
73+
else
74+
echo "Failed to built hermesvm.framework.dSYM for $SLICE in $FLAVOR"
75+
echo "Please try again"
76+
exit 1
77+
fi
78+
- name: Compress slices to preserve Symlinks
79+
shell: bash
80+
run: |
81+
tar -czv -f build_${{ matrix.slice }}_${{ matrix.flavor }}.tar.gz build_${{ matrix.slice }}_${{ matrix.flavor }}
82+
- name: Upload Artifact for Slice (${{ matrix.slice }}, ${{ matrix.flavor }})
83+
uses: actions/[email protected]
84+
with:
85+
name: slice-${{ matrix.slice }}-${{ matrix.flavor }}
86+
path: ./build_${{ matrix.slice }}_${{ matrix.flavor }}.tar.gz
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: build-hermes-macos
2+
3+
on: workflow_call
4+
5+
jobs:
6+
build-hermes-macos:
7+
runs-on: macos-14
8+
continue-on-error: true
9+
env:
10+
HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
flavor: [Debug, Release]
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: Setup xcode
19+
uses: ./.github/actions/setup-xcode
20+
- name: Setup node.js
21+
uses: ./.github/actions/setup-node
22+
- name: Yarn Install Dependencies
23+
uses: ./.github/actions/yarn-install
24+
- name: Download slice artifacts
25+
uses: actions/download-artifact@v4
26+
with:
27+
pattern: slice-*-${{ matrix.flavor }}
28+
path: .
29+
merge-multiple: true
30+
- name: Unzip slices
31+
shell: bash
32+
run: |
33+
ls -l .
34+
tar -xzv -f build_catalyst_${{ matrix.flavor }}.tar.gz
35+
tar -xzv -f build_iphoneos_${{ matrix.flavor }}.tar.gz
36+
tar -xzv -f build_iphonesimulator_${{ matrix.flavor }}.tar.gz
37+
tar -xzv -f build_appletvos_${{ matrix.flavor }}.tar.gz
38+
tar -xzv -f build_appletvsimulator_${{ matrix.flavor }}.tar.gz
39+
tar -xzv -f build_macosx_${{ matrix.flavor }}.tar.gz
40+
tar -xzv -f build_xros_${{ matrix.flavor }}.tar.gz
41+
tar -xzv -f build_xrsimulator_${{ matrix.flavor }}.tar.gz
42+
- name: Move back build folders
43+
shell: bash
44+
run: |
45+
ls -l build_*
46+
mv build_catalyst_${{ matrix.flavor }} build_catalyst
47+
mv build_iphoneos_${{ matrix.flavor }} build_iphoneos
48+
mv build_iphonesimulator_${{ matrix.flavor }} build_iphonesimulator
49+
mv build_appletvos_${{ matrix.flavor }} build_appletvos
50+
mv build_appletvsimulator_${{ matrix.flavor }} build_appletvsimulator
51+
mv build_macosx_${{ matrix.flavor }} build_macosx
52+
mv build_xros_${{ matrix.flavor }} build_xros
53+
mv build_xrsimulator_${{ matrix.flavor }} build_xrsimulator
54+
- name: Prepare destroot folder
55+
shell: bash
56+
run: |
57+
chmod +x ./utils/build-apple-framework-rn.sh
58+
source ./utils/build-apple-framework-rn.sh
59+
prepare_dest_root_for_ci
60+
- name: Create fat framework for iOS
61+
shell: bash
62+
run: |
63+
echo "[HERMES] Creating the universal framework"
64+
chmod +x ./utils/build-ios-framework-rn.sh
65+
./utils/build-ios-framework-rn.sh build_framework
66+
67+
chmod +x ./destroot/bin/hermesc
68+
- name: Package the Hermes Apple frameworks
69+
shell: bash
70+
run: |
71+
BUILD_TYPE="${{ matrix.flavor }}"
72+
echo "Packaging Hermes Apple frameworks for $BUILD_TYPE build type"
73+
74+
TARBALL_OUTPUT_DIR=$(mktemp -d /tmp/hermes-tarball-output-XXXXXXXX)
75+
76+
echo "Packaging Hermes Apple frameworks for $BUILD_TYPE build type"
77+
78+
TARBALL_OUTPUT_PATH=$(node ./utils/scripts/hermes/create-tarball.js \
79+
--inputDir . \
80+
--buildType "$BUILD_TYPE" \
81+
--outputDir $TARBALL_OUTPUT_DIR)
82+
83+
echo "Hermes tarball saved to $TARBALL_OUTPUT_PATH"
84+
85+
mkdir -p $HERMES_TARBALL_ARTIFACTS_DIR
86+
cp $TARBALL_OUTPUT_PATH $HERMES_TARBALL_ARTIFACTS_DIR/.
87+
88+
mkdir -p /tmp/hermes/osx-bin/${{ matrix.flavor }}
89+
cp ./build_macosx/bin/* /tmp/hermes/osx-bin/${{ matrix.flavor }}
90+
ls -lR /tmp/hermes/osx-bin/
91+
- name: Create dSYM archive
92+
shell: bash
93+
run: |
94+
FLAVOR=${{ matrix.flavor }}
95+
WORKING_DIR="/tmp/hermes_tmp/dSYM/$FLAVOR"
96+
97+
mkdir -p "$WORKING_DIR/macosx"
98+
mkdir -p "$WORKING_DIR/catalyst"
99+
mkdir -p "$WORKING_DIR/iphoneos"
100+
mkdir -p "$WORKING_DIR/iphonesimulator"
101+
mkdir -p "$WORKING_DIR/appletvos"
102+
mkdir -p "$WORKING_DIR/appletvsimulator"
103+
mkdir -p "$WORKING_DIR/xros"
104+
mkdir -p "$WORKING_DIR/xrsimulator"
105+
106+
DSYM_FILE_PATH=lib/hermesvm.framework.dSYM
107+
cp -r build_macosx/$DSYM_FILE_PATH "$WORKING_DIR/macosx/"
108+
cp -r build_catalyst/$DSYM_FILE_PATH "$WORKING_DIR/catalyst/"
109+
cp -r build_iphoneos/$DSYM_FILE_PATH "$WORKING_DIR/iphoneos/"
110+
cp -r build_iphonesimulator/$DSYM_FILE_PATH "$WORKING_DIR/iphonesimulator/"
111+
cp -r build_appletvos/$DSYM_FILE_PATH "$WORKING_DIR/appletvos/"
112+
cp -r build_appletvsimulator/$DSYM_FILE_PATH "$WORKING_DIR/appletvsimulator/"
113+
cp -r build_xros/$DSYM_FILE_PATH "$WORKING_DIR/xros/"
114+
cp -r build_xrsimulator/$DSYM_FILE_PATH "$WORKING_DIR/xrsimulator/"
115+
116+
DEST_DIR="/tmp/hermes/dSYM/$FLAVOR"
117+
tar -C "$WORKING_DIR" -czvf "hermesvm.framework.dSYM" .
118+
119+
mkdir -p "$DEST_DIR"
120+
mv "hermesvm.framework.dSYM" "$DEST_DIR"
121+
- name: Upload hermes dSYM artifacts
122+
uses: actions/[email protected]
123+
with:
124+
name: hermes-dSYM-${{ matrix.flavor }}
125+
path: /tmp/hermes/dSYM/${{ matrix.flavor }}
126+
- name: Upload hermes Runtime artifacts
127+
uses: actions/[email protected]
128+
with:
129+
name: hermes-darwin-bin-${{ matrix.flavor }}
130+
path: /tmp/hermes/hermes-runtime-darwin/hermes-ios-${{ matrix.flavor }}.tar.gz
131+
- name: Upload hermes osx artifacts
132+
uses: actions/[email protected]
133+
with:
134+
name: hermes-osx-bin-${{ matrix.flavor }}
135+
path: /tmp/hermes/osx-bin/${{ matrix.flavor }}
136+
- name: Upload Hermes Artifacts
137+
uses: actions/cache/save@v4
138+
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} # To avoid that the cache explode.
139+
with:
140+
key: v4-hermes-artifacts-${{ matrix.flavor }}-${{ matrix.hermes-version }}-${{ matrix.react-native-version }}-${{ hashFiles('./packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}
141+
path: |
142+
/tmp/hermes/osx-bin/${{ matrix.flavor }}
143+
/tmp/hermes/dSYM/${{ matrix.flavor }}
144+
/tmp/hermes/hermes-runtime-darwin/hermes-ios-${{ matrix.flavor }}.tar.gz
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: build-hermesc-apple
2+
3+
on: workflow_call
4+
5+
jobs:
6+
build-hermesc-apple:
7+
runs-on: macos-14
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v4
11+
- name: Setup xcode
12+
uses: ./.github/actions/setup-xcode
13+
- name: Build HermesC Apple
14+
shell: bash
15+
run: |
16+
source ./utils/build-apple-framework-rn.sh
17+
build_host_hermesc_if_needed
18+
- name: Upload HermesC Artifact
19+
uses: actions/[email protected]
20+
with:
21+
name: hermesc-apple
22+
path: ./build_host_hermesc
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: build-hermesc-linux
2+
3+
on: workflow_call
4+
5+
jobs:
6+
build-hermesc-linux:
7+
runs-on: ubuntu-latest
8+
env:
9+
HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
- name: Install dependencies
14+
shell: bash
15+
run: |
16+
sudo apt update
17+
sudo apt install -y git openssh-client build-essential \
18+
libreadline-dev libicu-dev jq zip python3
19+
20+
sudo mkdir -p /usr/local/cmake
21+
sudo wget -qO- https://github.com/Kitware/CMake/releases/download/v3.31.6/cmake-3.31.6-linux-x86_64.tar.gz \
22+
| sudo tar --strip-components=1 -xz -C /usr/local/cmake
23+
sudo cp /usr/local/cmake/bin/* /usr/local/bin/
24+
export PATH=/usr/local/bin:$PATH
25+
cmake --version
26+
27+
- name: Set up workspace
28+
shell: bash
29+
run: |
30+
mkdir -p /tmp/hermes/linux64-bin
31+
- name: Build HermesC for Linux
32+
shell: bash
33+
run: |
34+
cmake -S . -B build -DHERMES_STATIC_LINK=ON -DCMAKE_BUILD_TYPE=Release -DHERMES_ENABLE_TEST_SUITE=OFF \
35+
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DCMAKE_CXX_FLAGS=-s -DCMAKE_C_FLAGS=-s \
36+
-DCMAKE_EXE_LINKER_FLAGS="-Wl,--whole-archive -lpthread -Wl,--no-whole-archive"
37+
cmake --build build --target hermesc -j 4
38+
cp build/bin/hermesc /tmp/hermes/linux64-bin/.
39+
- name: Upload linux artifacts
40+
uses: actions/[email protected]
41+
with:
42+
name: hermes-linux-bin
43+
path: /tmp/hermes/linux64-bin

0 commit comments

Comments
 (0)