Skip to content

Commit

Permalink
Download Hermes tarball during pod install
Browse files Browse the repository at this point in the history
Summary:
Downloads a tarball of the Hermes source code when `pod install` is run.

If the current release is pinned to a Hermes tag, it will use that specific tag, otherwise the latest Hermes commit will be used.

# Changelog:
[Internal]

Reviewed By: cortinico

Differential Revision: D34629595

fbshipit-source-id: 5f36af4a43bc2d137dfd702082558ab9d0191140
  • Loading branch information
hramos authored and facebook-github-bot committed Mar 10, 2022
1 parent 52aee50 commit 889578a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ package-lock.json
# OS X
.DS_Store

# Hermes
/sdks/hermes
/sdks/download

# Test generated files
/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
*.js.meta
Expand Down Expand Up @@ -116,6 +112,11 @@ package-lock.json
/ReactCommon/react/renderer/components/rncore/
/packages/rn-tester/NativeModuleExample/ScreenshotManagerSpec*

# Additional SDKs
/sdks/.hermesversion
/sdks/hermes
/sdks/download

# Visual studio
.vscode
.vs
Expand Down
25 changes: 24 additions & 1 deletion scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def use_react_native! (options={})
pod 'React-hermes', :path => "#{prefix}/ReactCommon/hermes"

if ENV['BUILD_HERMES_SOURCE'] == '1'
hermes_source_path = locatePathToHermesSource!(prefix)
hermes_source_path = downloadAndConfigureHermesSource(prefix)
pod 'hermes-engine', :path => "#{hermes_source_path}/hermes-engine.podspec"
else
pod 'hermes-engine', '~> 0.11.0'
Expand Down Expand Up @@ -629,6 +629,29 @@ 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"
tarball_path = "#{download_dir}/hermes.tar.gz"

system("mkdir -p #{hermes_dir} #{download_dir}")

if(File.exist?(hermes_tag_file))
hermes_tag = file_data = File.read(hermes_tag_file).strip
hermes_tarball_url = hermes_tarball_base_url + hermes_tag
else
hermes_tarball_url = hermes_tarball_base_url + "main"
end

system("wget --timestamping -O #{tarball_path} #{hermes_tarball_url}")
system("tar -xzf #{tarball_path} --strip-components=1 -C #{hermes_dir}")

hermes_dir
end

def locatePathToHermesSource!(react_native_path)
return if ENV['BUILD_HERMES_SOURCE'] != '1'

Expand Down

0 comments on commit 889578a

Please sign in to comment.