react-native-macos 0.78.5 → 0.78.6
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.
- package/Libraries/AppDelegate/RCTReactNativeFactory.mm +4 -0
- package/Libraries/Blob/RCTBlobManager.h +0 -0
- package/Libraries/Blob/RCTBlobManager.mm +0 -0
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +0 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/StyleSheet/normalizeColor.js +0 -0
- package/React/Base/RCTJavaScriptLoader.h +0 -0
- package/React/Base/RCTJavaScriptLoader.mm +0 -0
- package/React/Base/RCTVersion.m +1 -1
- package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +18 -4
- package/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm +1 -1
- package/React/Fabric/Surface/RCTFabricSurface.mm +1 -0
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/style/BorderRadiusStyle.kt +2 -2
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/react/runtime/TimerManager.cpp +6 -4
- package/ReactCommon/react/runtime/TimerManager.h +3 -1
- package/ReactCommon/react/runtime/tests/cxx/ReactInstanceTest.cpp +9 -5
- package/local-cli/cli.js +0 -0
- package/package.json +10 -10
- package/scripts/cocoapods/autolinking.rb +206 -0
- package/scripts/cocoapods/autolinking_utils.rb +25 -0
- package/scripts/cocoapods/codegen.rb +59 -0
- package/scripts/cocoapods/codegen_script_phase_extractor.rb +13 -0
- package/scripts/cocoapods/codegen_utils.rb +389 -0
- package/scripts/cocoapods/fabric.rb +18 -0
- package/scripts/cocoapods/helpers.rb +150 -0
- package/scripts/cocoapods/jsengine.rb +33 -0
- package/scripts/cocoapods/local_podspec_patch.rb +51 -0
- package/scripts/cocoapods/new_architecture.rb +194 -0
- package/scripts/cocoapods/privacy_manifest_utils.rb +194 -0
- package/scripts/cocoapods/runtime.rb +18 -0
- package/scripts/cocoapods/spm.rb +94 -0
- package/scripts/cocoapods/utils.rb +730 -0
- package/scripts/codegen/codegen-utils.js +51 -0
- package/scripts/codegen/generate-artifacts-executor.js +1013 -0
- package/scripts/codegen/generate-specs-cli-executor.js +128 -0
- package/scripts/codegen/templates/RCTAppDependencyProviderH.template +25 -0
- package/scripts/codegen/templates/RCTAppDependencyProviderMM.template +55 -0
- package/scripts/codegen/templates/RCTModulesConformingToProtocolsProviderH.template +18 -0
- package/scripts/codegen/templates/RCTModulesConformingToProtocolsProviderMM.template +33 -0
- package/scripts/codegen/templates/RCTThirdPartyComponentsProviderH.template +16 -0
- package/scripts/codegen/templates/RCTThirdPartyComponentsProviderMM.template +23 -0
- package/scripts/codegen/templates/ReactAppDependencyProvider.podspec.template +34 -0
- package/scripts/compose-source-maps.js +0 -0
- package/scripts/ios-configure-glog.sh +0 -0
- package/scripts/node-binary.sh +0 -0
- package/scripts/packager.sh +0 -0
- package/scripts/react-native-xcode.sh +0 -0
- package/scripts/react_native_pods_utils/script_phases.sh +0 -0
- package/scripts/xcode/ccache-clang++.sh +0 -0
- package/scripts/xcode/ccache-clang.sh +0 -0
- package/scripts/xcode/with-environment.sh +0 -0
- package/sdks/hermes-engine/hermes-engine.podspec +168 -0
- package/sdks/hermes-engine/hermes-utils.rb +341 -0
- package/sdks/hermes-engine/utils/build-apple-framework.sh +225 -0
- package/sdks/hermes-engine/utils/build-hermes-xcode.sh +100 -0
- package/sdks/hermes-engine/utils/build-hermesc-xcode.sh +18 -0
- package/sdks/hermes-engine/utils/build-ios-framework.sh +90 -0
- package/sdks/hermes-engine/utils/build-mac-framework.sh +22 -0
- package/sdks/hermes-engine/utils/copy-hermes-xcode.sh +7 -0
- package/sdks/hermes-engine/utils/create-dummy-hermes-xcframework.sh +32 -0
- package/sdks/hermes-engine/utils/replace_hermes_version.js +106 -0
- package/scripts/featureflags/README.md +0 -156
- package/scripts/featureflags/index.js +0 -39
|
@@ -0,0 +1,341 @@
|
|
|
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_dir_path = artifacts_dir()
|
|
133
|
+
FileUtils.mkdir_p(tarball_dir_path) unless Dir.exist?(tarball_dir_path)
|
|
134
|
+
tarball_path = File.join(tarball_dir_path, "hermes-engine-from-local-source-dir.tar.gz")
|
|
135
|
+
exclude_paths = [
|
|
136
|
+
"__tests__",
|
|
137
|
+
"./external/flowtest",
|
|
138
|
+
"./external/esprima/test_fixtures"
|
|
139
|
+
]
|
|
140
|
+
.map {|path| "--exclude=#{path}"}
|
|
141
|
+
.join(' ')
|
|
142
|
+
tar_command = "tar #{exclude_paths} -czvf #{tarball_path} -C #{source_dir_path} . 2> /dev/null"
|
|
143
|
+
success = system(tar_command)
|
|
144
|
+
if !success
|
|
145
|
+
abort "Failed to create a tarball with the contents of \"#{source_dir_path}\""
|
|
146
|
+
end
|
|
147
|
+
return {:http => "file://#{tarball_path}"}
|
|
148
|
+
else
|
|
149
|
+
abort <<-EOS
|
|
150
|
+
[Hermes] REACT_NATIVE_OVERRIDE_HERMES_DIR is set, but points to a non-existing directory: \"#{source_dir_path}\"
|
|
151
|
+
If you don't want to use local source, run `unset REACT_NATIVE_OVERRIDE_HERMES_DIR`
|
|
152
|
+
EOS
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def podspec_source_local_prebuilt_tarball()
|
|
157
|
+
tarball_path = ENV['HERMES_ENGINE_TARBALL_PATH']
|
|
158
|
+
if File.exist?(tarball_path)
|
|
159
|
+
hermes_log("Using pre-built binary from local path defined by HERMES_ENGINE_TARBALL_PATH envvar: #{tarball_path}")
|
|
160
|
+
return {:http => "file://#{tarball_path}"}
|
|
161
|
+
end
|
|
162
|
+
abort <<-EOS
|
|
163
|
+
[Hermes] HERMES_ENGINE_TARBALL_PATH is set, but points to a non-existing file: \"#{tarball_path}\"
|
|
164
|
+
If you don't want to use tarball, run `unset HERMES_ENGINE_TARBALL_PATH`
|
|
165
|
+
EOS
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def podspec_source_build_from_github_commit()
|
|
169
|
+
commit = ENV['HERMES_COMMIT']
|
|
170
|
+
hermes_log("Using commit defined by HERMES_COMMIT envvar: #{commit}")
|
|
171
|
+
return {:git => HERMES_GITHUB_URL, :commit => commit}
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def podspec_source_build_from_github_tag(react_native_path)
|
|
175
|
+
tag = File.read(hermestag_file(react_native_path)).strip
|
|
176
|
+
hermes_log("Using tag difined in sdks/.hermesversion: #{tag}")
|
|
177
|
+
return {:git => HERMES_GITHUB_URL, :tag => tag}
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def podspec_source_build_from_github_main()
|
|
181
|
+
# hermes_log("Using the latest commit from main.")
|
|
182
|
+
# return {:git => HERMES_GITHUB_URL, :commit => `git ls-remote #{HERMES_GITHUB_URL} main | cut -f 1`.strip}
|
|
183
|
+
|
|
184
|
+
# [macOS
|
|
185
|
+
# The logic for this is a bit different on macOS.
|
|
186
|
+
# Since react-native-macos lags slightly behind facebook/react-native, we can't always use
|
|
187
|
+
# the latest Hermes commit because Hermes and JSI don't always guarantee backwards compatibility.
|
|
188
|
+
# Instead, we take the commit hash of Hermes at the time of the merge base with facebook/react-native.
|
|
189
|
+
commit = hermes_commit_at_merge_base()
|
|
190
|
+
hermes_log("Using Hermes commit from the merge base with facebook/react-native: #{commit}")
|
|
191
|
+
return {:git => HERMES_GITHUB_URL, :commit => commit}
|
|
192
|
+
# macOS]
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def podspec_source_download_prebuild_release_tarball(react_native_path, version)
|
|
196
|
+
url = release_tarball_url(version, :debug)
|
|
197
|
+
hermes_log("Using release tarball from URL: #{url}")
|
|
198
|
+
download_stable_hermes(react_native_path, version, :debug)
|
|
199
|
+
download_stable_hermes(react_native_path, version, :release)
|
|
200
|
+
return {:http => url}
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def podspec_source_download_prebuilt_nightly_tarball(version)
|
|
204
|
+
url = nightly_tarball_url(version)
|
|
205
|
+
hermes_log("Using nightly tarball from URL: #{url}")
|
|
206
|
+
return {:http => url}
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# HELPERS
|
|
210
|
+
|
|
211
|
+
def artifacts_dir()
|
|
212
|
+
return File.join(Pod::Config.instance.project_pods_root, "hermes-engine-artifacts")
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# [macOS
|
|
216
|
+
def hermes_commit_at_merge_base()
|
|
217
|
+
# We don't need ls-remote because react-native-macos is a fork of facebook/react-native
|
|
218
|
+
fetch_result = `git fetch -q https://github.com/facebook/react-native.git`
|
|
219
|
+
if $?.exitstatus != 0
|
|
220
|
+
abort <<-EOS
|
|
221
|
+
[Hermes] Failed to fetch facebook/react-native into the local repository.
|
|
222
|
+
EOS
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
merge_base = `git merge-base FETCH_HEAD HEAD`.strip
|
|
226
|
+
if merge_base.empty?
|
|
227
|
+
abort <<-EOS
|
|
228
|
+
[Hermes] Unable to find the merge base between our HEAD and upstream's HEAD.
|
|
229
|
+
EOS
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
timestamp = `git show -s --format=%ci #{merge_base}`.strip
|
|
233
|
+
if timestamp.empty?
|
|
234
|
+
abort <<-EOS
|
|
235
|
+
[Hermes] Unable to extract the timestamp for the merge base (#{merge_base}).
|
|
236
|
+
EOS
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
commit = nil
|
|
240
|
+
Dir.mktmpdir do |tmpdir|
|
|
241
|
+
hermes_git_dir = File.join(tmpdir, "hermes.git")
|
|
242
|
+
# Unfortunately we can't use git rev-list on HERMES_GITHUB_URL directly since we're not in that repo.
|
|
243
|
+
# Instead, we create a shallow clone to avoid downloading the entire history.
|
|
244
|
+
`git clone -q --bare --shallow-since="#{timestamp}" #{HERMES_GITHUB_URL} "#{hermes_git_dir}"`
|
|
245
|
+
`git --git-dir="#{hermes_git_dir}" fetch -q --deepen=1`
|
|
246
|
+
|
|
247
|
+
# If all goes well, this will be the commit hash of Hermes at the time of the merge base
|
|
248
|
+
commit = `git --git-dir="#{hermes_git_dir}" rev-list -1 --before="#{timestamp}" HEAD`.strip
|
|
249
|
+
if commit.empty?
|
|
250
|
+
abort <<-EOS
|
|
251
|
+
[Hermes] Unable to find the Hermes commit hash at time #{timestamp}.
|
|
252
|
+
EOS
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
return commit
|
|
257
|
+
end
|
|
258
|
+
# macOS]
|
|
259
|
+
|
|
260
|
+
def hermestag_file(react_native_path)
|
|
261
|
+
return File.join(react_native_path, "sdks", ".hermesversion")
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def release_tarball_url(version, build_type)
|
|
265
|
+
maven_repo_url = "https://repo1.maven.org/maven2"
|
|
266
|
+
namespace = "com/facebook/react"
|
|
267
|
+
# Sample url from Maven:
|
|
268
|
+
# 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
|
|
269
|
+
return "#{maven_repo_url}/#{namespace}/react-native-artifacts/#{version}/react-native-artifacts-#{version}-hermes-ios-#{build_type.to_s}.tar.gz"
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def download_stable_hermes(react_native_path, version, configuration)
|
|
273
|
+
tarball_url = release_tarball_url(version, configuration)
|
|
274
|
+
download_hermes_tarball(react_native_path, tarball_url, version, configuration)
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def download_hermes_tarball(react_native_path, tarball_url, version, configuration)
|
|
278
|
+
destination_path = configuration == nil ?
|
|
279
|
+
"#{artifacts_dir()}/hermes-ios-#{version}.tar.gz" :
|
|
280
|
+
"#{artifacts_dir()}/hermes-ios-#{version}-#{configuration}.tar.gz"
|
|
281
|
+
|
|
282
|
+
unless File.exist?(destination_path)
|
|
283
|
+
# Download to a temporary file first so we don't cache incomplete downloads.
|
|
284
|
+
tmp_file = "#{artifacts_dir()}/hermes-ios.download"
|
|
285
|
+
`mkdir -p "#{artifacts_dir()}" && curl "#{tarball_url}" -Lo "#{tmp_file}" && mv "#{tmp_file}" "#{destination_path}"`
|
|
286
|
+
end
|
|
287
|
+
return destination_path
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
def nightly_tarball_url(version)
|
|
291
|
+
params = "r=snapshots\&g=com.facebook.react\&a=react-native-artifacts\&c=hermes-ios-debug\&e=tar.gz\&v=#{version}-SNAPSHOT"
|
|
292
|
+
return resolve_url_redirects("http://oss.sonatype.org/service/local/artifact/maven/redirect\?#{params}")
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
def resolve_url_redirects(url)
|
|
296
|
+
return (`curl -Ls -o /dev/null -w %{url_effective} \"#{url}\"`)
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
# [macOS
|
|
300
|
+
# Tries to find a suitable Hermes version for a given react-native-macos package.
|
|
301
|
+
# For stable branches, we prefer this to be specified as a peer dependency.
|
|
302
|
+
def findMatchingHermesVersion(package)
|
|
303
|
+
if package['version'] == "1000.0.0"
|
|
304
|
+
# The main branch builds from source, so skip this check
|
|
305
|
+
return nil
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
if package['peerDependencies']
|
|
309
|
+
return package['peerDependencies']['react-native']
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
hermes_log("No matching Hermes version found. Defaulting to main branch, which may be unreliable.")
|
|
313
|
+
end
|
|
314
|
+
# macOS]
|
|
315
|
+
|
|
316
|
+
# This function checks that Hermes artifact exists.
|
|
317
|
+
# As of now it should check it on the Maven repo.
|
|
318
|
+
#
|
|
319
|
+
# Parameters
|
|
320
|
+
# - version: the version of React Native
|
|
321
|
+
# - build_type: debug or release
|
|
322
|
+
def hermes_artifact_exists(tarball_url)
|
|
323
|
+
# -L is used to follow redirects, useful for the nightlies
|
|
324
|
+
# I also needed to wrap the url in quotes to avoid escaping & and ?.
|
|
325
|
+
return (`curl -o /dev/null --silent -Iw '%{http_code}' -L "#{tarball_url}"` == "200")
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
def hermes_log(message, level = :warning)
|
|
329
|
+
if !Object.const_defined?("Pod::UI")
|
|
330
|
+
return
|
|
331
|
+
end
|
|
332
|
+
hermes_log_messgae = '[Hermes] ' + message
|
|
333
|
+
case level
|
|
334
|
+
when :info
|
|
335
|
+
Pod::UI.puts hermes_log_messgae.green
|
|
336
|
+
when :error
|
|
337
|
+
Pod::UI.puts hermes_log_messgae.red
|
|
338
|
+
else
|
|
339
|
+
Pod::UI.puts hermes_log_messgae.yellow
|
|
340
|
+
end
|
|
341
|
+
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" "appletvos" "appletvsimulator")
|
|
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 -e
|
|
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)"
|