Skip to content

Commit

Permalink
Hermes: Use prepare-hermes-for-build in CocoaPods (#33825)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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
  • Loading branch information
hramos authored and facebook-github-bot committed May 13, 2022
1 parent 6c2e34b commit aaa01f7
Showing 1 changed file with 2 additions and 34 deletions.
36 changes: 2 additions & 34 deletions scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit aaa01f7

Please sign in to comment.