Skip to content

Commit 7a48bc5

Browse files
j-piaseckifacebook-github-bot
authored andcommitted
Cover react/renderer/debug with Stable API guards
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 2f5a833 commit 7a48bc5

9 files changed

Lines changed: 66 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
@@ -146,6 +146,7 @@ val preparePrefab by
146146
Pair("../ReactCommon/react/debug/", "react/debug/"),
147147
// react_renderer_debug
148148
Pair("../ReactCommon/react/renderer/debug/", "react/renderer/debug/"),
149+
Pair("../ReactCommon/react/renderer/debug/React/", "React/"),
149150
// react_renderer_graphics
150151
Pair("../ReactCommon/react/renderer/graphics/", "react/renderer/graphics/"),
151152
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 = "React"
53+
ss.header_mappings_dir = "React"
54+
end
55+
4956
mark_as_react_native_build(s)
5057
end
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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. Scoped to
22+
// this block so later *direct* includes in the same TU are still caught.
23+
#define RN_UMBRELLA_CONTEXT
24+
25+
#include <react/renderer/debug/DebugStringConvertible.h>
26+
#include <react/renderer/debug/DebugStringConvertibleItem.h>
27+
#include <react/renderer/debug/debugStringConvertibleUtils.h>
28+
#include <react/renderer/debug/flags.h>
29+
30+
#undef 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
@@ -597,6 +597,23 @@ const PodspecExceptions /*: {[key: string]: PodSpecConfiguration} */ = {
597597
'Libraries/PushNotificationIOS/React-RCTPushNotification.podspec': {
598598
disabled: true,
599599
},
600+
'ReactCommon/react/renderer/debug/React-rendererdebug.podspec': {
601+
name: 'React-rendererdebug',
602+
headerPatterns: [],
603+
headerDir: '',
604+
subSpecs: [
605+
{
606+
name: 'debug',
607+
headerPatterns: ['*.h'],
608+
headerDir: 'react/renderer/debug',
609+
},
610+
{
611+
name: 'debugUmbrella',
612+
headerPatterns: ['React/*.h'],
613+
headerDir: 'React',
614+
},
615+
],
616+
},
600617
};
601618

602619
module.exports = {PodspecExceptions};

0 commit comments

Comments
 (0)