Skip to content

Commit 878d353

Browse files
j-piaseckifacebook-github-bot
authored andcommitted
Cover react/renderer/debug with Stable API guards (#58183)
Summary: 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] Differential Revision: D117850084
1 parent a9203b8 commit 878d353

9 files changed

Lines changed: 71 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
@@ -149,6 +149,7 @@ val preparePrefab by
149149
Pair("../ReactCommon/react/debug/React/", "React/"),
150150
// react_renderer_debug
151151
Pair("../ReactCommon/react/renderer/debug/", "react/renderer/debug/"),
152+
Pair("../ReactCommon/react/renderer/debug/React/", "React/"),
152153
// react_renderer_graphics
153154
Pair("../ReactCommon/react/renderer/graphics/", "react/renderer/graphics/"),
154155
Pair("../ReactCommon/react/renderer/graphics/platform/android/", ""),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ 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_link_libraries(react_renderer_debug folly_runtime react_cxxstableapi react_debug)
1616
target_compile_reactnative_options(react_renderer_debug PRIVATE)
1717
target_compile_options(react_renderer_debug PRIVATE -Wpedantic)
1818

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: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
// only outside consumers use this umbrella.
18+
// =============================================================================
19+
20+
// Marks that the following headers are pulled in through the umbrella, so their
21+
// shared guard (<react/cxxstableapi/UmbrellaGuard.h>) accepts them. The marker
22+
// is saved and restored rather than defined and undefined: the scope ends at
23+
// this block, so later *direct* includes in the same TU are still caught, and
24+
// it nests inside an enclosing umbrella rather than disarming it.
25+
#pragma push_macro("RN_UMBRELLA_CONTEXT")
26+
#undef RN_UMBRELLA_CONTEXT
27+
#define RN_UMBRELLA_CONTEXT 1
28+
29+
#include <react/renderer/debug/DebugStringConvertible.h>
30+
#include <react/renderer/debug/DebugStringConvertibleItem.h>
31+
#include <react/renderer/debug/debugStringConvertibleUtils.h>
32+
#include <react/renderer/debug/flags.h>
33+
34+
#undef RN_UMBRELLA_CONTEXT
35+
#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
@@ -653,6 +653,23 @@ const PodspecExceptions /*: {[key: string]: PodSpecConfiguration} */ = {
653653
},
654654
],
655655
},
656+
'ReactCommon/react/renderer/debug/React-rendererdebug.podspec': {
657+
name: 'React-rendererdebug',
658+
headerPatterns: [],
659+
headerDir: '',
660+
subSpecs: [
661+
{
662+
name: 'debug',
663+
headerPatterns: ['*.h'],
664+
headerDir: 'react/renderer/debug',
665+
},
666+
{
667+
name: 'debugUmbrella',
668+
headerPatterns: ['React/*.h'],
669+
headerDir: 'React',
670+
},
671+
],
672+
},
656673
};
657674

658675
module.exports = {PodspecExceptions};

0 commit comments

Comments
 (0)