From aaa01f77106f891696d9ec508e2ee71111a6af2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Thu, 12 May 2022 20:42:16 -0700 Subject: [PATCH] Hermes: Use prepare-hermes-for-build in CocoaPods (#33825) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/33825 Updates the CocoaPods build scripts to consume the prepare-hermes-for-build script, replacing the now redundant set of Ruby code that would previously set the filesystem up. Changelog: [iOS] [Changed] - When building Hermes from source, the filesystem will now be prepared using the new hermes-utils.js scripts, outside of CocoaPods Reviewed By: cortinico Differential Revision: D36336633 fbshipit-source-id: a4506db80c039529b14b0290d2f0b54fae78dcf2 --- scripts/react_native_pods.rb | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index ad2210b66cb..8ef86424cf4 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -102,9 +102,9 @@ def use_react_native! (options={}) end if hermes_enabled + system("(cd #{prefix} && node scripts/hermes/prepare-hermes-for-build)") pod 'React-hermes', :path => "#{prefix}/ReactCommon/hermes" - hermes_source_path = downloadAndConfigureHermesSource(prefix) - pod 'hermes-engine', :path => "#{hermes_source_path}/hermes-engine.podspec" + pod 'hermes-engine', :path => "#{prefix}/sdks/hermes/hermes-engine.podspec" pod 'libevent', '~> 2.1.12' end @@ -605,38 +605,6 @@ def use_react_native_codegen!(spec, options={}) } end -def downloadAndConfigureHermesSource(react_native_path) - hermes_tarball_base_url = "https://github.com/facebook/hermes/tarball/" - sdks_dir = "#{react_native_path}/sdks" - download_dir = "#{sdks_dir}/download" - hermes_dir = "#{sdks_dir}/hermes" - hermes_tag_file = "#{sdks_dir}/.hermesversion" - system("mkdir -p #{hermes_dir} #{download_dir}") - - if (File.exist?(hermes_tag_file)) - hermes_tag = File.read(hermes_tag_file).strip - else - hermes_tag = "main" - end - - hermes_tarball_url = hermes_tarball_base_url + hermes_tag - hermes_tag_sha = %x[git ls-remote https://github.com/facebook/hermes #{hermes_tag} | cut -f 1].strip - hermes_tarball_path = "#{download_dir}/hermes-#{hermes_tag_sha}.tar.gz" - - if (!File.exist?(hermes_tarball_path)) - Pod::UI.puts "[Hermes] Downloading Hermes source code..." - system("curl #{hermes_tarball_url} -Lo #{hermes_tarball_path}") - end - Pod::UI.puts "[Hermes] Extracting Hermes tarball (#{hermes_tag_sha.slice(0,6)})" - system("tar -zxf #{hermes_tarball_path} --strip-components=1 --directory #{hermes_dir}") - - # Use React Native's own scripts to build Hermes - system("cp #{sdks_dir}/hermes-engine/hermes-engine.podspec #{hermes_dir}/hermes-engine.podspec") - system("cp #{sdks_dir}/hermes-engine/utils/* #{hermes_dir}/utils/.") - - hermes_dir -end - # This provides a post_install workaround for build issues related Xcode 12.5 and Apple Silicon (M1) machines. # Call this in the app's main Podfile's post_install hook. # See https://github.com/facebook/react-native/issues/31480#issuecomment-902912841 for more context.