Skip to content

Commit 1ebb0d7

Browse files
dmytrorykunfacebook-github-bot
authored andcommitted
Store hermes stable artifacts inside Pods directory
Summary: Node package managers may purge or recreate `node_modules/react-native` when adding/removenf project dependencies. Storing hermes iOS artifacts inside `node_modules/react-native/sdks` is not reliable. This diff moves those artifacts to `Pods/hermes-engine-artifacts`. Should fix facebook#39903 Changelog: [Internal] Differential Revision: D50081559
1 parent 60f5a80 commit 1ebb0d7

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ package-lock.json
134134

135135
# Additional SDKs
136136
/packages/react-native/sdks/download
137-
/packages/react-native/sdks/downloads
138137
/packages/react-native/sdks/hermes
139138
/packages/react-native/sdks/hermesc
140139
/packages/react-native/sdks/hermes-engine/hermes-engine-from-local-source-dir.tar.gz

packages/react-native/sdks/hermes-engine/hermes-engine.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Pod::Spec.new do |spec|
6060
:execution_position => :before_compile,
6161
:script => <<-EOS
6262
. "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
63-
"$NODE_BINARY" "$REACT_NATIVE_PATH/sdks/hermes-engine/utils/replace_hermes_version.js" -c "$CONFIGURATION" -r "#{version}" -p "$REACT_NATIVE_PATH"
63+
"$NODE_BINARY" "$REACT_NATIVE_PATH/sdks/hermes-engine/utils/replace_hermes_version.js" -c "$CONFIGURATION" -r "#{version}" -p "$PODS_ROOT"
6464
EOS
6565
}
6666
end

packages/react-native/sdks/hermes-engine/hermes-utils.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def podspec_source_build_from_local_source_dir(react_native_path)
125125
source_dir_path = ENV['REACT_NATIVE_OVERRIDE_HERMES_DIR']
126126
if Dir.exist?(source_dir_path)
127127
hermes_log("Using source code from local path: #{source_dir_path}")
128-
tarball_path = File.join(react_native_path, "sdks", "hermes-engine", "hermes-engine-from-local-source-dir.tar.gz")
128+
tarball_path = File.join(artifacts_dir(), "hermes-engine-from-local-source-dir.tar.gz")
129129
exclude_paths = [
130130
"__tests__",
131131
"./external/flowtest",
@@ -192,6 +192,10 @@ def podspec_source_download_prebuilt_nightly_tarball(version)
192192

193193
# HELPERS
194194

195+
def artifacts_dir()
196+
return File.join(Pod::Config.instance.project_pods_root, "hermes-engine-artifacts")
197+
end
198+
195199
def hermestag_file(react_native_path)
196200
return File.join(react_native_path, "sdks", ".hermesversion")
197201
end
@@ -208,15 +212,14 @@ def download_stable_hermes(react_native_path, version, configuration)
208212
end
209213

210214
def download_hermes_tarball(react_native_path, tarball_url, version, configuration)
211-
destination_folder = "#{react_native_path}/sdks/downloads"
212215
destination_path = configuration == nil ?
213-
"#{destination_folder}/hermes-ios-#{version}.tar.gz" :
214-
"#{destination_folder}/hermes-ios-#{version}-#{configuration}.tar.gz"
216+
"#{artifacts_dir()}/hermes-ios-#{version}.tar.gz" :
217+
"#{artifacts_dir()}/hermes-ios-#{version}-#{configuration}.tar.gz"
215218

216219
unless File.exist?(destination_path)
217220
# Download to a temporary file first so we don't cache incomplete downloads.
218-
tmp_file = "#{destination_folder}/hermes-ios.download"
219-
`mkdir -p "#{destination_folder}" && curl "#{tarball_url}" -Lo "#{tmp_file}" && mv "#{tmp_file}" "#{destination_path}"`
221+
tmp_file = "#{artifacts_dir()}/hermes-ios.download"
222+
`mkdir -p "#{artifacts_dir()}" && curl "#{tarball_url}" -Lo "#{tmp_file}" && mv "#{tmp_file}" "#{destination_path}"`
220223
end
221224
return destination_path
222225
end

packages/react-native/sdks/hermes-engine/utils/replace_hermes_version.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ function shouldReplaceHermesConfiguration(configuration) {
5252
return true;
5353
}
5454

55-
function replaceHermesConfiguration(configuration, version, reactNativePath) {
56-
const tarballURLPath = `${reactNativePath}/sdks/downloads/hermes-ios-${version}-${configuration}.tar.gz`;
55+
function replaceHermesConfiguration(configuration, version, podsRoot) {
56+
const tarballURLPath = `${podsRoot}/hermes-engine-artifacts/hermes-ios-${version}-${configuration}.tar.gz`;
5757

5858
const finalLocation = 'hermes-engine';
5959
console.log('Preparing the final location');
@@ -68,15 +68,15 @@ function updateLastBuildConfiguration(configuration) {
6868
fs.writeFileSync(LAST_BUILD_FILENAME, configuration);
6969
}
7070

71-
function main(configuration, version, reactNativePath) {
71+
function main(configuration, version, podsRoot) {
7272
validateBuildConfiguration(configuration);
7373
validateVersion(version);
7474

7575
if (!shouldReplaceHermesConfiguration(configuration)) {
7676
return;
7777
}
7878

79-
replaceHermesConfiguration(configuration, version, reactNativePath);
79+
replaceHermesConfiguration(configuration, version, podsRoot);
8080
updateLastBuildConfiguration(configuration);
8181
console.log('Done replacing hermes-engine');
8282
}
@@ -94,13 +94,13 @@ const argv = yargs
9494
'The Version of React Native associated with the Hermes tarball.',
9595
})
9696
.option('p', {
97-
alias: 'reactNativePath',
98-
description: 'The path to the React Native root folder',
97+
alias: 'podsRoot',
98+
description: 'The path to the Pods root folder',
9999
})
100100
.usage('Usage: $0 -c Debug -r <version> -p <path/to/react-native>').argv;
101101

102102
const configuration = argv.configuration;
103103
const version = argv.reactNativeVersion;
104-
const reactNativePath = argv.reactNativePath;
104+
const podsRoot = argv.podsRoot;
105105

106-
main(configuration, version, reactNativePath);
106+
main(configuration, version, podsRoot);

0 commit comments

Comments
 (0)