Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove HERMES_BUILD_FROM_SOURCE flag #35397

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions scripts/cocoapods/__tests__/jsengine-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def setup
end

def teardown
ENV['HERMES_ENGINE_TARBALL_PATH'] = nil
Open3.reset()
Pod::Config.reset()
Pod::UI.reset()
Expand Down Expand Up @@ -119,4 +120,21 @@ def test_setupHermes_installsPods_installsFabricSubspecWhenFabricEnabled
assert_equal($podInvocation["React-hermes"][:path], "../../ReactCommon/hermes")
assert_equal($podInvocation["libevent"][:version], "~> 2.1.12")
end

# ================================= #
# TEST - isBuildingHermesFromSource #
# ================================= #
def test_isBuildingHermesFromSource_whenTarballIsNilAndVersionIsNotNightly_returnTrue
assert_true(is_building_hermes_from_source("1000.0.0"))
end

def test_isBuildingHermesFromSource_whenTarballIsNotNil_returnFalse
ENV['HERMES_ENGINE_TARBALL_PATH'] = "~/Downloads/hermes-ios-debug.tar.gz"
assert_false(is_building_hermes_from_source("1000.0.0"))
end

def test_isBuildingHermesFromSource_whenIsNigthly_returnsFalse
assert_false(is_building_hermes_from_source("0.0.0-"))
end

end
12 changes: 12 additions & 0 deletions scripts/cocoapods/jsengine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,15 @@ def remove_copy_hermes_framework_script_phase(installer, react_native_path)
def remove_hermesc_build_dir(react_native_path)
%x(rm -rf #{react_native_path}/sdks/hermes-engine/build_host_hermesc)
end

def is_building_hermes_from_source(react_native_version)
is_nightly = react_native_version.start_with?('0.0.0-')
has_tarball = ENV['HERMES_ENGINE_TARBALL_PATH'] != nil

# this is the same logic in the hermes-engine.podspec
if has_tarball || is_nightly
return false
end

return true
end
5 changes: 4 additions & 1 deletion scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ def react_native_post_install(installer, react_native_path = "../node_modules/re
flipper_post_install(installer)
end

if ReactNativePodsUtils.has_pod(installer, 'hermes-engine') && ENV['HERMES_BUILD_FROM_SOURCE'] == "1"
package = JSON.parse(File.read(File.join(react_native_path, "package.json")))
version = package['version']

if ReactNativePodsUtils.has_pod(installer, 'hermes-engine') && is_building_hermes_from_source(version)
add_copy_hermes_framework_script_phase(installer, react_native_path)
else
remove_copy_hermes_framework_script_phase(installer, react_native_path)
Expand Down
3 changes: 1 addition & 2 deletions sdks/hermes-engine/hermes-engine.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ Pod::Spec.new do |spec|

elsif source[:git] then

ENV['HERMES_BUILD_FROM_SOURCE'] = "1"

spec.subspec 'Hermes' do |ss|
ss.source_files = ''
ss.public_header_files = 'API/hermes/*.h'
Expand All @@ -108,6 +106,7 @@ Pod::Spec.new do |spec|
# Keep hermesc_path synchronized with .gitignore entry.
ENV['REACT_NATIVE_PATH'] = react_native_path
hermesc_path = "${REACT_NATIVE_PATH}/sdks/hermes-engine/build_host_hermesc"
# NOTE: Prepare command is not run if the pod is not downloaded.
spec.prepare_command = ". #{react_native_path}/sdks/hermes-engine/utils/build-hermesc-xcode.sh #{hermesc_path}"
end

Expand Down