Commit 3b66079
Define RN_BUILDING for React Native's own CMake, SwiftPM, and Buck targets
Summary:
Companion to the CocoaPods change: does the same for the other three build systems, so
every build has exactly one place that states "these targets are React Native's own".
React Native's public C++ headers are gaining guards from `react/cxxstableapi`, which
turn a direct include of a fine-grained header into an error for consumers that opt into
the strict API by defining `RN_STRICT_API`. React Native's own sources keep including
those headers directly, so they are exempted via `RN_BUILDING`.
Unlike CocoaPods, these three build systems each have a single chokepoint:
- CMake: one `add_compile_definitions(RN_BUILDING)` in the ReactAndroid JNI project,
a directory property inherited by every `add_react_common_subdir` below it. It is
declared *after* the third-party NDK subdirectories so glog/boost/folly/fmt never see
it, and this project never compiles app or third-party module code — those build
against the prefab artifacts through `ReactNative-application.cmake`. For that reason
the flag deliberately does NOT go into `target_compile_reactnative_options`, which app
and third-party module builds do call.
- SwiftPM: one `.define` in the shared `Target.reactNativeTarget` factory that every
React Native target is created through. `cxxSettings` are per-target and are not
inherited by packages that depend on React.
- Buck: a `_set_rn_building_flag` helper called from the four macros React Native's own
targets use. These macros are also used by ~300 product packages that *consume* React
Native, and those must stay subject to the guards, so the flag is scoped by package
prefix rather than applied unconditionally. It is `preprocessor_flags`, deliberately
not `exported_preprocessor_flags`, so dependents are not exempted either.
This change is inert on its own: nothing behaves differently unless a consumer defines
`RN_STRICT_API`.
Changelog: [Internal]
Differential Revision: D1150510881 parent a007a2e commit 3b66079
2 files changed
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
948 | 948 | | |
949 | 949 | | |
950 | 950 | | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
951 | 955 | | |
952 | 956 | | |
953 | 957 | | |
| |||
956 | 960 | | |
957 | 961 | | |
958 | 962 | | |
| 963 | + | |
959 | 964 | | |
960 | 965 | | |
961 | 966 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
61 | 69 | | |
62 | 70 | | |
63 | 71 | | |
| |||
0 commit comments