diff --git a/scripts/cocoapods/__tests__/hermes-test.rb b/scripts/cocoapods/__tests__/hermes-test.rb index a69bb29d1ee4d5..64562ec5d22d7d 100644 --- a/scripts/cocoapods/__tests__/hermes-test.rb +++ b/scripts/cocoapods/__tests__/hermes-test.rb @@ -22,7 +22,6 @@ def teardown Pod::Config.reset() Pod::UI.reset() podSpy_cleanUp() - ENV['PRODUCTION'] = '0' end # ============================= # @@ -84,55 +83,4 @@ def test_installHermesIfEnabled_whenHermesIsEnabledAndHermesScriptSucceeds_insta assert_equal($podInvocation["libevent"][:version], "~> 2.1.12") assert_equal($podInvocation["hermes-engine"][:podspec], "../../sdks/hermes/hermes-engine.podspec") end - - # ========================= # - # TEST - getHermesBuildType # - # ========================= # - def test_getHermesBuildType_whenNotInProduction - # Arrange - ENV['PRODUCTION'] = '0' - - # Act - build_type = get_hermes_build_type - - # Assert - assert_equal(build_type, :debug) - end - - def test_getHermesBuildType_whenInProduction - # Arrange - ENV['PRODUCTION'] = '1' - - # Act - build_type = get_hermes_build_type - - # Assert - assert_equal(build_type, :release) - end - - def test_getHermesBuildType_whenProductionIsNotSet - # Arrange - ENV.delete 'PRODUCTION' - - # Act - build_type = get_hermes_build_type - - # Assert - assert_equal(build_type, :debug) - end - - def test_getHermesBuildType_symbolsMatchStrings - # Arrange - ENV['PRODUCTION'] = '0' - - # Act - build_type = get_hermes_build_type - - # Assert - assert_equal(build_type, :debug) - assert_equal(build_type.to_s, "debug") - assert_equal(build_type.to_s.capitalize, "Debug") - end - - end diff --git a/scripts/cocoapods/hermes.rb b/scripts/cocoapods/hermes.rb index a88b8dc4c0af0c..747b744c87d7df 100644 --- a/scripts/cocoapods/hermes.rb +++ b/scripts/cocoapods/hermes.rb @@ -18,7 +18,3 @@ def install_hermes_if_enabled(hermes_enabled, react_native_path) pod 'libevent', '~> 2.1.12' pod 'hermes-engine', :podspec => "#{react_native_path}/sdks/hermes/hermes-engine.podspec" end - -def get_hermes_build_type() - return ENV['PRODUCTION'] == "1" ? :release : :debug -end diff --git a/sdks/hermes-engine/hermes-engine.podspec b/sdks/hermes-engine/hermes-engine.podspec index 1d5d4aa17c3b12..0eab5335d24f45 100644 --- a/sdks/hermes-engine/hermes-engine.podspec +++ b/sdks/hermes-engine/hermes-engine.podspec @@ -7,6 +7,9 @@ require "json" react_native_path = File.join(__dir__, "..", "..") +# Whether Hermes is built for Release or Debug is determined by the PRODUCTION envvar. +build_type = ENV['PRODUCTION'] == "1" ? :release : :debug + # package.json package_file = File.join(react_native_path, "package.json") package = JSON.parse(File.read(package_file)) @@ -35,7 +38,7 @@ elsif File.exists?(hermestag_file) && isInCI source[:git] = git source[:tag] = hermestag else - source[:http] = "https://github.com/facebook/react-native/releases/download/v#{version}/hermes-runtime-darwin-#{get_hermes_build_type.to_s}-v#{version}.tar.gz" + source[:http] = "https://github.com/facebook/react-native/releases/download/v#{version}/hermes-runtime-darwin-#{build_type.to_s}-v#{version}.tar.gz" end Pod::Spec.new do |spec| @@ -49,7 +52,7 @@ Pod::Spec.new do |spec| spec.source = source spec.platforms = { :osx => "10.13", :ios => "12.4" } - spec.preserve_paths = ["destroot/bin/*"].concat(get_hermes_build_type == :debug ? ["**/*.{h,c,cpp}"] : []) + spec.preserve_paths = ["destroot/bin/*"].concat(build_type == :debug ? ["**/*.{h,c,cpp}"] : []) spec.source_files = "destroot/include/**/*.h" spec.header_mappings_dir = "destroot/include" @@ -59,12 +62,12 @@ Pod::Spec.new do |spec| spec.xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", "CLANG_CXX_LIBRARY" => "compiler-default", - "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=#{get_hermes_build_type == :debug ? "1" : "0"}" + "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=#{build_type == :debug ? "1" : "0"}" } if source[:git] then spec.prepare_command = <<-EOS - BUILD_TYPE=#{get_hermes_build_type.to_s.capitalize} + BUILD_TYPE=#{build_type.to_s.capitalize} # Set HERMES_OVERRIDE_HERMESC_PATH if pre-built HermesC is available #{File.exist?(import_hermesc_file) ? "export HERMES_OVERRIDE_HERMESC_PATH=#{import_hermesc_file}" : ""}