Skip to content

Commit 8eb2c8a

Browse files
j-piaseckifacebook-github-bot
authored andcommitted
Cover react/featureflags with Stable API guards (#58083)
Summary: Classifies `react/featureflags:featureflags` as a public target under the C++ stable API three-tier visibility model and introduces the module umbrella `React/FeatureFlags.h` as its public entry point. This module's headers are generated, so the `UmbrellaGuard.h` include is added to the templates in `scripts/featureflags/templates/common-cxx/` rather than to the headers themselves. `ReactNativeFeatureFlagsOverridesOSSStable.h` is the module's one hand-written header and is edited directly. The umbrella is not generated, and re-exports all eight of the module's headers. The sibling `react/nativemodule/featureflags:featureflags` target is private under the same model. The guards are inert unless a consumer defines `RN_STRICT_API`, so there is no behavior change. Changelog: [General][Added] - Add `<React/FeatureFlags.h>` umbrella header as the public entry point for `react/featureflags` Reviewed By: cortinico Differential Revision: D117172757
1 parent 183969b commit 8eb2c8a

19 files changed

Lines changed: 102 additions & 8 deletions

packages/react-native/ReactAndroid/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ val preparePrefab by
115115
Pair("../ReactCommon/cxxreact/", "cxxreact/"),
116116
// react_featureflags
117117
Pair("../ReactCommon/react/featureflags/", "react/featureflags/"),
118+
Pair("../ReactCommon/react/featureflags/React/", "React/"),
118119
// react_devtoolsruntimesettings
119120
Pair(
120121
"../ReactCommon/react/devtoolsruntimesettings/",

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ file(GLOB react_featureflags_SRC CONFIGURE_DEPENDS *.cpp)
1212
add_library(react_featureflags OBJECT ${react_featureflags_SRC})
1313

1414
target_include_directories(react_featureflags PUBLIC ${REACT_COMMON_DIR})
15+
target_include_directories(react_featureflags INTERFACE ${REACT_COMMON_DIR}/react/featureflags)
1516

16-
target_link_libraries(react_featureflags folly_runtime)
17+
target_link_libraries(react_featureflags folly_runtime react_cxxstableapi)
1718
target_compile_reactnative_options(react_featureflags PRIVATE)
1819
target_compile_options(react_featureflags PRIVATE -Wpedantic)

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,15 @@ Pod::Spec.new do |s|
3939

4040
resolve_use_frameworks(s, header_mappings_dir: "../..", module_name: "React_featureflags")
4141

42+
s.dependency "React-cxxstableapi"
4243
add_rn_third_party_dependencies(s)
4344
add_rncore_dependency(s)
4445

46+
s.subspec "featureflagsUmbrella" do |ss|
47+
ss.source_files = "React/*.h"
48+
ss.header_dir = "React"
49+
ss.header_mappings_dir = "React"
50+
end
51+
4552
mark_as_react_native_build(s)
4653
end
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
// =============================================================================
11+
// Umbrella header for the `react/featureflags` module - public entry point.
12+
//
13+
// #include <React/FeatureFlags.h>
14+
//
15+
// Re-exports the module's public interface headers. React Native's own code
16+
// should keep using the fine-grained `<react/featureflags/...>` includes; only
17+
// outside consumers use this umbrella.
18+
//
19+
// The headers below are generated from
20+
// `scripts/featureflags/ReactNativeFeatureFlags.config.js`, but this file is
21+
// not - keep it in sync by hand when the set of generated headers in
22+
// `scripts/featureflags/generateCommonCxxModules.js` changes.
23+
// =============================================================================
24+
25+
// Marks that the following headers are pulled in through the umbrella, so their
26+
// shared guard (<react/cxxstableapi/UmbrellaGuard.h>) accepts them. Scoped to
27+
// this block so later *direct* includes in the same translation unit are still
28+
// caught.
29+
#define RN_UMBRELLA_CONTEXT
30+
31+
#include <react/featureflags/ReactNativeFeatureFlags.h>
32+
#include <react/featureflags/ReactNativeFeatureFlagsAccessor.h>
33+
#include <react/featureflags/ReactNativeFeatureFlagsDefaults.h>
34+
#include <react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h>
35+
#include <react/featureflags/ReactNativeFeatureFlagsOverridesOSSCanary.h>
36+
#include <react/featureflags/ReactNativeFeatureFlagsOverridesOSSExperimental.h>
37+
#include <react/featureflags/ReactNativeFeatureFlagsOverridesOSSStable.h>
38+
#include <react/featureflags/ReactNativeFeatureFlagsProvider.h>
39+
40+
#undef RN_UMBRELLA_CONTEXT

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<2d59cf5ea42847d6174fc433ba5a6fe4>>
7+
* @generated SignedSource<<414b7a90eeecd2abe9849955131fb122>>
88
*/
99

1010
/**
@@ -19,6 +19,8 @@
1919

2020
#pragma once
2121

22+
#include <react/cxxstableapi/UmbrellaGuard.h>
23+
2224
#include <react/featureflags/ReactNativeFeatureFlagsAccessor.h>
2325
#include <react/featureflags/ReactNativeFeatureFlagsProvider.h>
2426
#include <memory>

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<55f19e7a0d7fbbda3aa131a74909ec07>>
7+
* @generated SignedSource<<c1b8add7c4f70f65e71ff2742a7f5427>>
88
*/
99

1010
/**
@@ -19,6 +19,8 @@
1919

2020
#pragma once
2121

22+
#include <react/cxxstableapi/UmbrellaGuard.h>
23+
2224
#include <react/featureflags/ReactNativeFeatureFlagsProvider.h>
2325
#include <array>
2426
#include <atomic>

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<8e00ed57e2faa8e13ae2eb58afd64962>>
7+
* @generated SignedSource<<9e798b7ae2a2f26097359ca37fa99d04>>
88
*/
99

1010
/**
@@ -19,6 +19,8 @@
1919

2020
#pragma once
2121

22+
#include <react/cxxstableapi/UmbrellaGuard.h>
23+
2224
#include <react/featureflags/ReactNativeFeatureFlagsProvider.h>
2325

2426
namespace facebook::react {

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<9c0b6df9433a5696f5eacf47713b9040>>
7+
* @generated SignedSource<<3429660cde44d793af0e86ff425b1094>>
88
*/
99

1010
/**
@@ -19,6 +19,8 @@
1919

2020
#pragma once
2121

22+
#include <react/cxxstableapi/UmbrellaGuard.h>
23+
2224
#include <folly/dynamic.h>
2325
#include <react/featureflags/ReactNativeFeatureFlagsDefaults.h>
2426

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSCanary.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<70297dc6230d386e556c82860cbf9985>>
7+
* @generated SignedSource<<650cb266846c66577dde6d7c7a703af1>>
88
*/
99

1010
/**
@@ -19,6 +19,8 @@
1919

2020
#pragma once
2121

22+
#include <react/cxxstableapi/UmbrellaGuard.h>
23+
2224
#include <react/featureflags/ReactNativeFeatureFlagsOverridesOSSStable.h>
2325

2426
namespace facebook::react {

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSExperimental.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<dc6298e569276bf047951a8e4105aa96>>
7+
* @generated SignedSource<<5c7271fe5fcdd90f61a5a07772b820e5>>
88
*/
99

1010
/**
@@ -19,6 +19,8 @@
1919

2020
#pragma once
2121

22+
#include <react/cxxstableapi/UmbrellaGuard.h>
23+
2224
#include <react/featureflags/ReactNativeFeatureFlagsOverridesOSSCanary.h>
2325

2426
namespace facebook::react {

0 commit comments

Comments
 (0)