Skip to content

Commit 67d0264

Browse files
Riccardo Cipolleschifacebook-github-bot
authored andcommitted
Use the right logic to decide when we build Hermes from source (#35469)
Summary: This PR backports the changes in 0.71 to apply the same logic to decide when we have to build Hermes from source in both the `hermes-engine.podspec` and in the `react_native_pods.rb` script. ## Changelog [iOS] [Fixed] - Use the right logic to decide when we have to build from source Pull Request resolved: #35469 Test Plan: Working on RC2 Reviewed By: cortinico Differential Revision: D41529539 Pulled By: cipolleschi fbshipit-source-id: 879522c2187df28f40f6bc699057e9ecfb7e25fb
1 parent 2d1d61a commit 67d0264

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

scripts/cocoapods/__tests__/jsengine-test.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ class JSEngineTests < Test::Unit::TestCase
1414
:react_native_path
1515

1616
def setup
17+
File.enable_testing_mode!
1718
@react_native_path = "../.."
1819
podSpy_cleanUp()
20+
1921
end
2022

2123
def teardown
@@ -25,6 +27,8 @@ def teardown
2527
Pod::UI.reset()
2628
podSpy_cleanUp()
2729
ENV['USE_HERMES'] = '1'
30+
ENV['CI'] = nil
31+
File.reset()
2832
end
2933

3034
# =============== #
@@ -125,16 +129,26 @@ def test_setupHermes_installsPods_installsFabricSubspecWhenFabricEnabled
125129
# TEST - isBuildingHermesFromSource #
126130
# ================================= #
127131
def test_isBuildingHermesFromSource_whenTarballIsNilAndVersionIsNotNightly_returnTrue
128-
assert_true(is_building_hermes_from_source("1000.0.0"))
132+
assert_true(is_building_hermes_from_source("1000.0.0", '../..'))
133+
end
134+
135+
def test_isBuildingHermesFromSource_whenTarballIsNilAndInReleaseBranch_returnTrue
136+
ENV['CI'] = 'true'
137+
File.mocked_existing_files(['../../sdks/.hermesversion'])
138+
assert_true(is_building_hermes_from_source("0.999.0", '../..'))
129139
end
130140

131141
def test_isBuildingHermesFromSource_whenTarballIsNotNil_returnFalse
132142
ENV['HERMES_ENGINE_TARBALL_PATH'] = "~/Downloads/hermes-ios-debug.tar.gz"
133-
assert_false(is_building_hermes_from_source("1000.0.0"))
143+
assert_false(is_building_hermes_from_source("1000.0.0", '../..'))
134144
end
135145

136146
def test_isBuildingHermesFromSource_whenIsNigthly_returnsFalse
137-
assert_false(is_building_hermes_from_source("0.0.0-"))
147+
assert_false(is_building_hermes_from_source("0.0.0-", '../..'))
148+
end
149+
150+
def test_isBuildingHermesFromSource_whenIsStbleRelease_returnsFalse
151+
assert_false(is_building_hermes_from_source("0.71.0", '../..'))
138152
end
139153

140154
end

scripts/cocoapods/jsengine.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,19 @@ def remove_copy_hermes_framework_script_phase(installer, react_native_path)
6060
project.save()
6161
end
6262

63-
def is_building_hermes_from_source(react_native_version)
64-
is_nightly = react_native_version.start_with?('0.0.0-')
65-
has_tarball = ENV['HERMES_ENGINE_TARBALL_PATH'] != nil
66-
67-
# this is the same logic in the hermes-engine.podspec
68-
if has_tarball || is_nightly
63+
# TODO: Use this same function in the `hermes-engine.podspec` somehow
64+
def is_building_hermes_from_source(react_native_version, react_native_path)
65+
if ENV['HERMES_ENGINE_TARBALL_PATH'] != nil
6966
return false
7067
end
7168

72-
return true
69+
isInMain = react_native_version.include?('1000.0.0')
70+
71+
hermestag_file = File.join(react_native_path, "sdks", ".hermesversion")
72+
isInCI = ENV['CI'] === 'true'
73+
74+
isReleaseBranch = File.exist?(hermestag_file) && isInCI
75+
76+
77+
return isInMain || isReleaseBranch
7378
end

scripts/react_native_pods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def react_native_post_install(installer, react_native_path = "../node_modules/re
205205
package = JSON.parse(File.read(File.join(react_native_path, "package.json")))
206206
version = package['version']
207207

208-
if ReactNativePodsUtils.has_pod(installer, 'hermes-engine') && is_building_hermes_from_source(version)
208+
if ReactNativePodsUtils.has_pod(installer, 'hermes-engine') && is_building_hermes_from_source(version, react_native_path)
209209
add_copy_hermes_framework_script_phase(installer, react_native_path)
210210
else
211211
remove_copy_hermes_framework_script_phase(installer, react_native_path)

0 commit comments

Comments
 (0)