react-native-macos 0.76.11 → 0.76.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/Libraries/Blob/RCTBlobManager.h +0 -0
  2. package/Libraries/Blob/RCTBlobManager.mm +0 -0
  3. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +0 -0
  4. package/Libraries/Core/ReactNativeVersion.js +1 -1
  5. package/Libraries/StyleSheet/normalizeColor.js +0 -0
  6. package/React/Base/RCTJavaScriptLoader.h +0 -0
  7. package/React/Base/RCTJavaScriptLoader.mm +0 -0
  8. package/React/Base/RCTVersion.m +1 -1
  9. package/ReactAndroid/gradle.properties +1 -1
  10. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  11. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  12. package/local-cli/cli.js +0 -0
  13. package/package.json +3 -3
  14. package/scripts/cocoapods/autolinking.rb +206 -0
  15. package/scripts/cocoapods/autolinking_utils.rb +25 -0
  16. package/scripts/cocoapods/codegen.rb +59 -0
  17. package/scripts/cocoapods/codegen_script_phase_extractor.rb +13 -0
  18. package/scripts/cocoapods/codegen_utils.rb +363 -0
  19. package/scripts/cocoapods/fabric.rb +18 -0
  20. package/scripts/cocoapods/helpers.rb +148 -0
  21. package/scripts/cocoapods/jsengine.rb +33 -0
  22. package/scripts/cocoapods/local_podspec_patch.rb +51 -0
  23. package/scripts/cocoapods/new_architecture.rb +193 -0
  24. package/scripts/cocoapods/privacy_manifest_utils.rb +194 -0
  25. package/scripts/cocoapods/runtime.rb +18 -0
  26. package/scripts/cocoapods/spm.rb +94 -0
  27. package/scripts/cocoapods/utils.rb +729 -0
  28. package/scripts/codegen/codegen-utils.js +51 -0
  29. package/scripts/codegen/generate-artifacts-executor.js +815 -0
  30. package/scripts/codegen/generate-specs-cli-executor.js +128 -0
  31. package/scripts/codegen/templates/RCTModulesConformingToProtocolsProviderH.template +18 -0
  32. package/scripts/codegen/templates/RCTModulesConformingToProtocolsProviderMM.template +33 -0
  33. package/scripts/compose-source-maps.js +0 -0
  34. package/scripts/ios-configure-glog.sh +0 -0
  35. package/scripts/node-binary.sh +0 -0
  36. package/scripts/packager.sh +0 -0
  37. package/scripts/react-native-xcode.sh +0 -0
  38. package/scripts/react_native_pods_utils/script_phases.sh +0 -0
  39. package/scripts/xcode/ccache-clang++.sh +0 -0
  40. package/scripts/xcode/ccache-clang.sh +0 -0
  41. package/scripts/xcode/with-environment.sh +0 -0
  42. package/sdks/hermes-engine/hermes-engine.podspec +160 -0
  43. package/sdks/hermes-engine/hermes-utils.rb +337 -0
  44. package/sdks/hermes-engine/utils/build-apple-framework.sh +225 -0
  45. package/sdks/hermes-engine/utils/build-hermes-xcode.sh +100 -0
  46. package/sdks/hermes-engine/utils/build-hermesc-xcode.sh +18 -0
  47. package/sdks/hermes-engine/utils/build-ios-framework.sh +85 -0
  48. package/sdks/hermes-engine/utils/build-mac-framework.sh +22 -0
  49. package/sdks/hermes-engine/utils/copy-hermes-xcode.sh +7 -0
  50. package/sdks/hermes-engine/utils/create-dummy-hermes-xcframework.sh +32 -0
  51. package/sdks/hermes-engine/utils/replace_hermes_version.js +106 -0
  52. package/scripts/featureflags/README.md +0 -156
  53. package/scripts/featureflags/index.js +0 -14
@@ -0,0 +1,337 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ require 'net/http'
7
+ require 'rexml/document'
8
+ require 'open3' # [macOS]
9
+ require 'json' # [macOS]
10
+ require 'tmpdir' # [macOS]
11
+
12
+ HERMES_GITHUB_URL = "https://github.com/facebook/hermes.git"
13
+ ENV_BUILD_FROM_SOURCE = "RCT_BUILD_HERMES_FROM_SOURCE"
14
+
15
+ module HermesEngineSourceType
16
+ LOCAL_PREBUILT_TARBALL = :local_prebuilt_tarball
17
+ DOWNLOAD_PREBUILD_RELEASE_TARBALL = :download_prebuild_release_tarball
18
+ DOWNLOAD_PREBUILT_NIGHTLY_TARBALL = :download_prebuilt_nightly_tarball
19
+ BUILD_FROM_GITHUB_COMMIT = :build_from_github_commit
20
+ BUILD_FROM_GITHUB_TAG = :build_from_github_tag
21
+ BUILD_FROM_GITHUB_MAIN = :build_from_github_main
22
+ BUILD_FROM_LOCAL_SOURCE_DIR = :build_from_local_source_dir
23
+
24
+ def HermesEngineSourceType.isPrebuilt(source_type)
25
+ return source_type == LOCAL_PREBUILT_TARBALL || source_type == DOWNLOAD_PREBUILD_RELEASE_TARBALL || source_type == DOWNLOAD_PREBUILT_NIGHTLY_TARBALL
26
+ end
27
+
28
+ def HermesEngineSourceType.isFromSource(source_type)
29
+ return source_type == BUILD_FROM_GITHUB_COMMIT || source_type == BUILD_FROM_GITHUB_TAG || source_type == BUILD_FROM_GITHUB_MAIN || source_type == BUILD_FROM_LOCAL_SOURCE_DIR
30
+ end
31
+ end
32
+
33
+ # Computes the hermes-engine.podspec's source type.
34
+ # - To use a specific tarball, install the dependencies with:
35
+ # `HERMES_ENGINE_TARBALL_PATH=<path_to_tarball> bundle exec pod install`
36
+ # - To force a build from source, install the dependencies with:
37
+ # `RCT_BUILD_HERMES_FROM_SOURCE=true bundle exec pod install`
38
+ # If none of the two are provided, Cocoapods will check whether there is a tarball for the current version
39
+ # (either release or nightly). If not, it will fall back to building from source (the latest commit on main).
40
+ #
41
+ # Parameters:
42
+ # - version: current version of the pod
43
+ # - react_native_path: path to react native
44
+ #
45
+
46
+ # Returns: hermes-engine source type
47
+ def hermes_source_type(version, react_native_path)
48
+ if override_hermes_dir_envvar_defined()
49
+ return HermesEngineSourceType::BUILD_FROM_LOCAL_SOURCE_DIR
50
+ end
51
+
52
+ if hermes_engine_tarball_envvar_defined()
53
+ return HermesEngineSourceType::LOCAL_PREBUILT_TARBALL
54
+ end
55
+
56
+ if hermes_commit_envvar_defined()
57
+ return HermesEngineSourceType::BUILD_FROM_GITHUB_COMMIT
58
+ end
59
+
60
+ if force_build_from_tag(react_native_path)
61
+ return HermesEngineSourceType::BUILD_FROM_GITHUB_TAG
62
+ end
63
+
64
+ if force_build_from_main(react_native_path)
65
+ return HermesEngineSourceType::BUILD_FROM_GITHUB_MAIN
66
+ end
67
+
68
+ if release_artifact_exists(version)
69
+ return HermesEngineSourceType::DOWNLOAD_PREBUILD_RELEASE_TARBALL
70
+ end
71
+
72
+ if nightly_artifact_exists(version)
73
+ return HermesEngineSourceType::DOWNLOAD_PREBUILT_NIGHTLY_TARBALL
74
+ end
75
+
76
+ return HermesEngineSourceType::BUILD_FROM_GITHUB_MAIN
77
+ end
78
+
79
+ def override_hermes_dir_envvar_defined()
80
+ return ENV.has_key?('REACT_NATIVE_OVERRIDE_HERMES_DIR')
81
+ end
82
+
83
+ def hermes_engine_tarball_envvar_defined()
84
+ return ENV.has_key?('HERMES_ENGINE_TARBALL_PATH')
85
+ end
86
+
87
+ def hermes_commit_envvar_defined()
88
+ return ENV.has_key?('HERMES_COMMIT')
89
+ end
90
+
91
+ def force_build_from_tag(react_native_path)
92
+ return ENV[ENV_BUILD_FROM_SOURCE] === 'true' && File.exist?(hermestag_file(react_native_path))
93
+ end
94
+
95
+ def force_build_from_main(react_native_path)
96
+ return ENV[ENV_BUILD_FROM_SOURCE] === 'true' && !File.exist?(hermestag_file(react_native_path))
97
+ end
98
+
99
+ def release_artifact_exists(version)
100
+ return hermes_artifact_exists(release_tarball_url(version, :debug))
101
+ end
102
+
103
+ def nightly_artifact_exists(version)
104
+ return hermes_artifact_exists(nightly_tarball_url(version).gsub("\\", ""))
105
+ end
106
+
107
+ def podspec_source(source_type, version, react_native_path)
108
+ case source_type
109
+ when HermesEngineSourceType::BUILD_FROM_LOCAL_SOURCE_DIR
110
+ return podspec_source_build_from_local_source_dir(react_native_path)
111
+ when HermesEngineSourceType::LOCAL_PREBUILT_TARBALL
112
+ return podspec_source_local_prebuilt_tarball()
113
+ when HermesEngineSourceType::BUILD_FROM_GITHUB_COMMIT
114
+ return podspec_source_build_from_github_commit()
115
+ when HermesEngineSourceType::BUILD_FROM_GITHUB_TAG
116
+ return podspec_source_build_from_github_tag(react_native_path)
117
+ when HermesEngineSourceType::BUILD_FROM_GITHUB_MAIN
118
+ return podspec_source_build_from_github_main()
119
+ when HermesEngineSourceType::DOWNLOAD_PREBUILD_RELEASE_TARBALL
120
+ return podspec_source_download_prebuild_release_tarball(react_native_path, version)
121
+ when HermesEngineSourceType::DOWNLOAD_PREBUILT_NIGHTLY_TARBALL
122
+ return podspec_source_download_prebuilt_nightly_tarball(version)
123
+ else
124
+ abort "[Hermes] Unsupported or invalid source type provided: #{source_type}"
125
+ end
126
+ end
127
+
128
+ def podspec_source_build_from_local_source_dir(react_native_path)
129
+ source_dir_path = ENV['REACT_NATIVE_OVERRIDE_HERMES_DIR']
130
+ if Dir.exist?(source_dir_path)
131
+ hermes_log("Using source code from local path: #{source_dir_path}")
132
+ tarball_path = File.join(artifacts_dir(), "hermes-engine-from-local-source-dir.tar.gz")
133
+ exclude_paths = [
134
+ "__tests__",
135
+ "./external/flowtest",
136
+ "./external/esprima/test_fixtures"
137
+ ]
138
+ .map {|path| "--exclude=#{path}"}
139
+ .join(' ')
140
+ tar_command = "tar #{exclude_paths} -czvf #{tarball_path} -C #{source_dir_path} . 2> /dev/null"
141
+ success = system(tar_command)
142
+ if !success
143
+ abort "Failed to create a tarball with the contents of \"#{source_dir_path}\""
144
+ end
145
+ return {:http => "file://#{tarball_path}"}
146
+ else
147
+ abort <<-EOS
148
+ [Hermes] REACT_NATIVE_OVERRIDE_HERMES_DIR is set, but points to a non-existing directory: \"#{source_dir_path}\"
149
+ If you don't want to use local source, run `unset REACT_NATIVE_OVERRIDE_HERMES_DIR`
150
+ EOS
151
+ end
152
+ end
153
+
154
+ def podspec_source_local_prebuilt_tarball()
155
+ tarball_path = ENV['HERMES_ENGINE_TARBALL_PATH']
156
+ if File.exist?(tarball_path)
157
+ hermes_log("Using pre-built binary from local path defined by HERMES_ENGINE_TARBALL_PATH envvar: #{tarball_path}")
158
+ return {:http => "file://#{tarball_path}"}
159
+ end
160
+ abort <<-EOS
161
+ [Hermes] HERMES_ENGINE_TARBALL_PATH is set, but points to a non-existing file: \"#{tarball_path}\"
162
+ If you don't want to use tarball, run `unset HERMES_ENGINE_TARBALL_PATH`
163
+ EOS
164
+ end
165
+
166
+ def podspec_source_build_from_github_commit()
167
+ commit = ENV['HERMES_COMMIT']
168
+ hermes_log("Using commit defined by HERMES_COMMIT envvar: #{commit}")
169
+ return {:git => HERMES_GITHUB_URL, :commit => commit}
170
+ end
171
+
172
+ def podspec_source_build_from_github_tag(react_native_path)
173
+ tag = File.read(hermestag_file(react_native_path)).strip
174
+ hermes_log("Using tag difined in sdks/.hermesversion: #{tag}")
175
+ return {:git => HERMES_GITHUB_URL, :tag => tag}
176
+ end
177
+
178
+ def podspec_source_build_from_github_main()
179
+ # hermes_log("Using the latest commit from main.")
180
+ # return {:git => HERMES_GITHUB_URL, :commit => `git ls-remote #{HERMES_GITHUB_URL} main | cut -f 1`.strip}
181
+
182
+ # [macOS
183
+ # The logic for this is a bit different on macOS.
184
+ # Since react-native-macos lags slightly behind facebook/react-native, we can't always use
185
+ # the latest Hermes commit because Hermes and JSI don't always guarantee backwards compatibility.
186
+ # Instead, we take the commit hash of Hermes at the time of the merge base with facebook/react-native.
187
+ commit = hermes_commit_at_merge_base()
188
+ hermes_log("Using Hermes commit from the merge base with facebook/react-native: #{commit}")
189
+ return {:git => HERMES_GITHUB_URL, :commit => commit}
190
+ # macOS]
191
+ end
192
+
193
+ def podspec_source_download_prebuild_release_tarball(react_native_path, version)
194
+ url = release_tarball_url(version, :debug)
195
+ hermes_log("Using release tarball from URL: #{url}")
196
+ download_stable_hermes(react_native_path, version, :debug)
197
+ download_stable_hermes(react_native_path, version, :release)
198
+ return {:http => url}
199
+ end
200
+
201
+ def podspec_source_download_prebuilt_nightly_tarball(version)
202
+ url = nightly_tarball_url(version)
203
+ hermes_log("Using nightly tarball from URL: #{url}")
204
+ return {:http => url}
205
+ end
206
+
207
+ # HELPERS
208
+
209
+ def artifacts_dir()
210
+ return File.join(Pod::Config.instance.project_pods_root, "hermes-engine-artifacts")
211
+ end
212
+
213
+ # [macOS
214
+ def hermes_commit_at_merge_base()
215
+ # We don't need ls-remote because react-native-macos is a fork of facebook/react-native
216
+ fetch_result = `git fetch -q https://github.com/facebook/react-native.git`
217
+ if $?.exitstatus != 0
218
+ abort <<-EOS
219
+ [Hermes] Failed to fetch facebook/react-native into the local repository.
220
+ EOS
221
+ end
222
+
223
+ merge_base = `git merge-base FETCH_HEAD HEAD`.strip
224
+ if merge_base.empty?
225
+ abort <<-EOS
226
+ [Hermes] Unable to find the merge base between our HEAD and upstream's HEAD.
227
+ EOS
228
+ end
229
+
230
+ timestamp = `git show -s --format=%ci #{merge_base}`.strip
231
+ if timestamp.empty?
232
+ abort <<-EOS
233
+ [Hermes] Unable to extract the timestamp for the merge base (#{merge_base}).
234
+ EOS
235
+ end
236
+
237
+ commit = nil
238
+ Dir.mktmpdir do |tmpdir|
239
+ hermes_git_dir = File.join(tmpdir, "hermes.git")
240
+ # Unfortunately we can't use git rev-list on HERMES_GITHUB_URL directly since we're not in that repo.
241
+ # Instead, we create a shallow clone to avoid downloading the entire history.
242
+ `git clone -q --bare --shallow-since="#{timestamp}" #{HERMES_GITHUB_URL} "#{hermes_git_dir}"`
243
+ `git --git-dir="#{hermes_git_dir}" fetch -q --deepen=1`
244
+
245
+ # If all goes well, this will be the commit hash of Hermes at the time of the merge base
246
+ commit = `git --git-dir="#{hermes_git_dir}" rev-list -1 --before="#{timestamp}" HEAD`.strip
247
+ if commit.empty?
248
+ abort <<-EOS
249
+ [Hermes] Unable to find the Hermes commit hash at time #{timestamp}.
250
+ EOS
251
+ end
252
+ end
253
+
254
+ return commit
255
+ end
256
+ # macOS]
257
+
258
+ def hermestag_file(react_native_path)
259
+ return File.join(react_native_path, "sdks", ".hermesversion")
260
+ end
261
+
262
+ def release_tarball_url(version, build_type)
263
+ # Sample url from Maven:
264
+ # https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.71.0/react-native-artifacts-0.71.0-hermes-ios-debug.tar.gz
265
+ return "https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/#{version}/react-native-artifacts-#{version}-hermes-ios-#{build_type.to_s}.tar.gz"
266
+ end
267
+
268
+ def download_stable_hermes(react_native_path, version, configuration)
269
+ tarball_url = release_tarball_url(version, configuration)
270
+ download_hermes_tarball(react_native_path, tarball_url, version, configuration)
271
+ end
272
+
273
+ def download_hermes_tarball(react_native_path, tarball_url, version, configuration)
274
+ destination_path = configuration == nil ?
275
+ "#{artifacts_dir()}/hermes-ios-#{version}.tar.gz" :
276
+ "#{artifacts_dir()}/hermes-ios-#{version}-#{configuration}.tar.gz"
277
+
278
+ unless File.exist?(destination_path)
279
+ # Download to a temporary file first so we don't cache incomplete downloads.
280
+ tmp_file = "#{artifacts_dir()}/hermes-ios.download"
281
+ `mkdir -p "#{artifacts_dir()}" && curl "#{tarball_url}" -Lo "#{tmp_file}" && mv "#{tmp_file}" "#{destination_path}"`
282
+ end
283
+ return destination_path
284
+ end
285
+
286
+ def nightly_tarball_url(version)
287
+ params = "r=snapshots\&g=com.facebook.react\&a=react-native-artifacts\&c=hermes-ios-debug\&e=tar.gz\&v=#{version}-SNAPSHOT"
288
+ return resolve_url_redirects("http://oss.sonatype.org/service/local/artifact/maven/redirect\?#{params}")
289
+ end
290
+
291
+ def resolve_url_redirects(url)
292
+ return (`curl -Ls -o /dev/null -w %{url_effective} \"#{url}\"`)
293
+ end
294
+
295
+ # [macOS
296
+ # Tries to find a suitable Hermes version for a given react-native-macos package.
297
+ # For stable branches, we prefer this to be specified as a peer dependency.
298
+ def findMatchingHermesVersion(package)
299
+ if package['version'] == "1000.0.0"
300
+ # The main branch builds from source, so skip this check
301
+ return nil
302
+ end
303
+
304
+ if package['peerDependencies']
305
+ return package['peerDependencies']['react-native']
306
+ end
307
+
308
+ hermes_log("No matching Hermes version found. Defaulting to main branch, which may be unreliable.")
309
+ end
310
+ # macOS]
311
+
312
+ # This function checks that Hermes artifact exists.
313
+ # As of now it should check it on the Maven repo.
314
+ #
315
+ # Parameters
316
+ # - version: the version of React Native
317
+ # - build_type: debug or release
318
+ def hermes_artifact_exists(tarball_url)
319
+ # -L is used to follow redirects, useful for the nightlies
320
+ # I also needed to wrap the url in quotes to avoid escaping & and ?.
321
+ return (`curl -o /dev/null --silent -Iw '%{http_code}' -L "#{tarball_url}"` == "200")
322
+ end
323
+
324
+ def hermes_log(message, level = :warning)
325
+ if !Object.const_defined?("Pod::UI")
326
+ return
327
+ end
328
+ hermes_log_messgae = '[Hermes] ' + message
329
+ case level
330
+ when :info
331
+ Pod::UI.puts hermes_log_messgae.green
332
+ when :error
333
+ Pod::UI.puts hermes_log_messgae.red
334
+ else
335
+ Pod::UI.puts hermes_log_messgae.yellow
336
+ end
337
+ end
@@ -0,0 +1,225 @@
1
+ #!/bin/bash
2
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ #
4
+ # This source code is licensed under the MIT license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
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
+
12
+ IMPORT_HERMESC_PATH=${HERMES_OVERRIDE_HERMESC_PATH:-$PWD/build_host_hermesc/ImportHermesc.cmake}
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
+
20
+ PLATFORMS=("macosx" "iphoneos" "iphonesimulator" "catalyst" "xros" "xrsimulator")
21
+
22
+ if [[ -z "$JSI_PATH" ]]; then
23
+ JSI_PATH="$REACT_NATIVE_PATH/ReactCommon/jsi"
24
+ fi
25
+
26
+ function use_env_var_or_ruby_prop {
27
+ if [[ -n "$1" ]]; then
28
+ echo "$1"
29
+ else
30
+ ruby -rcocoapods-core -rjson -e "puts Pod::Specification.from_file('hermes-engine.podspec').$2"
31
+ fi
32
+ }
33
+
34
+ function use_env_var {
35
+ if [[ -n "$1" ]]; then
36
+ echo "$1"
37
+ else
38
+ echo "error: Missing $2 environment variable"
39
+ exit 1
40
+ fi
41
+ }
42
+
43
+ function get_release_version {
44
+ use_env_var_or_ruby_prop "${RELEASE_VERSION}" "version"
45
+ }
46
+
47
+ function get_ios_deployment_target {
48
+ use_env_var "${IOS_DEPLOYMENT_TARGET}" "IOS_DEPLOYMENT_TARGET"
49
+ }
50
+
51
+ function get_visionos_deployment_target {
52
+ use_env_var "${XROS_DEPLOYMENT_TARGET}" "XROS_DEPLOYMENT_TARGET"
53
+ }
54
+
55
+ function get_mac_deployment_target {
56
+ use_env_var "${MAC_DEPLOYMENT_TARGET}" "MAC_DEPLOYMENT_TARGET"
57
+ }
58
+
59
+ # Build host hermes compiler for internal bytecode
60
+ function build_host_hermesc {
61
+ echo "Building hermesc"
62
+ pushd "$HERMES_PATH" > /dev/null || exit 1
63
+ cmake -S . -B build_host_hermesc -DJSI_DIR="$JSI_PATH"
64
+ cmake --build ./build_host_hermesc --target hermesc -j "${NUM_CORES}"
65
+ popd > /dev/null || exit 1
66
+ }
67
+
68
+ # Utility function to configure an Apple framework
69
+ function configure_apple_framework {
70
+ local enable_debugger cmake_build_type xcode_15_flags xcode_major_version
71
+
72
+ if [[ $BUILD_TYPE == "Debug" ]]; then
73
+ enable_debugger="true"
74
+ else
75
+ enable_debugger="false"
76
+ fi
77
+ if [[ $BUILD_TYPE == "Debug" ]]; then
78
+ # JS developers aren't VM developers.
79
+ # Therefore we're passing as build type Release, to provide a faster build.
80
+ cmake_build_type="Release"
81
+ else
82
+ cmake_build_type="MinSizeRel"
83
+ fi
84
+
85
+ xcode_15_flags=""
86
+ xcode_major_version=$(xcodebuild -version | grep -oE '[0-9]*' | head -n 1)
87
+ if [[ $xcode_major_version -ge 15 ]]; then
88
+ xcode_15_flags="LINKER:-ld_classic"
89
+ fi
90
+
91
+ pushd "$HERMES_PATH" > /dev/null || exit 1
92
+ cmake -S . -B "build_$1" \
93
+ -DHERMES_EXTRA_LINKER_FLAGS="$xcode_15_flags" \
94
+ -DHERMES_APPLE_TARGET_PLATFORM:STRING="$1" \
95
+ -DCMAKE_OSX_ARCHITECTURES:STRING="$2" \
96
+ -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="$3" \
97
+ -DHERMES_ENABLE_DEBUGGER:BOOLEAN="$enable_debugger" \
98
+ -DHERMES_ENABLE_INTL:BOOLEAN=true \
99
+ -DHERMES_ENABLE_LIBFUZZER:BOOLEAN=false \
100
+ -DHERMES_ENABLE_FUZZILLI:BOOLEAN=false \
101
+ -DHERMES_ENABLE_TEST_SUITE:BOOLEAN=false \
102
+ -DHERMES_ENABLE_BITCODE:BOOLEAN=false \
103
+ -DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=true \
104
+ -DHERMES_BUILD_SHARED_JSI:BOOLEAN=false \
105
+ -DHERMES_BUILD_APPLE_DSYM:BOOLEAN=true \
106
+ -DIMPORT_HERMESC:PATH="$IMPORT_HERMESC_PATH" \
107
+ -DJSI_DIR="$JSI_PATH" \
108
+ -DHERMES_RELEASE_VERSION="for RN $(get_release_version)" \
109
+ -DCMAKE_BUILD_TYPE="$cmake_build_type"
110
+ popd > /dev/null || exit 1
111
+ }
112
+
113
+ function build_host_hermesc_if_needed {
114
+ if [[ ! -f "$IMPORT_HERMESC_PATH" ]]; then
115
+ build_host_hermesc
116
+ else
117
+ echo "[HermesC] Skipping! Found an existent hermesc already at: $IMPORT_HERMESC_PATH"
118
+ fi
119
+ }
120
+
121
+ # Utility function to build an Apple framework
122
+ function build_apple_framework {
123
+ # Only build host HermesC if no file found at $IMPORT_HERMESC_PATH
124
+ build_host_hermesc_if_needed
125
+
126
+ # Confirm ImportHermesc.cmake is now available.
127
+ [ ! -f "$IMPORT_HERMESC_PATH" ] &&
128
+ echo "Host hermesc is required to build apple frameworks!"
129
+
130
+ # $1: platform, $2: architectures, $3: deployment target
131
+ echo "Building $BUILD_TYPE framework for $1 with architectures: $2"
132
+ configure_apple_framework "$1" "$2" "$3"
133
+
134
+ pushd "$HERMES_PATH" > /dev/null || exit 1
135
+ mkdir -p "destroot/Library/Frameworks/$1"
136
+ cmake --build "./build_$1" --target libhermes -j "${NUM_CORES}"
137
+ cp -R "./build_$1"/API/hermes/hermes.framework* "destroot/Library/Frameworks/$1"
138
+
139
+ # In a MacOS build, also produce the hermes and hermesc CLI tools.
140
+ if [[ $1 == macosx ]]; then
141
+ cmake --build "./build_$1" --target hermesc hermes -j "${NUM_CORES}"
142
+ mkdir -p destroot/bin
143
+ cp "./build_$1/bin"/* "destroot/bin"
144
+ fi
145
+
146
+ # Copy over Hermes and JSI API headers.
147
+ mkdir -p destroot/include/hermes/Public
148
+ cp public/hermes/Public/*.h destroot/include/hermes/Public
149
+
150
+ mkdir -p destroot/include/hermes
151
+ cp API/hermes/*.h destroot/include/hermes
152
+
153
+ mkdir -p destroot/include/hermes/cdp
154
+ cp API/hermes/cdp/*.h destroot/include/hermes/cdp
155
+
156
+ mkdir -p destroot/include/hermes/inspector
157
+ cp API/hermes/inspector/*.h destroot/include/hermes/inspector
158
+
159
+ mkdir -p destroot/include/hermes/inspector/chrome
160
+ cp API/hermes/inspector/chrome/*.h destroot/include/hermes/inspector/chrome
161
+
162
+ mkdir -p destroot/include/jsi
163
+ cp "$JSI_PATH"/jsi/*.h destroot/include/jsi
164
+ popd > /dev/null || exit 1
165
+ }
166
+
167
+ function prepare_dest_root_for_ci {
168
+ mkdir -p "destroot/bin"
169
+ for platform in "${PLATFORMS[@]}"; do
170
+ mkdir -p "destroot/Library/Frameworks/$platform"
171
+ cp -R "./build_$platform/API/hermes/hermes.framework"* "destroot/Library/Frameworks/$platform"
172
+ done
173
+
174
+ cp "./build_macosx/bin/"* "destroot/bin"
175
+
176
+ # Copy over Hermes and JSI API headers.
177
+ mkdir -p destroot/include/hermes/Public
178
+ cp public/hermes/Public/*.h destroot/include/hermes/Public
179
+
180
+ mkdir -p destroot/include/hermes
181
+ cp API/hermes/*.h destroot/include/hermes
182
+
183
+ mkdir -p destroot/include/hermes/cdp
184
+ cp API/hermes/cdp/*.h destroot/include/hermes/cdp
185
+
186
+ mkdir -p destroot/include/hermes/inspector
187
+ cp API/hermes/inspector/*.h destroot/include/hermes/inspector
188
+
189
+ mkdir -p destroot/include/hermes/inspector/chrome
190
+ cp API/hermes/inspector/chrome/*.h destroot/include/hermes/inspector/chrome
191
+
192
+ mkdir -p destroot/include/jsi
193
+ cp "$JSI_PATH"/jsi/*.h destroot/include/jsi
194
+ }
195
+
196
+ # Accepts an array of frameworks and will place all of
197
+ # the architectures into an universal folder and then remove
198
+ # the merged frameworks from destroot
199
+ function create_universal_framework {
200
+ pushd "$HERMES_PATH/destroot/Library/Frameworks" > /dev/null || exit 1
201
+
202
+ local platforms=("$@")
203
+ local args=""
204
+
205
+ echo "Creating universal framework for platforms: ${platforms[*]}"
206
+
207
+ for i in "${!platforms[@]}"; do
208
+ local platform="${platforms[$i]}"
209
+ local hermes_framework_path="${platform}/hermes.framework"
210
+ args+="-framework $hermes_framework_path "
211
+ done
212
+
213
+ mkdir -p universal
214
+ # shellcheck disable=SC2086
215
+ if xcodebuild -create-xcframework $args -output "universal/hermes.xcframework"
216
+ then
217
+ # # Remove the thin iOS hermes.frameworks that are now part of the universal
218
+ # XCFramework
219
+ for platform in "${platforms[@]}"; do
220
+ rm -r "$platform"
221
+ done
222
+ fi
223
+
224
+ popd > /dev/null || exit 1
225
+ }
@@ -0,0 +1,100 @@
1
+ #!/bin/bash
2
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ #
4
+ # This source code is licensed under the MIT license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ set -x
8
+
9
+ release_version="$1"; shift
10
+ hermesc_path="$1"; shift
11
+ jsi_path="$1"; shift
12
+
13
+ # Based on platform name returns the framework copy destination. Used later by `vendored_frameworks` in Podspec.
14
+ # Fallbacks to "ios" if platform is not recognized.
15
+ function get_platform_copy_destination {
16
+ if [[ $1 == "macosx" ]]; then
17
+ echo "macosx"
18
+ return
19
+ elif [[ $1 == "xros" || $1 == "xrsimulator" ]]; then
20
+ echo "xros"
21
+ return
22
+ fi
23
+
24
+ echo "ios"
25
+ }
26
+
27
+ function get_deployment_target {
28
+ if [[ $1 == "macosx" ]]; then
29
+ echo "${MACOSX_DEPLOYMENT_TARGET}"
30
+ return
31
+ elif [[ $1 == "xrsimulator" || $1 == "xros" ]]; then
32
+ echo "${XROS_DEPLOYMENT_TARGET}"
33
+ return
34
+ fi
35
+
36
+ echo "${IPHONEOS_DEPLOYMENT_TARGET}"
37
+ }
38
+
39
+ enable_debugger="false"
40
+ if [[ "$CONFIGURATION" == "Debug" ]]; then
41
+ enable_debugger="true"
42
+ fi
43
+
44
+ cmake_build_type=""
45
+ if [[ $CONFIGURATION == "Debug" ]]; then
46
+ # JS developers aren't VM developers.
47
+ # Therefore we're passing as build type Release, to provide a faster build.
48
+ cmake_build_type="Release"
49
+ else
50
+ cmake_build_type="MinSizeRel"
51
+ fi
52
+
53
+ deployment_target=$(get_deployment_target $PLATFORM_NAME)
54
+
55
+ xcode_15_flags=""
56
+ xcode_major_version=$(xcodebuild -version | grep -oE '[0-9]*' | head -n 1)
57
+ if [[ $xcode_major_version -ge 15 ]]; then
58
+ echo "########### Using LINKER:-ld_classic ###########"
59
+ xcode_15_flags="LINKER:-ld_classic"
60
+ fi
61
+
62
+ architectures=$( echo "$ARCHS" | tr " " ";" )
63
+
64
+ echo "Configure Apple framework"
65
+
66
+ "$CMAKE_BINARY" \
67
+ -S "${PODS_ROOT}/hermes-engine" \
68
+ -B "${PODS_ROOT}/hermes-engine/build/${PLATFORM_NAME}" \
69
+ -DHERMES_EXTRA_LINKER_FLAGS="$xcode_15_flags" \
70
+ -DHERMES_APPLE_TARGET_PLATFORM:STRING="$PLATFORM_NAME" \
71
+ -DCMAKE_OSX_ARCHITECTURES:STRING="$architectures" \
72
+ -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="$deployment_target" \
73
+ -DHERMES_ENABLE_DEBUGGER:BOOLEAN="$enable_debugger" \
74
+ -DHERMES_ENABLE_INTL:BOOLEAN=true \
75
+ -DHERMES_ENABLE_LIBFUZZER:BOOLEAN=false \
76
+ -DHERMES_ENABLE_FUZZILLI:BOOLEAN=false \
77
+ -DHERMES_ENABLE_TEST_SUITE:BOOLEAN=false \
78
+ -DHERMES_ENABLE_BITCODE:BOOLEAN=false \
79
+ -DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=true \
80
+ -DHERMES_BUILD_SHARED_JSI:BOOLEAN=false \
81
+ -DHERMES_BUILD_APPLE_DSYM:BOOLEAN=true \
82
+ -DIMPORT_HERMESC:PATH="${hermesc_path}" \
83
+ -DJSI_DIR="$jsi_path" \
84
+ -DHERMES_RELEASE_VERSION="for RN $release_version" \
85
+ -DCMAKE_BUILD_TYPE="$cmake_build_type"
86
+
87
+ echo "Build Apple framework"
88
+
89
+ "$CMAKE_BINARY" \
90
+ --build "${PODS_ROOT}/hermes-engine/build/${PLATFORM_NAME}" \
91
+ --target libhermes \
92
+ -j "$(sysctl -n hw.ncpu)"
93
+
94
+ echo "Copy Apple framework to destroot/Library/Frameworks"
95
+
96
+ platform_copy_destination=$(get_platform_copy_destination $PLATFORM_NAME)
97
+
98
+ cp -pfR \
99
+ "${PODS_ROOT}/hermes-engine/build/${PLATFORM_NAME}/API/hermes/hermes.framework" \
100
+ "${PODS_ROOT}/hermes-engine/destroot/Library/Frameworks/${platform_copy_destination}"
@@ -0,0 +1,18 @@
1
+ #!/bin/bash
2
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ #
4
+ # This source code is licensed under the MIT license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ set -x -e
8
+
9
+ hermesc_dir_path="$1"; shift
10
+ jsi_path="$1"
11
+
12
+ # This script is supposed to be executed from Xcode "run script" phase.
13
+ # Xcode sets up its build environment based on the build target (iphone, iphonesimulator, macodsx).
14
+ # We want to make sure that hermesc is built for mac.
15
+ # So we clean the environment with env -i, and explicitly set SDKROOT to macosx
16
+ SDKROOT=$(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
17
+ env -i SDKROOT="$SDKROOT" "$CMAKE_BINARY" -S "${PODS_ROOT}/hermes-engine" -B "$hermesc_dir_path" -DJSI_DIR="$jsi_path"
18
+ env -i SDKROOT="$SDKROOT" "$CMAKE_BINARY" --build "$hermesc_dir_path" --target hermesc -j "$(sysctl -n hw.ncpu)"