Skip to content

Commit 42a3721

Browse files
j-piaseckimeta-codesync[bot]
authored andcommitted
Add stable public CallInvoker C++ entry point (#58159)
Summary: Pull Request resolved: #58159 Pull Request resolved: #58049 Add `<React/CallInvoker.h>` as the canonical public C++ entry point for `CallInvoker`, `NativeMethodCallInvoker`, and `SchedulerPriority`. Guard direct leaf-header inclusion for strict API consumers while preserving existing React Native builds and legacy include paths. Export and stage the umbrella consistently through Buck, CMake, Android Prefab, CocoaPods, and the Apple prebuilt-header inventory. SwiftPM needs no change, since its header mapping for this module already preserves the directory structure. The `ios-prebuild` header configuration needs an explicit entry here: the generic podspec parser only reads the first `header_dir`, so it would have flattened the umbrella into `ReactCommon/` and collided with the existing leaf header of the same basename. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D116921026 fbshipit-source-id: 1838a18632f4493f22397bfebe44f38895cbfc7d
1 parent 2f5a833 commit 42a3721

7 files changed

Lines changed: 62 additions & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ val preparePrefab by
233233
Pair(File(buildDir, "third-party-ndk/folly/").absolutePath, ""),
234234
Pair(File(buildDir, "third-party-ndk/glog/exported/").absolutePath, ""),
235235
Pair("../ReactCommon/callinvoker/", ""),
236+
Pair("../ReactCommon/callinvoker/React/", "React/"),
236237
Pair("../ReactCommon/cxxreact/", "cxxreact/"),
237238
// Exported because the public cxxreact/ErrorUtils.h includes it
238239
Pair("../ReactCommon/jserrorhandler/", "jserrorhandler/"),

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ include(${REACT_COMMON_DIR}/cmake-utils/react-native-flags.cmake)
1111
add_library(callinvoker INTERFACE)
1212

1313
target_include_directories(callinvoker INTERFACE .)
14+
target_link_libraries(callinvoker INTERFACE react_cxxstableapi)
1415
target_compile_reactnative_options(callinvoker INTERFACE)
1516
target_compile_options(callinvoker INTERFACE -Wpedantic)

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ else
1616
source[:tag] = "v#{version}"
1717
end
1818

19+
header_search_paths = []
20+
21+
if ENV['USE_FRAMEWORKS']
22+
header_search_paths << "\"$(PODS_TARGET_SRCROOT)/..\"" # ReactCommon, for <react/cxxstableapi/...>
23+
end
24+
1925
Pod::Spec.new do |s|
2026
s.name = "React-callinvoker"
2127
s.version = version
@@ -26,7 +32,17 @@ Pod::Spec.new do |s|
2632
s.platforms = min_supported_versions
2733
s.source = source
2834
s.source_files = podspec_sources("**/*.{cpp,h}", "**/*.h")
35+
s.exclude_files = "React"
36+
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => header_search_paths.join(' ') }
2937
s.header_dir = "ReactCommon"
3038

39+
s.subspec "CallInvokerUmbrella" do |ss|
40+
ss.source_files = "React/*.h"
41+
ss.header_dir = "React"
42+
ss.header_mappings_dir = "React"
43+
end
44+
45+
s.dependency "React-cxxstableapi"
46+
3147
mark_as_react_native_build(s)
3248
end
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 `callinvoker` module - public entry point.
12+
//
13+
// #include <React/CallInvoker.h>
14+
//
15+
// Re-exports the module's public interface headers. React Native's own code
16+
// should keep using the fine-grained `<ReactCommon/...>` includes; only outside
17+
// 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.
22+
#define RN_UMBRELLA_CONTEXT
23+
24+
#include <ReactCommon/CallInvoker.h>
25+
#include <ReactCommon/SchedulerPriority.h>
26+
27+
#undef RN_UMBRELLA_CONTEXT

packages/react-native/ReactCommon/callinvoker/ReactCommon/CallInvoker.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 "SchedulerPriority.h"
1113

1214
#include <functional>

packages/react-native/ReactCommon/callinvoker/ReactCommon/SchedulerPriority.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
namespace facebook::react {
1113

1214
enum class SchedulerPriority : int {

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,19 @@ const PodspecExceptions /*: {[key: string]: PodSpecConfiguration} */ = {
513513
},
514514
],
515515
},
516+
'ReactCommon/callinvoker/React-callinvoker.podspec': {
517+
name: 'React-callinvoker',
518+
headerPatterns: ['**/*.h'],
519+
excludePatterns: ['React/**'],
520+
headerDir: 'ReactCommon',
521+
subSpecs: [
522+
{
523+
name: 'CallInvokerUmbrella',
524+
headerPatterns: ['React/*.h'],
525+
headerDir: 'React',
526+
},
527+
],
528+
},
516529
'React-Core.podspec': {
517530
name: 'React-Core',
518531
headerPatterns: [],

0 commit comments

Comments
 (0)