Drop the requirement to use PRODUCTION=1 to add -NDEBUG
Summary: The previous fix for -DNDEBUG required to install the pods with PRODUCTION=1 in order to add the flag. The flag was added also to Debug configurations, which is not ideal. With this change, we remove the requirement of running `PRODUCTION=1 pod install` and we install the -DNDEBUG flag to all the release configurations. ## Changelog: [iOS][Changed] - Install the -DNDEBUG flag on Release configurations, without requiring PRODUCTION=1 flag Reviewed By: cortinico Differential Revision: D43535620 fbshipit-source-id: af97bef06f267dddd5ce13a466bbc8d9a5eb2b0b
This commit is contained in:
Родитель
c1304d938d
Коммит
93fdcbaed0
|
@ -81,7 +81,7 @@ class NewArchitectureTests < Test::Unit::TestCase
|
|||
assert_equal(yoga_release_config.build_settings["OTHER_CPLUSPLUSFLAGS"], "$(inherited)")
|
||||
end
|
||||
|
||||
def test_modifyFlagsForNewArch_whenOnNewArch_updateFlags
|
||||
def test_modifyFlagsForNewArch_whenOnNewArchAndIsRelease_updateFlags
|
||||
# Arrange
|
||||
first_xcconfig = prepare_xcconfig("First")
|
||||
second_xcconfig = prepare_xcconfig("Second")
|
||||
|
@ -102,47 +102,17 @@ class NewArchitectureTests < Test::Unit::TestCase
|
|||
|
||||
# Assert
|
||||
assert_equal(first_xcconfig.attributes["OTHER_CPLUSPLUSFLAGS"], "$(inherited) -DRCT_NEW_ARCH_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1")
|
||||
assert_nil(first_xcconfig.attributes["OTHER_CFLAGS"])
|
||||
assert_equal(first_xcconfig.save_as_invocation, ["a/path/First.xcconfig"])
|
||||
assert_equal(second_xcconfig.attributes["OTHER_CPLUSPLUSFLAGS"], "$(inherited) -DRCT_NEW_ARCH_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1")
|
||||
assert_nil(second_xcconfig.attributes["OTHER_CFLAGS"])
|
||||
assert_equal(second_xcconfig.save_as_invocation, ["a/path/Second.xcconfig"])
|
||||
assert_equal(react_core_debug_config.build_settings["OTHER_CPLUSPLUSFLAGS"], "$(inherited) -DRCT_NEW_ARCH_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1")
|
||||
assert_equal(react_core_release_config.build_settings["OTHER_CPLUSPLUSFLAGS"], "$(inherited) -DRCT_NEW_ARCH_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1")
|
||||
assert_equal(yoga_debug_config.build_settings["OTHER_CPLUSPLUSFLAGS"], "$(inherited)")
|
||||
assert_equal(yoga_release_config.build_settings["OTHER_CPLUSPLUSFLAGS"], "$(inherited)")
|
||||
end
|
||||
|
||||
def test_modifyFlagsForNewArch_whenOnNewArchAndIsRelease_updateFlags
|
||||
# Arrange
|
||||
first_xcconfig = prepare_xcconfig("First")
|
||||
second_xcconfig = prepare_xcconfig("Second")
|
||||
react_core_debug_config = prepare_CXX_Flags_build_configuration("Debug")
|
||||
react_core_release_config = prepare_CXX_Flags_build_configuration("Release")
|
||||
yoga_debug_config = prepare_CXX_Flags_build_configuration("Debug")
|
||||
yoga_release_config = prepare_CXX_Flags_build_configuration("Release")
|
||||
|
||||
installer = prepare_installer_for_cpp_flags(
|
||||
[ first_xcconfig, second_xcconfig ],
|
||||
{
|
||||
"React-Core" => [ react_core_debug_config, react_core_release_config ],
|
||||
"Yoga" => [ yoga_debug_config, yoga_release_config ],
|
||||
}
|
||||
)
|
||||
# Act
|
||||
NewArchitectureHelper.modify_flags_for_new_architecture(installer, true, is_release: true)
|
||||
|
||||
# Assert
|
||||
assert_equal(first_xcconfig.attributes["OTHER_CPLUSPLUSFLAGS"], "$(inherited) -DRCT_NEW_ARCH_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DNDEBUG")
|
||||
assert_equal(first_xcconfig.attributes["OTHER_CFLAGS"], "$(inherited) -DNDEBUG")
|
||||
assert_equal(first_xcconfig.save_as_invocation, ["a/path/First.xcconfig"])
|
||||
assert_equal(second_xcconfig.attributes["OTHER_CPLUSPLUSFLAGS"], "$(inherited) -DRCT_NEW_ARCH_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DNDEBUG")
|
||||
assert_equal(second_xcconfig.attributes["OTHER_CFLAGS"], "$(inherited) -DNDEBUG")
|
||||
assert_equal(second_xcconfig.save_as_invocation, ["a/path/Second.xcconfig"])
|
||||
assert_equal(react_core_debug_config.build_settings["OTHER_CPLUSPLUSFLAGS"], "$(inherited) -DRCT_NEW_ARCH_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DNDEBUG")
|
||||
assert_equal(react_core_debug_config.build_settings["OTHER_CFLAGS"], "$(inherited) -DNDEBUG")
|
||||
assert_nil(react_core_debug_config.build_settings["OTHER_CFLAGS"])
|
||||
assert_equal(react_core_release_config.build_settings["OTHER_CPLUSPLUSFLAGS"], "$(inherited) -DRCT_NEW_ARCH_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DNDEBUG")
|
||||
assert_equal(react_core_release_config.build_settings["OTHER_CFLAGS"], "$(inherited) -DNDEBUG")
|
||||
assert_equal(yoga_debug_config.build_settings["OTHER_CPLUSPLUSFLAGS"], "$(inherited) -DNDEBUG")
|
||||
assert_equal(yoga_debug_config.build_settings["OTHER_CFLAGS"], "$(inherited) -DNDEBUG")
|
||||
assert_equal(yoga_debug_config.build_settings["OTHER_CPLUSPLUSFLAGS"], "$(inherited)")
|
||||
assert_nil(yoga_debug_config.build_settings["OTHER_CFLAGS"])
|
||||
assert_equal(yoga_release_config.build_settings["OTHER_CPLUSPLUSFLAGS"], "$(inherited) -DNDEBUG")
|
||||
assert_equal(yoga_release_config.build_settings["OTHER_CFLAGS"], "$(inherited) -DNDEBUG")
|
||||
end
|
||||
|
|
|
@ -38,16 +38,20 @@ class NewArchitectureHelper
|
|||
end
|
||||
end
|
||||
|
||||
def self.modify_flags_for_new_architecture(installer, is_new_arch_enabled, is_release: false)
|
||||
def self.modify_flags_for_new_architecture(installer, is_new_arch_enabled)
|
||||
unless is_new_arch_enabled
|
||||
return
|
||||
end
|
||||
ndebug_flag = (is_release ? " -DNDEBUG" : "")
|
||||
ndebug_flag = " -DNDEBUG"
|
||||
# Add RCT_NEW_ARCH_ENABLED to Target pods xcconfig
|
||||
installer.aggregate_targets.each do |aggregate_target|
|
||||
aggregate_target.xcconfigs.each do |config_name, config_file|
|
||||
config_file.attributes['OTHER_CPLUSPLUSFLAGS'] = @@new_arch_cpp_flags + ndebug_flag
|
||||
config_file.attributes['OTHER_CPLUSPLUSFLAGS'] = @@new_arch_cpp_flags
|
||||
|
||||
if config_name == "Release"
|
||||
config_file.attributes['OTHER_CPLUSPLUSFLAGS'] = config_file.attributes['OTHER_CPLUSPLUSFLAGS'] + ndebug_flag
|
||||
config_file.attributes['OTHER_CFLAGS'] = "$(inherited)" + ndebug_flag
|
||||
end
|
||||
|
||||
xcconfig_path = aggregate_target.xcconfig_path(config_name)
|
||||
config_file.save_as(xcconfig_path)
|
||||
|
@ -63,12 +67,14 @@ class NewArchitectureHelper
|
|||
end
|
||||
|
||||
target_installation_result.native_target.build_configurations.each do |config|
|
||||
if config.name == "Release"
|
||||
current_flags = config.build_settings['OTHER_CPLUSPLUSFLAGS'] != nil ? config.build_settings['OTHER_CPLUSPLUSFLAGS'] : ""
|
||||
config.build_settings['OTHER_CPLUSPLUSFLAGS'] = current_flags + ndebug_flag
|
||||
config.build_settings['OTHER_CFLAGS'] = "$(inherited)" + ndebug_flag
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.install_modules_dependencies(spec, new_arch_enabled, folly_version)
|
||||
# Pod::Specification does not have getters so, we have to read
|
||||
|
|
|
@ -222,7 +222,7 @@ def react_native_post_install(installer, react_native_path = "../node_modules/re
|
|||
|
||||
NewArchitectureHelper.set_clang_cxx_language_standard_if_needed(installer)
|
||||
is_new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == "1"
|
||||
NewArchitectureHelper.modify_flags_for_new_architecture(installer, is_new_arch_enabled, is_release: ENV['PRODUCTION'] == "1")
|
||||
NewArchitectureHelper.modify_flags_for_new_architecture(installer, is_new_arch_enabled)
|
||||
|
||||
Pod::UI.puts "Pod install took #{Time.now.to_i - $START_TIME} [s] to run".green
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче