4
4
# This source code is licensed under the MIT license found in the
5
5
# LICENSE file in the root directory of this source tree.
6
6
7
- NUM_CORES=$( sysctl -n hw.ncpu)
7
+ # Defines functions for building various Hermes frameworks.
8
+ # See build-ios-framework.sh and build-mac-framework.sh for usage examples.
9
+
10
+ CURR_SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd -P) "
11
+
8
12
IMPORT_HERMESC_PATH=${HERMES_OVERRIDE_HERMESC_PATH:- $PWD / build_host_hermesc/ ImportHermesc.cmake}
9
- REACT_NATIVE_PATH=${REACT_NATIVE_PATH:- $PWD / ../ ..}
13
+ BUILD_TYPE=${BUILD_TYPE:- Debug}
14
+
15
+ HERMES_PATH=" $CURR_SCRIPT_DIR /.."
16
+ REACT_NATIVE_PATH=${REACT_NATIVE_PATH:- $CURR_SCRIPT_DIR / ../ ../ ..}
17
+
18
+ NUM_CORES=$( sysctl -n hw.ncpu)
19
+
10
20
if [[ -z " $JSI_PATH " ]]; then
11
21
JSI_PATH=" $REACT_NATIVE_PATH /ReactCommon/jsi"
12
22
fi
@@ -34,8 +44,10 @@ function get_mac_deployment_target {
34
44
# Build host hermes compiler for internal bytecode
35
45
function build_host_hermesc {
36
46
echo " Building hermesc"
37
- cmake -S . -B build_host_hermesc
38
- cmake --build ./build_host_hermesc --target hermesc -j ${NUM_CORES}
47
+ pushd " $HERMES_PATH " > /dev/null || exit 1
48
+ cmake -S . -B build_host_hermesc -DJSI_DIR=" $JSI_PATH "
49
+ cmake --build ./build_host_hermesc --target hermesc -j " ${NUM_CORES} "
50
+ popd > /dev/null || exit 1
39
51
}
40
52
41
53
# Utility function to configure an Apple framework
@@ -58,30 +70,30 @@ function configure_apple_framework {
58
70
enable_debugger=" false"
59
71
fi
60
72
61
- cmake -S . -B " build_$1 " \
62
- -DHERMES_APPLE_TARGET_PLATFORM:STRING=" $1 " \
63
- -DCMAKE_OSX_ARCHITECTURES:STRING=" $2 " \
64
- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=" $3 " \
65
- -DHERMES_ENABLE_DEBUGGER:BOOLEAN=" $enable_debugger " \
66
- -DHERMES_ENABLE_INTL:BOOLEAN=true \
67
- -DHERMES_ENABLE_LIBFUZZER:BOOLEAN=false \
68
- -DHERMES_ENABLE_FUZZILLI:BOOLEAN=false \
69
- -DHERMES_ENABLE_TEST_SUITE:BOOLEAN=false \
70
- -DHERMES_ENABLE_BITCODE:BOOLEAN=" $enable_bitcode " \
71
- -DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=true \
72
- -DHERMES_BUILD_APPLE_DSYM:BOOLEAN=true \
73
- -DHERMES_ENABLE_TOOLS:BOOLEAN=" $build_cli_tools " \
74
- -DIMPORT_HERMESC:PATH=" $IMPORT_HERMESC_PATH " \
75
- -DJSI_DIR=" $JSI_PATH " \
76
- -DHERMES_RELEASE_VERSION=" for RN $( get_release_version) " \
77
- -DCMAKE_INSTALL_PREFIX:PATH=../destroot \
78
- -DCMAKE_BUILD_TYPE=" $BUILD_TYPE "
73
+ pushd " $HERMES_PATH " > /dev/null || exit 1
74
+ cmake -S . -B " build_$1 " \
75
+ -DHERMES_APPLE_TARGET_PLATFORM:STRING=" $1 " \
76
+ -DCMAKE_OSX_ARCHITECTURES:STRING=" $2 " \
77
+ -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=" $3 " \
78
+ -DHERMES_ENABLE_DEBUGGER:BOOLEAN=" $enable_debugger " \
79
+ -DHERMES_ENABLE_INTL:BOOLEAN=true \
80
+ -DHERMES_ENABLE_LIBFUZZER:BOOLEAN=false \
81
+ -DHERMES_ENABLE_FUZZILLI:BOOLEAN=false \
82
+ -DHERMES_ENABLE_TEST_SUITE:BOOLEAN=false \
83
+ -DHERMES_ENABLE_BITCODE:BOOLEAN=" $enable_bitcode " \
84
+ -DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=true \
85
+ -DHERMES_BUILD_APPLE_DSYM:BOOLEAN=true \
86
+ -DHERMES_ENABLE_TOOLS:BOOLEAN=" $build_cli_tools " \
87
+ -DIMPORT_HERMESC:PATH=" $IMPORT_HERMESC_PATH " \
88
+ -DJSI_DIR=" $JSI_PATH " \
89
+ -DHERMES_RELEASE_VERSION=" for RN $( get_release_version) " \
90
+ -DCMAKE_INSTALL_PREFIX:PATH=../destroot \
91
+ -DCMAKE_BUILD_TYPE=" $BUILD_TYPE "
92
+ popd > /dev/null || exit 1
79
93
}
80
94
81
95
# Utility function to build an Apple framework
82
96
function build_apple_framework {
83
- echo " Building $BUILD_TYPE framework for $1 with architectures: $2 "
84
-
85
97
# Only build host HermesC if no file found at $IMPORT_HERMESC_PATH
86
98
[ ! -f " $IMPORT_HERMESC_PATH " ] &&
87
99
build_host_hermesc
@@ -90,32 +102,43 @@ function build_apple_framework {
90
102
[ ! -f " $IMPORT_HERMESC_PATH " ] &&
91
103
echo " Host hermesc is required to build apple frameworks!"
92
104
105
+ echo " Building $BUILD_TYPE framework for $1 with architectures: $2 "
93
106
configure_apple_framework " $1 " " $2 " " $3 "
94
- cmake --build " ./build_$1 " --target install/strip -j ${NUM_CORES}
107
+
108
+ pushd " $HERMES_PATH " > /dev/null || exit 1
109
+ cmake --build " ./build_$1 " --target install/strip -j " ${NUM_CORES} "
110
+ popd > /dev/null || exit 1
95
111
}
96
112
97
113
# Accepts an array of frameworks and will place all of
98
114
# the architectures into an universal folder and then remove
99
115
# the merged frameworks from destroot
100
116
function create_universal_framework {
101
- cd . /destroot/Library/Frameworks || exit 1
117
+ pushd " $HERMES_PATH /destroot/Library/Frameworks" > /dev/null || exit 1
102
118
103
119
local platforms=(" $@ " )
104
120
local args=" "
105
121
106
122
echo " Creating universal framework for platforms: ${platforms[*]} "
107
123
108
124
for i in " ${! platforms[@]} " ; do
109
- args+=" -framework ${platforms[$i]} /hermes.framework "
125
+ local hermes_framework_path=" ${platforms[$i]} /hermes.framework"
126
+ args+=" -framework $hermes_framework_path "
127
+
128
+ # Path to dSYM must be absolute
129
+ args+=" -debug-symbols $HERMES_PATH /destroot/Library/Frameworks/$hermes_framework_path .dSYM "
110
130
done
111
131
112
- mkdir universal
132
+ mkdir -p universal
113
133
# shellcheck disable=SC2086
114
- xcodebuild -create-xcframework $args -output " universal/hermes.xcframework"
115
-
116
- for platform in " $@ " ; do
117
- rm -r " $platform "
118
- done
134
+ if xcodebuild -create-xcframework $args -output " universal/hermes.xcframework"
135
+ then
136
+ # # Remove the thin iOS hermes.frameworks that are now part of the universal
137
+ # XCFramework
138
+ for platform in " ${platforms[@]} " ; do
139
+ rm -r " $platform "
140
+ done
141
+ fi
119
142
120
- cd - || exit 1
143
+ popd > /dev/null || exit 1
121
144
}
0 commit comments