Skip to content

Commit ff558b7

Browse files
lavenzgfacebook-github-bot
authored andcommitted
Fix Apple build script
Summary: 1. Fix errors in build-apple-framework.sh due to changes in SH build. 2. Update build-ios-framework.sh to take an optional argument to build for a single platform instead of all supported ones. 3. Rename hermes.framework to hermesvm.framework in rest relevant files. Reviewed By: tsaichien Differential Revision: D83033266 fbshipit-source-id: faed578e5c5e41cb2d00cc3a57f0dc4ee2ddd855
1 parent 7f488cf commit ff558b7

File tree

4 files changed

+42
-19
lines changed

4 files changed

+42
-19
lines changed

hermes-engine.podspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ Pod::Spec.new do |spec|
3030
spec.source_files = "destroot/include/**/*.h"
3131
spec.header_mappings_dir = "destroot/include"
3232

33-
spec.ios.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework"
34-
spec.visionos.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework"
35-
spec.tvos.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework"
36-
spec.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework"
33+
spec.ios.vendored_frameworks = "destroot/Library/Frameworks/universal/hermesvm.xcframework"
34+
spec.visionos.vendored_frameworks = "destroot/Library/Frameworks/universal/hermesvm.xcframework"
35+
spec.tvos.vendored_frameworks = "destroot/Library/Frameworks/universal/hermesvm.xcframework"
36+
spec.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermesvm.framework"
3737

3838
spec.xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", "CLANG_CXX_LIBRARY" => "compiler-default", "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" }
3939

utils/build-apple-framework.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ function get_mac_deployment_target {
4747

4848
# Build host hermes compiler for internal bytecode
4949
function build_host_hermesc {
50-
cmake -S . -B build_host_hermesc
51-
cmake --build ./build_host_hermesc --target hermesc
50+
cmake -S . -B build_host_hermesc -DCMAKE_BUILD_TYPE="$BUILD_TYPE"
51+
cmake --build ./build_host_hermesc --target hermesc shermes
5252
}
5353

5454
# Utility function to configure an Apple framework
5555
function configure_apple_framework {
5656
local build_cli_tools
5757

58-
if [[ $1 == macosx ]]; then
58+
if [[ $1 == iphonesimulator || $1 == macosx ]]; then
5959
build_cli_tools="true"
6060
else
6161
build_cli_tools="false"
@@ -70,11 +70,15 @@ function configure_apple_framework {
7070
-DHERMES_ENABLE_LIBFUZZER:BOOLEAN=false \
7171
-DHERMES_ENABLE_FUZZILLI:BOOLEAN=false \
7272
-DHERMES_ENABLE_TEST_SUITE:BOOLEAN=false \
73+
-DHERMES_ENABLE_BITCODE:BOOLEAN=false \
7374
-DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=true \
7475
-DCMAKE_CXX_FLAGS="-gdwarf" \
7576
-DCMAKE_C_FLAGS="-gdwarf" \
7677
-DHERMES_ENABLE_TOOLS:BOOLEAN="$build_cli_tools" \
77-
-DIMPORT_HERMESC:PATH="$PWD/build_host_hermesc/ImportHermesc.cmake" \
78+
-DLLVM_ENABLE_TERMINFO=OFF \
79+
-DLIBREADLINE_FOUND=OFF \
80+
-DLIBTINFO_FOUND=OFF \
81+
-DIMPORT_HOST_COMPILERS:PATH="$PWD/build_host_hermesc/ImportHostCompilers.cmake" \
7882
-DCMAKE_INSTALL_PREFIX:PATH=../destroot \
7983
-DCMAKE_BUILD_TYPE="$BUILD_TYPE"
8084
}
@@ -84,16 +88,20 @@ function build_apple_framework {
8488
echo "Building framework for $1 with architectures: $2"
8589

8690
build_host_hermesc
87-
[ ! -f "$PWD/build_host_hermesc/ImportHermesc.cmake" ] &&
91+
[ ! -f "$PWD/build_host_hermesc/ImportHostCompilers.cmake" ] &&
8892
echo "Host hermesc is required to build apple frameworks!"
8993

9094
configure_apple_framework "$1" "$2" "$3"
9195

9296
if [[ "$BUILD_SYSTEM" == "Ninja" ]]; then
93-
(cd "./build_$1" && ninja install/strip)
97+
ninja -C "./build_$1" install/strip
9498
else
95-
(cd "./build_$1" && make install/strip)
99+
make -C "./build_$1" install/strip
96100
fi
101+
102+
# Copy the built binary to destroot so universal framework can be created later.
103+
mkdir -p "destroot/Library/Frameworks/$1"
104+
cp -R "./build_$1"/lib/hermesvm.framework* "destroot/Library/Frameworks/$1"
97105
}
98106

99107
# Accepts an array of frameworks and will place all of
@@ -108,11 +116,11 @@ function create_universal_framework {
108116
echo "Creating universal framework for platforms: ${platforms[*]}"
109117

110118
for i in "${!platforms[@]}"; do
111-
args+="-framework ${platforms[$i]}/hermes.framework "
119+
args+="-framework ${platforms[$i]}/hermesvm.framework "
112120
done
113121

114122
mkdir universal
115-
xcodebuild -create-xcframework $args -output "universal/hermes.xcframework"
123+
xcodebuild -create-xcframework $args -output "universal/hermesvm.xcframework"
116124

117125
for platform in $@; do
118126
rm -r "$platform"

utils/build-ios-framework.sh

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66

77
. ./utils/build-apple-framework.sh
88

9-
if [ ! -d destroot/Library/Frameworks/universal/hermes.xcframework ]; then
10-
ios_deployment_target=$(get_ios_deployment_target)
11-
visionos_deployment_target=$(get_visionos_deployment_target)
12-
tvos_deployment_target=$(get_tvos_deployment_target)
9+
ios_deployment_target=$(get_ios_deployment_target)
10+
visionos_deployment_target=$(get_visionos_deployment_target)
11+
tvos_deployment_target=$(get_tvos_deployment_target)
1312

13+
function build_all {
14+
if [ ! -d destroot/Library/Frameworks/universal/hermesvm.xcframework ]; then
1415
build_apple_framework "iphoneos" "arm64" "$ios_deployment_target"
1516
build_apple_framework "iphonesimulator" "x86_64;arm64" "$ios_deployment_target"
1617
build_apple_framework "catalyst" "x86_64;arm64" "$ios_deployment_target"
@@ -20,6 +21,20 @@ if [ ! -d destroot/Library/Frameworks/universal/hermes.xcframework ]; then
2021
build_apple_framework "appletvsimulator" "x86_64;arm64" "$tvos_deployment_target"
2122

2223
create_universal_framework "iphoneos" "iphonesimulator" "catalyst" "xros" "xrsimulator" "appletvos" "appletvsimulator"
23-
else
24+
else
2425
echo "Skipping; Clean \"destroot\" to rebuild".
26+
fi
27+
}
28+
29+
if [[ $1 == "iphoneos" ]]; then
30+
build_apple_framework "iphoneos" "arm64" "$ios_deployment_target"
31+
elif [[ $1 == "iphonesimulator" ]]; then
32+
build_apple_framework "iphonesimulator" "x86_64;arm64" "$ios_deployment_target"
33+
elif [[ $1 == "appletvos" ]]; then
34+
build_apple_framework "appletvos" "arm64" "$tvos_deployment_target"
35+
elif [[ $1 == "appletvsimulator" ]]; then
36+
build_apple_framework "appletvsimulator" "x86_64;arm64" "$tvos_deployment_target"
37+
else
38+
echo "Build for all supported platforms and create universal framework."
39+
build_all
2540
fi

utils/build-mac-framework.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# LICENSE file in the root directory of this source tree.
66

77
. ./utils/build-apple-framework.sh
8-
if [ ! -d destroot/Library/Frameworks/macosx/hermes.framework ]; then
8+
if [ ! -d destroot/Library/Frameworks/macosx/hermesvm.framework ]; then
99
mac_deployment_target=$(get_mac_deployment_target)
1010

1111
build_apple_framework "macosx" "x86_64;arm64" "$mac_deployment_target"

0 commit comments

Comments
 (0)