Skip to content

Commit 5ad1d5c

Browse files
j-piaseckimeta-codesync[bot]
authored andcommitted
Cover react/renderer/debug with Stable API guards (#58183)
Summary: Pull Request resolved: #58183 Classifies `react/renderer/debug:debug` as a public target under the three-tier C++ stable API visibility model, and adds the module umbrella `<React/RendererDebug.h>` as its public entry point. Consumers that opt into `RN_STRICT_API` now get an error if they include the module's headers directly and have to go through the umbrella instead; without that flag the guards are inert, so no existing build changes behaviour. The pod's source glob is narrowed to the module's own directory so the umbrella is not also flattened into `react/renderer/debug`, and the matching `headers-config.js` exception splits the pod into module and umbrella subspecs so `<React/RendererDebug.h>` resolves in the SwiftPM prebuild. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D117850084 fbshipit-source-id: 7e07ee5e9351e77453159c4476b31094332544a9
1 parent 39751d8 commit 5ad1d5c

9 files changed

Lines changed: 76 additions & 3 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ val preparePrefab by
151151
Pair("../ReactCommon/react/debug/React/", "React/"),
152152
// react_renderer_debug
153153
Pair("../ReactCommon/react/renderer/debug/", "react/renderer/debug/"),
154+
Pair("../ReactCommon/react/renderer/debug/React/", "React/"),
154155
// react_renderer_graphics
155156
Pair("../ReactCommon/react/renderer/graphics/", "react/renderer/graphics/"),
156157
Pair("../ReactCommon/react/renderer/graphics/platform/android/", ""),

packages/react-native/ReactCommon/react/renderer/debug/CMakeLists.txt

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

1414
target_include_directories(react_renderer_debug PUBLIC ${REACT_COMMON_DIR})
15-
target_link_libraries(react_renderer_debug folly_runtime react_debug)
15+
target_include_directories(react_renderer_debug INTERFACE ${REACT_COMMON_DIR}/react/renderer/debug)
16+
target_link_libraries(react_renderer_debug folly_runtime react_cxxstableapi react_debug)
1617
target_compile_reactnative_options(react_renderer_debug PRIVATE)
1718
target_compile_options(react_renderer_debug PRIVATE -Wpedantic)
1819

packages/react-native/ReactCommon/react/renderer/debug/DebugStringConvertible.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#include <react/cxxstableapi/UmbrellaGuard.h>
11+
1012
#include <climits>
1113
#include <memory>
1214
#include <optional>

packages/react-native/ReactCommon/react/renderer/debug/DebugStringConvertibleItem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#include <react/cxxstableapi/UmbrellaGuard.h>
11+
1012
#include <string>
1113

1214
#include <react/renderer/debug/DebugStringConvertible.h>

packages/react-native/ReactCommon/react/renderer/debug/React-rendererdebug.podspec

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ Pod::Spec.new do |s|
3131
s.author = "Meta Platforms, Inc. and its affiliates"
3232
s.platforms = min_supported_versions
3333
s.source = source
34-
s.source_files = podspec_sources("**/*.{cpp,h,mm}", "**/*.h")
34+
s.source_files = podspec_sources("*.{cpp,h,mm}", "*.h")
3535
s.header_dir = "react/renderer/debug"
36-
s.exclude_files = "tests"
3736
s.pod_target_xcconfig = {
3837
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
3938
"HEADER_SEARCH_PATHS" => header_search_paths.join(' '),
@@ -46,5 +45,13 @@ Pod::Spec.new do |s|
4645
add_rn_third_party_dependencies(s)
4746
add_rncore_dependency(s)
4847

48+
s.dependency "React-cxxstableapi"
49+
50+
s.subspec "debugUmbrella" do |ss|
51+
ss.source_files = "React/*.h"
52+
ss.header_dir = ""
53+
ss.header_mappings_dir = "."
54+
end
55+
4956
mark_as_react_native_build(s)
5057
end
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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/renderer/debug` module - public entry point.
12+
//
13+
// #include <React/RendererDebug.h>
14+
//
15+
// Re-exports the module's public interface headers. React Native's own code
16+
// should keep using the fine-grained `<react/renderer/debug/...>` includes,
17+
// except in headers it exports to consumers: those are preprocessed in the
18+
// consumer's translation unit, where the fine-grained include hits this
19+
// module's <react/cxxstableapi/UmbrellaGuard.h>. `RN_ALLOW_FRAMEWORKS` does not
20+
// suppress that guard, so a "for frameworks" header must reach this module
21+
// through the umbrella.
22+
// =============================================================================
23+
24+
// Marks that the following headers are pulled in through the umbrella, so their
25+
// shared guard (<react/cxxstableapi/UmbrellaGuard.h>) accepts them. The marker
26+
// is saved and restored rather than defined and undefined: the scope ends at
27+
// this block, so later *direct* includes in the same TU are still caught, and
28+
// it nests inside an enclosing umbrella rather than disarming it.
29+
#pragma push_macro("RN_UMBRELLA_CONTEXT")
30+
#undef RN_UMBRELLA_CONTEXT
31+
#define RN_UMBRELLA_CONTEXT 1
32+
33+
#include <react/renderer/debug/DebugStringConvertible.h>
34+
#include <react/renderer/debug/DebugStringConvertibleItem.h>
35+
#include <react/renderer/debug/debugStringConvertibleUtils.h>
36+
#include <react/renderer/debug/flags.h>
37+
38+
#undef RN_UMBRELLA_CONTEXT
39+
#pragma pop_macro("RN_UMBRELLA_CONTEXT")

packages/react-native/ReactCommon/react/renderer/debug/debugStringConvertibleUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#include <react/cxxstableapi/UmbrellaGuard.h>
11+
1012
#include <memory>
1113
#include <optional>
1214
#include <string>

packages/react-native/ReactCommon/react/renderer/debug/flags.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#include <react/cxxstableapi/UmbrellaGuard.h>
11+
1012
#include <react/debug/flags.h>
1113

1214
//

packages/react-native/scripts/ios-prebuild/headers-config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,23 @@ const PodspecExceptions /*: {[key: string]: PodSpecConfiguration} */ = {
697697
},
698698
],
699699
},
700+
'ReactCommon/react/renderer/debug/React-rendererdebug.podspec': {
701+
name: 'React-rendererdebug',
702+
headerPatterns: [],
703+
headerDir: '',
704+
subSpecs: [
705+
{
706+
name: 'debug',
707+
headerPatterns: ['*.h'],
708+
headerDir: 'react/renderer/debug',
709+
},
710+
{
711+
name: 'debugUmbrella',
712+
headerPatterns: ['React/*.h'],
713+
headerDir: 'React',
714+
},
715+
],
716+
},
700717
};
701718

702719
module.exports = {PodspecExceptions};

0 commit comments

Comments
 (0)