Store hermes stable artifacts inside Pods directory (#40733)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40733

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 https://github.com/facebook/react-native/issues/39903
Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D50081559

fbshipit-source-id: a130898e12fb6275cadaef7617bf4b6a09e6487e
This commit is contained in:
Dmitry Rykun 2023-10-09 08:26:05 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 60f5a80c1d
Коммит 12eef6ea57
4 изменённых файлов: 18 добавлений и 16 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -134,7 +134,6 @@ package-lock.json
# Additional SDKs # Additional SDKs
/packages/react-native/sdks/download /packages/react-native/sdks/download
/packages/react-native/sdks/downloads
/packages/react-native/sdks/hermes /packages/react-native/sdks/hermes
/packages/react-native/sdks/hermesc /packages/react-native/sdks/hermesc
/packages/react-native/sdks/hermes-engine/hermes-engine-from-local-source-dir.tar.gz /packages/react-native/sdks/hermes-engine/hermes-engine-from-local-source-dir.tar.gz

Просмотреть файл

@ -60,7 +60,7 @@ Pod::Spec.new do |spec|
:execution_position => :before_compile, :execution_position => :before_compile,
:script => <<-EOS :script => <<-EOS
. "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh" . "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
"$NODE_BINARY" "$REACT_NATIVE_PATH/sdks/hermes-engine/utils/replace_hermes_version.js" -c "$CONFIGURATION" -r "#{version}" -p "$REACT_NATIVE_PATH" "$NODE_BINARY" "$REACT_NATIVE_PATH/sdks/hermes-engine/utils/replace_hermes_version.js" -c "$CONFIGURATION" -r "#{version}" -p "$PODS_ROOT"
EOS EOS
} }
end end

Просмотреть файл

@ -125,7 +125,7 @@ def podspec_source_build_from_local_source_dir(react_native_path)
source_dir_path = ENV['REACT_NATIVE_OVERRIDE_HERMES_DIR'] source_dir_path = ENV['REACT_NATIVE_OVERRIDE_HERMES_DIR']
if Dir.exist?(source_dir_path) if Dir.exist?(source_dir_path)
hermes_log("Using source code from local path: #{source_dir_path}") hermes_log("Using source code from local path: #{source_dir_path}")
tarball_path = File.join(react_native_path, "sdks", "hermes-engine", "hermes-engine-from-local-source-dir.tar.gz") tarball_path = File.join(artifacts_dir(), "hermes-engine-from-local-source-dir.tar.gz")
exclude_paths = [ exclude_paths = [
"__tests__", "__tests__",
"./external/flowtest", "./external/flowtest",
@ -192,6 +192,10 @@ end
# HELPERS # HELPERS
def artifacts_dir()
return File.join(Pod::Config.instance.project_pods_root, "hermes-engine-artifacts")
end
def hermestag_file(react_native_path) def hermestag_file(react_native_path)
return File.join(react_native_path, "sdks", ".hermesversion") return File.join(react_native_path, "sdks", ".hermesversion")
end end
@ -208,15 +212,14 @@ def download_stable_hermes(react_native_path, version, configuration)
end end
def download_hermes_tarball(react_native_path, tarball_url, version, configuration) def download_hermes_tarball(react_native_path, tarball_url, version, configuration)
destination_folder = "#{react_native_path}/sdks/downloads"
destination_path = configuration == nil ? destination_path = configuration == nil ?
"#{destination_folder}/hermes-ios-#{version}.tar.gz" : "#{artifacts_dir()}/hermes-ios-#{version}.tar.gz" :
"#{destination_folder}/hermes-ios-#{version}-#{configuration}.tar.gz" "#{artifacts_dir()}/hermes-ios-#{version}-#{configuration}.tar.gz"
unless File.exist?(destination_path) unless File.exist?(destination_path)
# Download to a temporary file first so we don't cache incomplete downloads. # Download to a temporary file first so we don't cache incomplete downloads.
tmp_file = "#{destination_folder}/hermes-ios.download" tmp_file = "#{artifacts_dir()}/hermes-ios.download"
`mkdir -p "#{destination_folder}" && curl "#{tarball_url}" -Lo "#{tmp_file}" && mv "#{tmp_file}" "#{destination_path}"` `mkdir -p "#{artifacts_dir()}" && curl "#{tarball_url}" -Lo "#{tmp_file}" && mv "#{tmp_file}" "#{destination_path}"`
end end
return destination_path return destination_path
end end

Просмотреть файл

@ -52,8 +52,8 @@ function shouldReplaceHermesConfiguration(configuration) {
return true; return true;
} }
function replaceHermesConfiguration(configuration, version, reactNativePath) { function replaceHermesConfiguration(configuration, version, podsRoot) {
const tarballURLPath = `${reactNativePath}/sdks/downloads/hermes-ios-${version}-${configuration}.tar.gz`; const tarballURLPath = `${podsRoot}/hermes-engine-artifacts/hermes-ios-${version}-${configuration}.tar.gz`;
const finalLocation = 'hermes-engine'; const finalLocation = 'hermes-engine';
console.log('Preparing the final location'); console.log('Preparing the final location');
@ -68,7 +68,7 @@ function updateLastBuildConfiguration(configuration) {
fs.writeFileSync(LAST_BUILD_FILENAME, configuration); fs.writeFileSync(LAST_BUILD_FILENAME, configuration);
} }
function main(configuration, version, reactNativePath) { function main(configuration, version, podsRoot) {
validateBuildConfiguration(configuration); validateBuildConfiguration(configuration);
validateVersion(version); validateVersion(version);
@ -76,7 +76,7 @@ function main(configuration, version, reactNativePath) {
return; return;
} }
replaceHermesConfiguration(configuration, version, reactNativePath); replaceHermesConfiguration(configuration, version, podsRoot);
updateLastBuildConfiguration(configuration); updateLastBuildConfiguration(configuration);
console.log('Done replacing hermes-engine'); console.log('Done replacing hermes-engine');
} }
@ -94,13 +94,13 @@ const argv = yargs
'The Version of React Native associated with the Hermes tarball.', 'The Version of React Native associated with the Hermes tarball.',
}) })
.option('p', { .option('p', {
alias: 'reactNativePath', alias: 'podsRoot',
description: 'The path to the React Native root folder', description: 'The path to the Pods root folder',
}) })
.usage('Usage: $0 -c Debug -r <version> -p <path/to/react-native>').argv; .usage('Usage: $0 -c Debug -r <version> -p <path/to/react-native>').argv;
const configuration = argv.configuration; const configuration = argv.configuration;
const version = argv.reactNativeVersion; const version = argv.reactNativeVersion;
const reactNativePath = argv.reactNativePath; const podsRoot = argv.podsRoot;
main(configuration, version, reactNativePath); main(configuration, version, podsRoot);