Skip to content

Commit

Permalink
[LOCAL] Use the right logic for build from source
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo Cipolleschi committed Nov 24, 2022
1 parent 0d90a44 commit 49c0267
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
20 changes: 17 additions & 3 deletions scripts/cocoapods/__tests__/jsengine-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ class JSEngineTests < Test::Unit::TestCase
:react_native_path

def setup
File.enable_testing_mode!
@react_native_path = "../.."
podSpy_cleanUp()

end

def teardown
Expand All @@ -25,6 +27,8 @@ def teardown
Pod::UI.reset()
podSpy_cleanUp()
ENV['USE_HERMES'] = '1'
ENV['CI'] = nil
File.reset()
end

# =============== #
Expand Down Expand Up @@ -125,16 +129,26 @@ def test_setupHermes_installsPods_installsFabricSubspecWhenFabricEnabled
# TEST - isBuildingHermesFromSource #
# ================================= #
def test_isBuildingHermesFromSource_whenTarballIsNilAndVersionIsNotNightly_returnTrue
assert_true(is_building_hermes_from_source("1000.0.0"))
assert_true(is_building_hermes_from_source("1000.0.0", '../..'))
end

def test_isBuildingHermesFromSource_whenTarballIsNilAndInReleaseBranch_returnTrue
ENV['CI'] = 'true'
File.mocked_existing_files(['../../sdks/.hermesversion'])
assert_true(is_building_hermes_from_source("0.999.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"))
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-"))
assert_false(is_building_hermes_from_source("0.0.0-", '../..'))
end

def test_isBuildingHermesFromSource_whenIsStbleRelease_returnsFalse
assert_false(is_building_hermes_from_source("0.71.0", '../..'))
end

end
7 changes: 6 additions & 1 deletion scripts/cocoapods/jsengine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,17 @@ def remove_hermesc_build_dir(react_native_path)
end

def is_building_hermes_from_source(react_native_version, react_native_path)
if ENV['HERMES_ENGINE_TARBALL_PATH'] != nil
return false
end

isInMain = react_native_version.include?('1000.0.0')

hermestag_file = File.join(react_native_path, "sdks", ".hermesversion")
isInCI = ENV['CI'] === 'true'

isReleaseBranch = File.exists?(hermestag_file) && isInCI
isReleaseBranch = File.exist?(hermestag_file) && isInCI


return isInMain || isReleaseBranch
end
2 changes: 1 addition & 1 deletion scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def react_native_post_install(installer, react_native_path = "../node_modules/re
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)
if ReactNativePodsUtils.has_pod(installer, 'hermes-engine') && is_building_hermes_from_source(version, react_native_path)
add_copy_hermes_framework_script_phase(installer, react_native_path)
else
remove_copy_hermes_framework_script_phase(installer, react_native_path)
Expand Down

0 comments on commit 49c0267

Please sign in to comment.