Skip to content

Commit db70b79

Browse files
rubennortefacebook-github-bot
authored andcommitted
Add ReactNativeFeatureFlagsDynamicProvider to allow configuration in C++ using dynamic values (#48093)
Summary: Pull Request resolved: #48093 Changelog: [internal] We're going to add support for specifying feature flags in Fantom tests in pragmas. E.g.: ``` /** * fantom_flags commonTestFlag:true */ ``` Users will be able to specify any feature flags in their tests, so we need a way to pass that information from the test file to the runner, and the runner has to be able to apply this dynamic configuration. Because the API is statically typed in C++, we need to define a method for every possible feature flag configurable through this API. We could do it in userland, but we'd have to manually add a method every time there was a new feature flag we wanted to support. Instead of doing that, this introduces a new abstraction in the feature flag system that codegens it for you. The API is basically: ``` folly::dynamic values = folly::dynamic::object(); values["commonTestFlag"] = true; ReactNativeFeatureFlags::override( std::make_unique<ReactNativeFeatureFlagsDynamicProvider>(values)); EXPECT_EQ(ReactNativeFeatureFlags::commonTestFlag(), true); ``` Then we can use this abstraction in Fantom to pass all the configured flags as `folly::dynamic` through this API. Reviewed By: javache Differential Revision: D66760118 fbshipit-source-id: c32329e5ca76923c3e0b9c0eb1fe8c3268e1f57b
1 parent da6d089 commit db70b79

File tree

7 files changed

+669
-11
lines changed

7 files changed

+669
-11
lines changed

packages/react-native/ReactCommon/react/featureflags/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ file(GLOB react_featureflags_SRC CONFIGURE_DEPENDS *.cpp)
1818
add_library(react_featureflags OBJECT ${react_featureflags_SRC})
1919

2020
target_include_directories(react_featureflags PUBLIC ${REACT_COMMON_DIR})
21+
22+
target_link_libraries(react_featureflags
23+
folly_runtime)

packages/react-native/ReactCommon/react/featureflags/React-featureflags.podspec

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ if ENV['USE_FRAMEWORKS']
2222
header_search_paths << "\"$(PODS_TARGET_SRCROOT)/../..\"" # this is needed to allow the feature flags access its own files
2323
end
2424

25+
folly_config = get_folly_config()
26+
folly_compiler_flags = folly_config[:compiler_flags]
27+
folly_version = folly_config[:version]
28+
2529
Pod::Spec.new do |s|
2630
s.name = "React-featureflags"
2731
s.version = version
@@ -32,11 +36,14 @@ Pod::Spec.new do |s|
3236
s.platforms = min_supported_versions
3337
s.source = source
3438
s.source_files = "*.{cpp,h}"
39+
s.compiler_flags = folly_compiler_flags
3540
s.header_dir = "react/featureflags"
3641
s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
3742
"HEADER_SEARCH_PATHS" => header_search_paths.join(' '),
3843
"DEFINES_MODULE" => "YES" }
3944

45+
s.dependency "RCT-Folly", folly_version
46+
4047
if ENV['USE_FRAMEWORKS']
4148
s.module_name = "React_featureflags"
4249
s.header_mappings_dir = "../.."

0 commit comments

Comments
 (0)