basalt-core 0.0.0-rc5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (325) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cli/basalt.d.ts +3 -0
  3. package/dist/cli/basalt.d.ts.map +1 -0
  4. package/dist/cli/basalt.js +47 -0
  5. package/dist/cli/basalt.js.map +1 -0
  6. package/dist/cli/bundle-cli.d.ts +12 -0
  7. package/dist/cli/bundle-cli.d.ts.map +1 -0
  8. package/dist/cli/bundle-cli.js +124 -0
  9. package/dist/cli/bundle-cli.js.map +1 -0
  10. package/dist/cli/bundleWithAssets.d.ts +79 -0
  11. package/dist/cli/bundleWithAssets.d.ts.map +1 -0
  12. package/dist/cli/bundleWithAssets.js +198 -0
  13. package/dist/cli/bundleWithAssets.js.map +1 -0
  14. package/dist/cli/desktop.d.ts +339 -0
  15. package/dist/cli/desktop.d.ts.map +1 -0
  16. package/dist/cli/desktop.js +1029 -0
  17. package/dist/cli/desktop.js.map +1 -0
  18. package/dist/cli/doctor.d.ts +31 -0
  19. package/dist/cli/doctor.d.ts.map +1 -0
  20. package/dist/cli/doctor.js +283 -0
  21. package/dist/cli/doctor.js.map +1 -0
  22. package/dist/cli/init.d.ts +77 -0
  23. package/dist/cli/init.d.ts.map +1 -0
  24. package/dist/cli/init.js +442 -0
  25. package/dist/cli/init.js.map +1 -0
  26. package/dist/cli/metro.d.ts +49 -0
  27. package/dist/cli/metro.d.ts.map +1 -0
  28. package/dist/cli/metro.js +148 -0
  29. package/dist/cli/metro.js.map +1 -0
  30. package/dist/cli/packageApp.d.ts +102 -0
  31. package/dist/cli/packageApp.d.ts.map +1 -0
  32. package/dist/cli/packageApp.js +319 -0
  33. package/dist/cli/packageApp.js.map +1 -0
  34. package/dist/cli/steps.d.ts +34 -0
  35. package/dist/cli/steps.d.ts.map +1 -0
  36. package/dist/cli/steps.js +53 -0
  37. package/dist/cli/steps.js.map +1 -0
  38. package/dist/metro-config.d.ts +168 -0
  39. package/dist/metro-config.d.ts.map +1 -0
  40. package/dist/metro-config.js +671 -0
  41. package/dist/metro-config.js.map +1 -0
  42. package/dist/react-native.config.d.ts +7 -0
  43. package/dist/react-native.config.d.ts.map +1 -0
  44. package/dist/react-native.config.js +80 -0
  45. package/dist/react-native.config.js.map +1 -0
  46. package/dist/src/DragSource.d.ts +52 -0
  47. package/dist/src/DragSource.d.ts.map +1 -0
  48. package/dist/src/DragSource.js +97 -0
  49. package/dist/src/DragSource.js.map +1 -0
  50. package/dist/src/DropTarget.d.ts +58 -0
  51. package/dist/src/DropTarget.d.ts.map +1 -0
  52. package/dist/src/DropTarget.js +131 -0
  53. package/dist/src/DropTarget.js.map +1 -0
  54. package/dist/src/KeyHandler.d.ts +57 -0
  55. package/dist/src/KeyHandler.d.ts.map +1 -0
  56. package/dist/src/KeyHandler.js +48 -0
  57. package/dist/src/KeyHandler.js.map +1 -0
  58. package/dist/src/Menu.d.ts +72 -0
  59. package/dist/src/Menu.d.ts.map +1 -0
  60. package/dist/src/Menu.js +179 -0
  61. package/dist/src/Menu.js.map +1 -0
  62. package/dist/src/TitleBar.d.ts +75 -0
  63. package/dist/src/TitleBar.d.ts.map +1 -0
  64. package/dist/src/TitleBar.js +236 -0
  65. package/dist/src/TitleBar.js.map +1 -0
  66. package/dist/src/Window.d.ts +87 -0
  67. package/dist/src/Window.d.ts.map +1 -0
  68. package/dist/src/Window.js +248 -0
  69. package/dist/src/Window.js.map +1 -0
  70. package/dist/src/closeRequest.d.ts +55 -0
  71. package/dist/src/closeRequest.d.ts.map +1 -0
  72. package/dist/src/closeRequest.js +134 -0
  73. package/dist/src/closeRequest.js.map +1 -0
  74. package/dist/src/index.d.ts +45 -0
  75. package/dist/src/index.d.ts.map +1 -0
  76. package/dist/src/index.js +92 -0
  77. package/dist/src/index.js.map +1 -0
  78. package/dist/src/overrides/Alert.d.ts +69 -0
  79. package/dist/src/overrides/Alert.d.ts.map +1 -0
  80. package/dist/src/overrides/Alert.js +112 -0
  81. package/dist/src/overrides/Alert.js.map +1 -0
  82. package/dist/src/overrides/BaseViewConfig.d.ts +28 -0
  83. package/dist/src/overrides/BaseViewConfig.d.ts.map +1 -0
  84. package/dist/src/overrides/BaseViewConfig.js +72 -0
  85. package/dist/src/overrides/BaseViewConfig.js.map +1 -0
  86. package/dist/src/overrides/Platform.linux.d.ts +10 -0
  87. package/dist/src/overrides/Platform.linux.d.ts.map +1 -0
  88. package/dist/src/overrides/Platform.linux.js +15 -0
  89. package/dist/src/overrides/Platform.linux.js.map +1 -0
  90. package/dist/src/overrides/Platform.macos.d.ts +10 -0
  91. package/dist/src/overrides/Platform.macos.d.ts.map +1 -0
  92. package/dist/src/overrides/Platform.macos.js +15 -0
  93. package/dist/src/overrides/Platform.macos.js.map +1 -0
  94. package/dist/src/overrides/Platform.windows.d.ts +10 -0
  95. package/dist/src/overrides/Platform.windows.d.ts.map +1 -0
  96. package/dist/src/overrides/Platform.windows.js +15 -0
  97. package/dist/src/overrides/Platform.windows.js.map +1 -0
  98. package/dist/src/overrides/ReactDevToolsSettingsManager.d.ts +24 -0
  99. package/dist/src/overrides/ReactDevToolsSettingsManager.d.ts.map +1 -0
  100. package/dist/src/overrides/ReactDevToolsSettingsManager.js +30 -0
  101. package/dist/src/overrides/ReactDevToolsSettingsManager.js.map +1 -0
  102. package/dist/src/overrides/RefreshControl.d.ts +52 -0
  103. package/dist/src/overrides/RefreshControl.d.ts.map +1 -0
  104. package/dist/src/overrides/RefreshControl.js +92 -0
  105. package/dist/src/overrides/RefreshControl.js.map +1 -0
  106. package/dist/src/overrides/ScrollView.d.ts +39 -0
  107. package/dist/src/overrides/ScrollView.d.ts.map +1 -0
  108. package/dist/src/overrides/ScrollView.js +59 -0
  109. package/dist/src/overrides/ScrollView.js.map +1 -0
  110. package/dist/src/overrides/Share.d.ts +96 -0
  111. package/dist/src/overrides/Share.d.ts.map +1 -0
  112. package/dist/src/overrides/Share.js +97 -0
  113. package/dist/src/overrides/Share.js.map +1 -0
  114. package/dist/src/overrides/TextInput.d.ts +81 -0
  115. package/dist/src/overrides/TextInput.d.ts.map +1 -0
  116. package/dist/src/overrides/TextInput.js +213 -0
  117. package/dist/src/overrides/TextInput.js.map +1 -0
  118. package/dist/src/overrides/View.d.ts +36 -0
  119. package/dist/src/overrides/View.d.ts.map +1 -0
  120. package/dist/src/overrides/View.js +99 -0
  121. package/dist/src/overrides/View.js.map +1 -0
  122. package/dist/src/overrides/createPlatform.d.ts +32 -0
  123. package/dist/src/overrides/createPlatform.d.ts.map +1 -0
  124. package/dist/src/overrides/createPlatform.js +84 -0
  125. package/dist/src/overrides/createPlatform.js.map +1 -0
  126. package/dist/src/overrides/setUpDeveloperTools.d.ts +28 -0
  127. package/dist/src/overrides/setUpDeveloperTools.d.ts.map +1 -0
  128. package/dist/src/overrides/setUpDeveloperTools.js +84 -0
  129. package/dist/src/overrides/setUpDeveloperTools.js.map +1 -0
  130. package/dist/src/overrides/setUpXHR.d.ts +46 -0
  131. package/dist/src/overrides/setUpXHR.d.ts.map +1 -0
  132. package/dist/src/overrides/setUpXHR.js +236 -0
  133. package/dist/src/overrides/setUpXHR.js.map +1 -0
  134. package/dist/src/quitRequest.d.ts +55 -0
  135. package/dist/src/quitRequest.d.ts.map +1 -0
  136. package/dist/src/quitRequest.js +121 -0
  137. package/dist/src/quitRequest.js.map +1 -0
  138. package/dist/src/resourcePath.d.ts +18 -0
  139. package/dist/src/resourcePath.d.ts.map +1 -0
  140. package/dist/src/resourcePath.js +31 -0
  141. package/dist/src/resourcePath.js.map +1 -0
  142. package/dist/src/responseBody.d.ts +76 -0
  143. package/dist/src/responseBody.d.ts.map +1 -0
  144. package/dist/src/responseBody.js +94 -0
  145. package/dist/src/responseBody.js.map +1 -0
  146. package/dist/src/responseHeaders.d.ts +40 -0
  147. package/dist/src/responseHeaders.d.ts.map +1 -0
  148. package/dist/src/responseHeaders.js +75 -0
  149. package/dist/src/responseHeaders.js.map +1 -0
  150. package/dist/src/titleBarState.d.ts +43 -0
  151. package/dist/src/titleBarState.d.ts.map +1 -0
  152. package/dist/src/titleBarState.js +77 -0
  153. package/dist/src/titleBarState.js.map +1 -0
  154. package/dist/src/useContextMenu.d.ts +113 -0
  155. package/dist/src/useContextMenu.d.ts.map +1 -0
  156. package/dist/src/useContextMenu.js +109 -0
  157. package/dist/src/useContextMenu.js.map +1 -0
  158. package/dist/src/useDialog.d.ts +98 -0
  159. package/dist/src/useDialog.d.ts.map +1 -0
  160. package/dist/src/useDialog.js +112 -0
  161. package/dist/src/useDialog.js.map +1 -0
  162. package/dist/src/useDisplays.d.ts +70 -0
  163. package/dist/src/useDisplays.d.ts.map +1 -0
  164. package/dist/src/useDisplays.js +118 -0
  165. package/dist/src/useDisplays.js.map +1 -0
  166. package/dist/src/useHandledKeys.d.ts +38 -0
  167. package/dist/src/useHandledKeys.d.ts.map +1 -0
  168. package/dist/src/useHandledKeys.js +70 -0
  169. package/dist/src/useHandledKeys.js.map +1 -0
  170. package/dist/src/useWindow.d.ts +140 -0
  171. package/dist/src/useWindow.d.ts.map +1 -0
  172. package/dist/src/useWindow.js +233 -0
  173. package/dist/src/useWindow.js.map +1 -0
  174. package/dist/tsconfig.tsbuildinfo +1 -0
  175. package/native/CMakeLists.txt +355 -0
  176. package/native/bootstrap.sh +613 -0
  177. package/native/cmake/CompilerFlags.cmake +49 -0
  178. package/native/cmake/Expo.cmake +125 -0
  179. package/native/cmake/ReactNativeCore.cmake +612 -0
  180. package/native/cmake/Reanimated.cmake +108 -0
  181. package/native/cmake/Skia.cmake +379 -0
  182. package/native/cmake/ThirdParty.cmake +290 -0
  183. package/native/cmake/Worklets.cmake +67 -0
  184. package/native/cmake/codegen/CMakeLists.txt +32 -0
  185. package/native/core/AppIdentity.cpp +85 -0
  186. package/native/core/AppIdentity.h +59 -0
  187. package/native/core/AppPaths.cpp +96 -0
  188. package/native/core/AppPaths.h +53 -0
  189. package/native/core/AppearanceModule.cpp +60 -0
  190. package/native/core/AppearanceModule.h +40 -0
  191. package/native/core/Backface.h +59 -0
  192. package/native/core/BlobModule.cpp +283 -0
  193. package/native/core/BlobModule.h +76 -0
  194. package/native/core/BlobRegistry.cpp +75 -0
  195. package/native/core/BlobRegistry.h +44 -0
  196. package/native/core/ColorScheme.cpp +105 -0
  197. package/native/core/ColorScheme.h +59 -0
  198. package/native/core/ComponentRegistry.h +30 -0
  199. package/native/core/ControlMetrics.h +37 -0
  200. package/native/core/CoreModules.cpp +592 -0
  201. package/native/core/CoreModules.h +308 -0
  202. package/native/core/DebuggingOverlay.cpp +106 -0
  203. package/native/core/DebuggingOverlay.h +65 -0
  204. package/native/core/DesktopControls.cpp +232 -0
  205. package/native/core/DesktopControls.h +170 -0
  206. package/native/core/DevBundle.cpp +108 -0
  207. package/native/core/DevBundle.h +69 -0
  208. package/native/core/DevMenu.cpp +99 -0
  209. package/native/core/DevMenu.h +75 -0
  210. package/native/core/DialogModule.cpp +150 -0
  211. package/native/core/DialogModule.h +51 -0
  212. package/native/core/DragAndDrop.cpp +45 -0
  213. package/native/core/DragAndDrop.h +225 -0
  214. package/native/core/ExpoImageComponent.cpp +79 -0
  215. package/native/core/ExpoImageComponent.h +80 -0
  216. package/native/core/ExpoModules.cpp +415 -0
  217. package/native/core/ExpoModules.h +115 -0
  218. package/native/core/ExpoRuntime.cpp +366 -0
  219. package/native/core/ExpoRuntime.h +42 -0
  220. package/native/core/FocusRing.h +36 -0
  221. package/native/core/FontRegistry.h +51 -0
  222. package/native/core/GestureHandlerModule.cpp +136 -0
  223. package/native/core/GestureHandlerModule.h +71 -0
  224. package/native/core/Gestures.cpp +533 -0
  225. package/native/core/Gestures.h +145 -0
  226. package/native/core/HoverTracker.cpp +69 -0
  227. package/native/core/HoverTracker.h +109 -0
  228. package/native/core/HttpClient.cpp +282 -0
  229. package/native/core/ImageBytes.cpp +205 -0
  230. package/native/core/ImageBytes.h +29 -0
  231. package/native/core/ImageCache.cpp +51 -0
  232. package/native/core/ImageCache.h +89 -0
  233. package/native/core/JsRuntimeAccess.cpp +70 -0
  234. package/native/core/JsRuntimeAccess.h +60 -0
  235. package/native/core/JsiPromise.h +51 -0
  236. package/native/core/KeyEvents.cpp +116 -0
  237. package/native/core/KeyEvents.h +144 -0
  238. package/native/core/LogBoxSurface.cpp +46 -0
  239. package/native/core/LogBoxSurface.h +68 -0
  240. package/native/core/MenuModel.h +117 -0
  241. package/native/core/MenuModule.cpp +209 -0
  242. package/native/core/MenuModule.h +66 -0
  243. package/native/core/MountingWalk.h +524 -0
  244. package/native/core/PackageModules.cpp.in +25 -0
  245. package/native/core/PackageModules.h +50 -0
  246. package/native/core/PlatformConstantsModule.cpp +63 -0
  247. package/native/core/PlatformConstantsModule.h +64 -0
  248. package/native/core/PlatformServices.h +213 -0
  249. package/native/core/PointerButtons.h +63 -0
  250. package/native/core/PullToRefresh.cpp +57 -0
  251. package/native/core/PullToRefresh.h +73 -0
  252. package/native/core/ReanimatedCompat.h +47 -0
  253. package/native/core/ReanimatedModule.cpp +203 -0
  254. package/native/core/ReanimatedModule.h +55 -0
  255. package/native/core/ScrollAnimation.cpp +59 -0
  256. package/native/core/ScrollAnimation.h +70 -0
  257. package/native/core/ScrollBounds.cpp +26 -0
  258. package/native/core/ScrollBounds.h +68 -0
  259. package/native/core/ScrollIndicator.cpp +50 -0
  260. package/native/core/ScrollIndicator.h +69 -0
  261. package/native/core/ScrollMomentum.cpp +71 -0
  262. package/native/core/ScrollMomentum.h +73 -0
  263. package/native/core/ScrollSnap.cpp +123 -0
  264. package/native/core/ScrollSnap.h +80 -0
  265. package/native/core/ShareFallback.cpp +101 -0
  266. package/native/core/ShareFallback.h +45 -0
  267. package/native/core/SkiaPictureViewComponent.cpp +11 -0
  268. package/native/core/SkiaPictureViewComponent.h +47 -0
  269. package/native/core/SourceCodeModule.cpp +55 -0
  270. package/native/core/SourceCodeModule.h +53 -0
  271. package/native/core/StatusBarModule.cpp +23 -0
  272. package/native/core/StatusBarModule.h +42 -0
  273. package/native/core/TestDialog.cpp +148 -0
  274. package/native/core/TestDialog.h +96 -0
  275. package/native/core/TestKeys.cpp +78 -0
  276. package/native/core/TestKeys.h +50 -0
  277. package/native/core/TestQuitFile.cpp +33 -0
  278. package/native/core/TestQuitFile.h +60 -0
  279. package/native/core/TestSettle.h +192 -0
  280. package/native/core/TitleBarRegions.h +31 -0
  281. package/native/core/TurboModuleProxy.cpp +51 -0
  282. package/native/core/TurboModuleProxy.h +46 -0
  283. package/native/core/UIManagerAccess.cpp +43 -0
  284. package/native/core/UIManagerAccess.h +43 -0
  285. package/native/core/WindowBoundsCache.cpp +319 -0
  286. package/native/core/WindowControl.h +235 -0
  287. package/native/core/WindowHost.h +158 -0
  288. package/native/core/WindowMethods.cpp +167 -0
  289. package/native/core/WindowMethods.h +84 -0
  290. package/native/core/WindowsModule.cpp +448 -0
  291. package/native/core/WindowsModule.h +133 -0
  292. package/native/core/WorkletsModule.cpp +199 -0
  293. package/native/core/WorkletsModule.h +57 -0
  294. package/native/core/portability_probe.cpp +210 -0
  295. package/native/tests/EventRecorder.h +124 -0
  296. package/native/tests/TestHarness.cpp +109 -0
  297. package/native/tests/TestHarness.h +89 -0
  298. package/native/tests/TreeDump.h +49 -0
  299. package/native/tests/test_app_identity.cpp +114 -0
  300. package/native/tests/test_app_paths.cpp +48 -0
  301. package/native/tests/test_appearance.cpp +107 -0
  302. package/native/tests/test_backface.cpp +79 -0
  303. package/native/tests/test_blobs.cpp +157 -0
  304. package/native/tests/test_controls.cpp +185 -0
  305. package/native/tests/test_devbundle.cpp +103 -0
  306. package/native/tests/test_drag_and_drop.cpp +143 -0
  307. package/native/tests/test_gestures.cpp +331 -0
  308. package/native/tests/test_hover.cpp +92 -0
  309. package/native/tests/test_image_cache.cpp +109 -0
  310. package/native/tests/test_js_runtime_access.cpp +137 -0
  311. package/native/tests/test_key_events.cpp +235 -0
  312. package/native/tests/test_momentum.cpp +138 -0
  313. package/native/tests/test_quit_file.cpp +104 -0
  314. package/native/tests/test_scroll_animation.cpp +120 -0
  315. package/native/tests/test_scroll_bounds.cpp +66 -0
  316. package/native/tests/test_scroll_indicator.cpp +149 -0
  317. package/native/tests/test_scroll_snap.cpp +112 -0
  318. package/native/tests/test_settle.cpp +115 -0
  319. package/native/tests/test_share.cpp +75 -0
  320. package/native/tests/test_sourcecode.cpp +62 -0
  321. package/native/tests/test_window_close.cpp +119 -0
  322. package/native/tests/test_window_limits.cpp +123 -0
  323. package/package.json +43 -0
  324. package/react-native.config.js +86 -0
  325. package/supported-versions.json +66 -0
@@ -0,0 +1,612 @@
1
+ # Adds the React Native C++ targets a host needs in order to run Fabric's
2
+ # mounting layer.
3
+ #
4
+ # This is the transitive closure of react_renderer_mounting, computed from the
5
+ # target_link_libraries in RN's own CMakeLists. Notably it contains no Hermes:
6
+ # constructing and applying mutations does not require a JS runtime. Adding one
7
+ # (react/runtime + react/runtime/hermes) is a separate, later step.
8
+
9
+ set(REACT_COMMON_DIR ${RN_DIR}/ReactCommon)
10
+ # jsinspector-modern's CMakeLists include SoMerging-utils.cmake from here. It
11
+ # is an Android .so-merging helper that no-ops off-Android, but the include
12
+ # path must still resolve.
13
+ set(REACT_ANDROID_DIR ${RN_DIR}/ReactAndroid)
14
+
15
+ # Several RN CMakeLists call react_native_android_selector() without including
16
+ # the file that defines it, relying on a parent scope having done so.
17
+ include(${REACT_COMMON_DIR}/cmake-utils/internal/react-native-platform-selector.cmake)
18
+ if(DEFINED RN_CXX_PLATFORM_OVERRIDE)
19
+ set(REACT_CXX_PLATFORM_DIR ${RN_CXX_PLATFORM_OVERRIDE})
20
+ else()
21
+ set(REACT_CXX_PLATFORM_DIR ${RN_DIR}/ReactCxxPlatform)
22
+ endif()
23
+
24
+ # The version being built against, for the messages below and for anyone
25
+ # wondering which React Native a given build came from. `main` calls itself
26
+ # 1000.0.0, which is React Native's placeholder for "not a release" and reads
27
+ # as exactly that in the output. Parsed with a regex rather than string(JSON)
28
+ # to keep the CMake floor where it is.
29
+ file(READ ${RN_DIR}/package.json RN_PACKAGE_JSON)
30
+ string(REGEX MATCH "\"version\"[ \t]*:[ \t]*\"([^\"]+)\"" _ ${RN_PACKAGE_JSON})
31
+ set(RN_VERSION ${CMAKE_MATCH_1})
32
+ message(STATUS "React Native ${RN_VERSION} (${RN_DIR})")
33
+
34
+ # Reported to JavaScript by core/PlatformConstantsModule.cpp, which exists
35
+ # because ReactCxxPlatform hardcodes 1000.0.0 and so can never match a release.
36
+ add_compile_definitions(BASALT_REACT_NATIVE_VERSION="${RN_VERSION}")
37
+
38
+ # The minor, as a number, for the handful of places this platform's own sources
39
+ # have to differ between supported React Natives. `main` calls itself 1000.0.0,
40
+ # which sorts above every release, which is what you want.
41
+ string(REGEX MATCH "^([0-9]+)\\.([0-9]+)" _ ${RN_VERSION})
42
+ math(EXPR RN_MINOR "${CMAKE_MATCH_1} * 1000 + ${CMAKE_MATCH_2}")
43
+ add_compile_definitions(BASALT_RN_MINOR=${RN_MINOR})
44
+ message(STATUS "React Native minor code ${RN_MINOR}")
45
+
46
+ # Codegen output belongs to exactly one React Native version: the generated
47
+ # spec headers name every feature flag that version has. Building against a
48
+ # different one fails deep inside React Native's own sources, on flags that
49
+ # look like they should exist, and says nothing about the real cause. Ask here
50
+ # instead, where the answer is a single command.
51
+ # Nothing here without bootstrap. Checked before the version stamp because an
52
+ # absent directory and a stale one need the same command, and because CMake's
53
+ # own complaint further down names a missing CMakeLists.txt, which sends you
54
+ # looking for a file this project does not ask you to write.
55
+ if(NOT EXISTS ${BASALT_THIRD_PARTY}/codegen/CMakeLists.txt)
56
+ get_filename_component(RN_MONOREPO_DIR "${RN_DIR}/../.." ABSOLUTE)
57
+ message(FATAL_ERROR
58
+ "no codegen output at ${BASALT_THIRD_PARTY}/codegen.\n"
59
+ "Generate it with:\n"
60
+ " scripts/bootstrap.sh ${RN_MONOREPO_DIR}\n")
61
+ endif()
62
+
63
+ set(RN_CODEGEN_STAMP ${BASALT_THIRD_PARTY}/codegen/.react-native-version)
64
+ if(EXISTS ${RN_CODEGEN_STAMP})
65
+ file(READ ${RN_CODEGEN_STAMP} RN_CODEGEN_VERSION)
66
+ string(STRIP "${RN_CODEGEN_VERSION}" RN_CODEGEN_VERSION)
67
+ if(NOT RN_CODEGEN_VERSION STREQUAL RN_VERSION)
68
+ get_filename_component(RN_MONOREPO_DIR "${RN_DIR}/../.." ABSOLUTE)
69
+ message(FATAL_ERROR
70
+ "third_party/codegen was generated from React Native ${RN_CODEGEN_VERSION}, "
71
+ "but this build is against ${RN_VERSION}.\n"
72
+ "Regenerate it with:\n"
73
+ " scripts/bootstrap.sh ${RN_MONOREPO_DIR}\n")
74
+ endif()
75
+ endif()
76
+
77
+ # Skips a directory this React Native does not have, rather than failing.
78
+ #
79
+ # The list below is written against `main`, and a release is `main` minus
80
+ # whatever landed after it -- 0.87.1, for instance, has no ResizeObserver. A
81
+ # hard failure there would mean one build file per supported version, so
82
+ # absence is reported and carried on from instead. What is skipped is printed,
83
+ # because silently building less than intended is the worse failure.
84
+ function(add_react_common_subdir relative_path)
85
+ if(NOT EXISTS ${REACT_COMMON_DIR}/${relative_path}/CMakeLists.txt)
86
+ set(RN_SKIPPED_SUBDIRS ${RN_SKIPPED_SUBDIRS} ${relative_path} PARENT_SCOPE)
87
+ return()
88
+ endif()
89
+ add_subdirectory(${REACT_COMMON_DIR}/${relative_path} ReactCommon/${relative_path})
90
+ endfunction()
91
+
92
+ set(RN_CORE_SUBDIRS
93
+ callinvoker
94
+ cxxreact
95
+ devtoolsruntimesettings
96
+ hermes/executor
97
+ hermes/inspector-modern
98
+ jserrorhandler
99
+ jsi
100
+ jsiexecutor
101
+ jsinspector-modern
102
+ jsinspector-modern/cdp
103
+ jsinspector-modern/network
104
+ jsinspector-modern/tracing
105
+ jsitooling
106
+ logger
107
+ oscompat
108
+ react/bridging
109
+ react/cxxstableapi
110
+ react/debug
111
+ react/featureflags
112
+ react/nativemodule/core
113
+ # Deliberately not react/nativemodule/cputime. React Native ships that
114
+ # module's C++ in the npm package but not its codegen spec, which lives
115
+ # under src/private/testing/fantom and is excluded, so it cannot be
116
+ # built from an installed React Native at all. Nothing links it -- it is
117
+ # a Fantom testing module -- so this platform simply does not build it.
118
+ react/nativemodule/defaults
119
+ react/nativemodule/devtoolsruntimesettings
120
+ react/nativemodule/dom
121
+ react/nativemodule/featureflags
122
+ react/nativemodule/idlecallbacks
123
+ react/nativemodule/intersectionobserver
124
+ react/nativemodule/microtasks
125
+ react/nativemodule/mutationobserver
126
+ react/nativemodule/resizeobserver
127
+ react/nativemodule/viewtransition
128
+ react/nativemodule/webperformance
129
+ react/performance/cdpmetrics
130
+ react/performance/timeline
131
+ react/renderer/animated
132
+ react/renderer/animationbackend
133
+ react/renderer/attributedstring
134
+ react/renderer/bridging
135
+ react/renderer/componentregistry
136
+ react/renderer/componentregistry/native
137
+ react/renderer/components/image
138
+ react/renderer/components/legacyviewmanagerinterop
139
+ react/renderer/components/modal
140
+ react/renderer/components/root
141
+ react/renderer/components/scrollview
142
+ react/renderer/components/text
143
+ react/renderer/components/view
144
+ react/renderer/consistency
145
+ react/renderer/core
146
+ react/renderer/css
147
+ react/renderer/debug
148
+ react/renderer/dom
149
+ react/renderer/graphics
150
+ react/renderer/imagemanager
151
+ react/renderer/leakchecker
152
+ react/renderer/mapbuffer
153
+ react/renderer/mounting
154
+ react/renderer/observers/events
155
+ react/renderer/observers/intersection
156
+ react/renderer/observers/mutation
157
+ react/renderer/observers/resize
158
+ react/renderer/runtimescheduler
159
+ react/renderer/scheduler
160
+ react/renderer/telemetry
161
+ react/renderer/textlayoutmanager
162
+ react/renderer/uimanager
163
+ react/renderer/uimanager/consistency
164
+ react/renderer/viewtransition
165
+ react/runtime
166
+ react/runtime/hermes
167
+ react/timing
168
+ react/utils
169
+ reactperflogger
170
+ runtimeexecutor
171
+ yoga)
172
+
173
+ # Seams with per-platform variants: a host must choose one of each, globally,
174
+ # before any RN target is added. Individual RN CMakeLists only add the variant
175
+ # dirs they own, so a target like componentregistry -- which includes ViewProps
176
+ # transitively -- otherwise cannot find HostPlatformViewProps.h.
177
+ include_directories(
178
+ ${REACT_COMMON_DIR}/react/renderer/graphics/platform/cxx
179
+ ${REACT_COMMON_DIR}/react/renderer/components/view/platform/cxx
180
+ ${REACT_COMMON_DIR}/react/renderer/textlayoutmanager/platform/cxx
181
+ ${REACT_COMMON_DIR}/react/renderer/imagemanager/platform/cxx
182
+ ${REACT_COMMON_DIR}/react/utils/platform/cxx
183
+ ${REACT_COMMON_DIR}/runtimeexecutor/platform/cxx)
184
+
185
+ set(RN_SKIPPED_SUBDIRS)
186
+ foreach(subdir ${RN_CORE_SUBDIRS})
187
+ add_react_common_subdir(${subdir})
188
+ endforeach()
189
+ if(RN_SKIPPED_SUBDIRS)
190
+ message(STATUS "React Native ${RN_VERSION} has no: ${RN_SKIPPED_SUBDIRS}")
191
+ endif()
192
+
193
+ # yoga/CMakeLists.txt descends into yoga/yoga, which names the target
194
+ # `yogacore`. RN's other CMakeLists link against `yoga`. Fantom bridges the
195
+ # two the same way.
196
+ add_library(yoga ALIAS yogacore)
197
+
198
+ # ---------------------------------------------------------------------------
199
+ # ReactCxxPlatform — the generic C++ platform: ReactHost, the scheduler
200
+ # delegate, http, io, logging, threading, devsupport, coremodules and the
201
+ # TurboModule host. This is the layer that makes a non-Apple, non-Android host
202
+ # possible at all.
203
+ # ---------------------------------------------------------------------------
204
+
205
+ # React Native's generated codegen artifacts. 24 targets depend on
206
+ # react_codegen_rncore, including ReactCxxPlatform's react/runtime -- where
207
+ # ReactHost lives -- so this is not optional for a host that runs JS.
208
+ add_subdirectory(${CODEGEN_DIR} codegen)
209
+
210
+ function(add_react_cxx_platform_subdir relative_path)
211
+ add_subdirectory(${REACT_CXX_PLATFORM_DIR}/${relative_path} ReactCxxPlatform/${relative_path})
212
+ endfunction()
213
+
214
+ set(RN_CXX_PLATFORM_SUBDIRS
215
+ react/coremodules
216
+ react/devsupport
217
+ react/http
218
+ react/io
219
+ react/logging
220
+ react/nativemodule
221
+ react/profiling
222
+ react/renderer/scheduler
223
+ react/renderer/uimanager
224
+ react/runtime
225
+ react/threading
226
+ react/utils)
227
+
228
+ foreach(subdir ${RN_CXX_PLATFORM_SUBDIRS})
229
+ add_react_cxx_platform_subdir(${subdir})
230
+ endforeach()
231
+
232
+ set(RN_CXX_PLATFORM_TARGETS
233
+ react_cxx_platform_react_coremodules
234
+ react_cxx_platform_react_devsupport
235
+ react_cxx_platform_react_http
236
+ react_cxx_platform_react_io
237
+ react_cxx_platform_react_logging
238
+ react_cxx_platform_react_nativemodule
239
+ react_cxx_platform_react_profiling
240
+ react_cxx_platform_react_renderer_scheduler
241
+ react_cxx_platform_react_renderer_uimanager
242
+ react_cxx_platform_react_runtime
243
+ react_cxx_platform_react_threading
244
+ react_cxx_platform_react_utils)
245
+
246
+ # Every RN target above is an OBJECT library; collect them into one thing that
247
+ # is convenient to link.
248
+ set(RN_CORE_OBJECT_TARGETS
249
+ bridgeless
250
+ bridgelesshermes
251
+ callinvoker
252
+ devtoolsruntimesettings
253
+ hermes_executor_common
254
+ hermes_inspector_modern
255
+ jserrorhandler
256
+ jsi
257
+ jsinspector
258
+ jsinspector_cdp
259
+ jsinspector_network
260
+ jsinspector_tracing
261
+ jsireact
262
+ jsitooling
263
+ logger
264
+ oscompat
265
+ react_bridging
266
+ react_cxxreact
267
+ react_cxxstableapi
268
+ react_debug
269
+ react_featureflags
270
+ react_nativemodule_core
271
+ react_nativemodule_defaults
272
+ react_nativemodule_devtoolsruntimesettings
273
+ react_nativemodule_dom
274
+ react_nativemodule_featureflags
275
+ react_nativemodule_idlecallbacks
276
+ react_nativemodule_intersectionobserver
277
+ react_nativemodule_microtasks
278
+ react_nativemodule_mutationobserver
279
+ react_nativemodule_resizeobserver
280
+ react_nativemodule_viewtransition
281
+ react_nativemodule_webperformance
282
+ react_performance_cdpmetrics
283
+ react_performance_timeline
284
+ react_renderer_animated
285
+ react_renderer_animationbackend
286
+ react_renderer_attributedstring
287
+ react_renderer_bridging
288
+ react_renderer_componentregistry
289
+ react_renderer_consistency
290
+ react_renderer_core
291
+ react_renderer_css
292
+ react_renderer_debug
293
+ react_renderer_dom
294
+ react_renderer_graphics
295
+ react_renderer_imagemanager
296
+ react_renderer_leakchecker
297
+ react_renderer_mapbuffer
298
+ react_renderer_mounting
299
+ react_renderer_observers_events
300
+ react_renderer_observers_intersection
301
+ react_renderer_observers_mutation
302
+ react_renderer_observers_resize
303
+ react_renderer_runtimescheduler
304
+ react_renderer_scheduler
305
+ react_renderer_telemetry
306
+ react_renderer_textlayoutmanager
307
+ react_renderer_uimanager
308
+ react_renderer_uimanager_consistency
309
+ react_renderer_viewtransition
310
+ react_timing
311
+ react_utils
312
+ reactperflogger
313
+ rrc_image
314
+ rrc_legacyviewmanagerinterop
315
+ rrc_modal
316
+ rrc_native
317
+ rrc_root
318
+ rrc_scrollview
319
+ rrc_text
320
+ rrc_view
321
+ runtimeexecutor)
322
+
323
+ # Must come after the set() above, which would otherwise overwrite it.
324
+ list(APPEND RN_CORE_OBJECT_TARGETS ${RN_CXX_PLATFORM_TARGETS})
325
+
326
+ # Same reasoning as add_react_common_subdir: a target belonging to a directory
327
+ # this version does not ship is not an error. Filtered here rather than at each
328
+ # use, so everything downstream can assume the list is real.
329
+ set(RN_PRESENT_TARGETS)
330
+ set(RN_ABSENT_TARGETS)
331
+ foreach(target ${RN_CORE_OBJECT_TARGETS})
332
+ if(TARGET ${target})
333
+ list(APPEND RN_PRESENT_TARGETS ${target})
334
+ else()
335
+ list(APPEND RN_ABSENT_TARGETS ${target})
336
+ endif()
337
+ endforeach()
338
+ if(RN_ABSENT_TARGETS)
339
+ message(STATUS "React Native ${RN_VERSION} defines no: ${RN_ABSENT_TARGETS}")
340
+ endif()
341
+ set(RN_CORE_OBJECT_TARGETS ${RN_PRESENT_TARGETS})
342
+
343
+ # Upstream portability bug: ReactCommon/jsinspector-modern/network/HttpUtils.h
344
+ # uses uint16_t without including <cstdint>. It compiles on Meta's toolchains
345
+ # only via transitive includes. Force-including <cstdint> fixes it without
346
+ # patching the React Native checkout, and is harmless everywhere else.
347
+ # React Native's own targets build with -Werror, and on Linux clang uses
348
+ # libstdc++, whose std::bind instantiates the deprecated std::result_of
349
+ # internally (ReactCommon/cxxreact/CxxModule.h:83 is the trigger). libc++ --
350
+ # what Apple platforms and the Android NDK use -- does not, which is why this
351
+ # only appears here. Nothing in React Native's code is actually wrong, so the
352
+ # warning is suppressed rather than worked around.
353
+ #
354
+ # libc++ would avoid it, but every other dependency on a Linux distro
355
+ # (glog, fmt, boost_regex, double-conversion) is built against libstdc++, and
356
+ # mixing the two is an ABI hazard for anything passing a std::string.
357
+ set(RN_EXTRA_FLAGS ${BASALT_FORCE_INCLUDE_CSTDINT_FLAG})
358
+ if(NOT APPLE AND NOT WIN32)
359
+ list(APPEND RN_EXTRA_FLAGS ${BASALT_NO_DEPRECATED_FLAG})
360
+ endif()
361
+
362
+ # --- React Native's own flags, on a compiler they were not written for -------
363
+ #
364
+ # ReactCommon/cmake-utils/react-native-flags.cmake puts this on every target it
365
+ # touches:
366
+ #
367
+ # -Wall -Werror -fexceptions -frtti -std=c++20
368
+ #
369
+ # and immediately below it says `TODO T228344694 improve this so that it works
370
+ # for all platforms`, which is this problem, acknowledged upstream and not yet
371
+ # fixed. Three of those five are clang command-line spellings that MSVC's front
372
+ # end does not have, and `-std=c++20` is actively harmful: clang-cl discards it
373
+ # with a warning, and cl would take it as a filename.
374
+ #
375
+ # Patching the checkout is not an option -- nothing here modifies React Native,
376
+ # which is the property that lets this platform track it. Removing the flags
377
+ # from each target afterwards was tried and does not work either: React Native
378
+ # applies them PUBLIC, so every copy also lives in the INTERFACE_COMPILE_OPTIONS
379
+ # of everything a target links, and they come back on the command line *after*
380
+ # the ones taken off. Chasing them through the link graph would be a fight with
381
+ # the build system on every upstream bump.
382
+ #
383
+ # So the flags are left alone and clang-cl is told not to treat its own
384
+ # "I ignored this" as an error. That is the honest reading of the situation:
385
+ # clang-cl is right to ignore them, and nothing is lost by it. `-std=c++20` is
386
+ # already supplied as `/std:c++20` from CXX_STANDARD, and exceptions and RTTI
387
+ # are added below in MSVC's spelling -- so all three are in force, just spelled
388
+ # the other way. `-Wall -Werror` are understood by clang-cl and kept, because
389
+ # building React Native's C++ warning-free is what catches an upstream change
390
+ # early.
391
+ #
392
+ # This is also why the core build needs clang-cl rather than cl. cl does not
393
+ # understand `-Werror` or clang's `-Wall` at all, and its own `/Wall` is a
394
+ # different and far noisier set; the Windows *view layer* builds fine with
395
+ # either, and CI uses cl for it.
396
+ if(WIN32)
397
+ if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
398
+ message(WARNING
399
+ "The Windows core build expects clang-cl. React Native's own CMake sets "
400
+ "clang-style flags (see ReactCommon/cmake-utils/react-native-flags.cmake "
401
+ "and its TODO T228344694), which cl does not understand. Configure with "
402
+ "-DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl.")
403
+ endif()
404
+ # And `-Wall` is worse than ignored -- it is misread. To clang-cl the token
405
+ # `-Wall` is MSVC's `/Wall`, which it maps to clang's `-Weverything`: not
406
+ # "the usual warnings" but *every* warning clang has, including
407
+ # -Wc++98-compat, which fires on every nested namespace and defaulted
408
+ # constructor in a C++20 codebase. React Native's own header for the event
409
+ # beat produces about forty errors from that alone.
410
+ #
411
+ # `-Wno-everything` undoes the misreading. What it does not do is restore
412
+ # what React Native meant, so React Native's C++ is compiled here with its
413
+ # warnings off -- which is a real loss, because warning-free upstream code is
414
+ # what catches an API change early, and it is why the Linux build stays the
415
+ # one that guards that. Recorded in docs/BACKLOG.md rather than papered over.
416
+ #
417
+ # This project's *own* sources are unaffected: they are held to /W4
418
+ # /permissive- by the platform package, and none of this reaches them.
419
+ # Applied at the bottom of this file, to every target in the build graph
420
+ # rather than to a list -- see the walk there for why.
421
+ set(RN_WINDOWS_FLAGS
422
+ -Wno-unknown-argument
423
+ -Wno-everything
424
+ # M_PI is a POSIX extension, not standard C++, and MSVC's <cmath> defines
425
+ # it only behind this. React Native's
426
+ # react/renderer/components/view/conversions.h uses it unguarded, seven
427
+ # times, to convert degrees for `transform: rotate`. The same shape of
428
+ # upstream portability bug as the missing <cstdint> above -- code that
429
+ # compiles on Meta's toolchains and nowhere else -- and the same kind of
430
+ # fix, on the command line rather than in their tree.
431
+ -D_USE_MATH_DEFINES
432
+ ${BASALT_EXCEPTIONS_FLAG}
433
+ ${BASALT_RTTI_FLAG})
434
+ endif()
435
+
436
+
437
+ foreach(target ${RN_CORE_OBJECT_TARGETS} yogacore)
438
+ if(TARGET ${target})
439
+ # A few RN targets are INTERFACE libraries, which reject PRIVATE options.
440
+ get_target_property(target_type ${target} TYPE)
441
+ if(NOT target_type STREQUAL "INTERFACE_LIBRARY")
442
+ target_compile_options(${target} PRIVATE ${RN_EXTRA_FLAGS})
443
+ endif()
444
+ endif()
445
+ endforeach()
446
+
447
+ add_library(rn_core INTERFACE)
448
+ foreach(target ${RN_CORE_OBJECT_TARGETS})
449
+ # target_link_libraries carries usage requirements (include dirs, defines);
450
+ # OBJECT libraries additionally need their objects named explicitly, or the
451
+ # final link comes up short on every symbol they define.
452
+ target_link_libraries(rn_core INTERFACE ${target})
453
+ # Some of these (e.g. callinvoker) are header-only INTERFACE libraries with
454
+ # no objects at all; $<TARGET_OBJECTS:> is an error on those.
455
+ get_target_property(target_type ${target} TYPE)
456
+ if(target_type STREQUAL "OBJECT_LIBRARY")
457
+ target_sources(rn_core INTERFACE $<TARGET_OBJECTS:${target}>)
458
+ endif()
459
+ endforeach()
460
+
461
+ # ---------------------------------------------------------------------------
462
+ # <TextInput>, from React Native's *iOS* variant.
463
+ #
464
+ # React Native's own rrc_textinput target globs the base sources plus
465
+ # platform/android, whose descriptor includes <fbjni/fbjni.h> and reaches into a
466
+ # Java FabricUIManager for theme padding -- unusable off Android.
467
+ #
468
+ # The iOS variant is pure C++: TextInputShadowNode measures through a
469
+ # TextLayoutManager, which on this platform is the Pango one, and nothing in it
470
+ # touches Objective-C or an Apple SDK. Its component name is "TextInput", which
471
+ # is the name packages/basalt-core' src/overrides/TextInput.js asks for.
472
+ #
473
+ # So this target takes the base sources and the iOS ones, and skips Android's.
474
+ # ---------------------------------------------------------------------------
475
+ set(RN_TEXTINPUT_DIR ${REACT_COMMON_DIR}/react/renderer/components/textinput)
476
+ file(GLOB rn_textinput_SRC CONFIGURE_DEPENDS
477
+ ${RN_TEXTINPUT_DIR}/*.cpp
478
+ ${RN_TEXTINPUT_DIR}/platform/ios/react/renderer/components/iostextinput/*.cpp)
479
+ add_library(rn_textinput OBJECT ${rn_textinput_SRC})
480
+ # SYSTEM, for the same reason basalt_gtk_mounting's React Native includes are: this
481
+ # project builds with -Wall -Wextra and inherits -Werror from React Native's
482
+ # own targets, and iostextinput/conversions.h has unused parameters. Plain -I
483
+ # would make every file that includes it fail to compile.
484
+ target_include_directories(rn_textinput SYSTEM PUBLIC
485
+ ${RN_TEXTINPUT_DIR}
486
+ ${RN_TEXTINPUT_DIR}/platform/ios
487
+ ${REACT_COMMON_DIR})
488
+ target_link_libraries(rn_textinput
489
+ glog folly_runtime jsi react_debug
490
+ react_renderer_attributedstring react_renderer_componentregistry
491
+ react_renderer_core react_renderer_graphics react_renderer_imagemanager
492
+ react_renderer_mounting react_renderer_textlayoutmanager
493
+ react_renderer_uimanager react_utils rrc_image rrc_text rrc_view yoga)
494
+ target_compile_options(rn_textinput PRIVATE ${BASALT_NO_UNKNOWN_PRAGMAS_FLAG} ${RN_EXTRA_FLAGS})
495
+ target_sources(rn_core INTERFACE $<TARGET_OBJECTS:rn_textinput>)
496
+ target_link_libraries(rn_core INTERFACE rn_textinput)
497
+
498
+ # ---------------------------------------------------------------------------
499
+ # Text measurement: drop React Native's stub so ours is the only definition.
500
+ #
501
+ # react/renderer/textlayoutmanager globs platform/cxx/*.cpp, which is a
502
+ # TextLayoutManager that ignores every attribute and hands back
503
+ # layoutConstraints.minimumSize. src/PangoTextLayoutManager.cpp defines the same
504
+ # symbols against Pango, so the stub has to leave the build or the two collide.
505
+ #
506
+ # The header is untouched and shared: only the implementation differs, which is
507
+ # what the platform/ split in React Native's tree is for.
508
+ # ---------------------------------------------------------------------------
509
+ get_target_property(_tlm_sources react_renderer_textlayoutmanager SOURCES)
510
+ list(REMOVE_ITEM _tlm_sources
511
+ ${REACT_COMMON_DIR}/react/renderer/textlayoutmanager/platform/cxx/react/renderer/textlayoutmanager/TextLayoutManager.cpp)
512
+ set_target_properties(react_renderer_textlayoutmanager PROPERTIES SOURCES "${_tlm_sources}")
513
+
514
+ # ReactCommon declares jsi::dynamicFromValue (used by RawProps) but no
515
+ # CMakeLists anywhere in the tree compiles JSIDynamic.cpp. Hosts are expected
516
+ # to build it themselves.
517
+ add_library(rn_jsidynamic OBJECT ${REACT_COMMON_DIR}/jsi/jsi/JSIDynamic.cpp)
518
+ target_include_directories(rn_jsidynamic PUBLIC ${REACT_COMMON_DIR} ${REACT_COMMON_DIR}/jsi ${FOLLY_DIR})
519
+ target_link_libraries(rn_jsidynamic folly_runtime glog)
520
+ target_sources(rn_core INTERFACE $<TARGET_OBJECTS:rn_jsidynamic>)
521
+
522
+ # Same situation one directory over: ReactCxxPlatform ships a working
523
+ # boost::beast websocket client under react/http/platform/cxx, but the
524
+ # CMakeLists for react/http globs only its own directory, so nothing compiles
525
+ # it. It defines getWebSocketClientFactory(), the seam every host has to fill,
526
+ # and the packager connection is what needs it.
527
+ # It only exists from 0.83 or so. React Native 0.81 ships the IWebSocketClient
528
+ # interface with no implementation behind it, so a host on that version has no
529
+ # websocket client and therefore no packager connection: no Fast Refresh, and no
530
+ # websockets for the app either. Not a gap this build can paper over, so it is
531
+ # reported and the target skipped.
532
+ set(RN_WEBSOCKET_SRC ${REACT_CXX_PLATFORM_DIR}/react/http/platform/cxx/WebSocketClient.cpp)
533
+ if(EXISTS ${RN_WEBSOCKET_SRC})
534
+ add_library(rn_websocket OBJECT ${RN_WEBSOCKET_SRC})
535
+ target_include_directories(rn_websocket PUBLIC
536
+ ${REACT_CXX_PLATFORM_DIR} ${REACT_COMMON_DIR} ${FOLLY_DIR})
537
+ target_link_libraries(rn_websocket folly_runtime glog boost fmt double-conversion)
538
+ target_compile_options(rn_websocket PRIVATE ${BASALT_NO_UNKNOWN_PRAGMAS_FLAG})
539
+ target_sources(rn_core INTERFACE $<TARGET_OBJECTS:rn_websocket>)
540
+ else()
541
+ message(STATUS "React Native ${RN_VERSION} bundles no websocket client; "
542
+ "the packager connection and Fast Refresh will not work")
543
+ endif()
544
+ target_link_libraries(rn_core INTERFACE yogacore folly_runtime glog boost fmt
545
+ double-conversion fast_float)
546
+
547
+ # std::atomic<std::optional<double>> in ReactNativeFeatureFlagsAccessor is
548
+ # 16 bytes wide; on x86-64 those operations are out-of-line calls in libatomic.
549
+ # Fantom's tester CMakeLists carries the same `if(UNIX AND NOT APPLE)` branch.
550
+ if(UNIX AND NOT APPLE)
551
+ target_link_libraries(rn_core INTERFACE atomic)
552
+ endif()
553
+
554
+ # --- The Windows flags, applied to everything React Native added -------------
555
+ #
556
+ # `-Wno-unknown-argument` and `-Wno-everything` have to land *after* React
557
+ # Native's own `-Wall -Werror -fexceptions -frtti -std=c++20`, and a compiler
558
+ # command line is built in a fixed order: CMAKE_CXX_FLAGS, then the directory's
559
+ # options, then the target's, then those a linked target exports. Only the last
560
+ # two are after React Native's, and React Native applies its flags to every
561
+ # target it defines -- ReactCxxPlatform's as much as ReactCommon's.
562
+ #
563
+ # So this walks every target in the build graph rather than a list. A list was
564
+ # tried first and covered ReactCommon but not ReactCxxPlatform, which failed
565
+ # seventy-three translation units later on -Wlanguage-extension-token inside
566
+ # folly's F14Table.h -- the same -Weverything, arriving by a route the list did
567
+ # not know about. Walking is the version that does not need updating when
568
+ # upstream adds a directory.
569
+ # Counteracting the flags was tried before removing them, and cannot work.
570
+ # `-Wno-everything` does undo `-Wall`, but React Native also applies
571
+ # `-Wpedantic`, and applies it INTERFACE on callinvoker and react_cxxstableapi
572
+ # -- so it arrives from the link graph, after every PRIVATE option, and
573
+ # re-enables -Wlanguage-extension-token on top of whatever came before. There
574
+ # is no flag that reliably lands last. Removing is the only order-independent
575
+ # answer.
576
+ #
577
+ # Both property sets, because INTERFACE_COMPILE_OPTIONS is how the ones that
578
+ # arrive last get there in the first place.
579
+ if(WIN32)
580
+ set(RN_CLANG_ONLY_FLAGS -Wall -Werror -Wpedantic -fexceptions -frtti -std=c++20)
581
+
582
+ function(basalt_strip_clang_flags target property)
583
+ get_target_property(options ${target} ${property})
584
+ if(NOT options)
585
+ return()
586
+ endif()
587
+ list(REMOVE_ITEM options ${RN_CLANG_ONLY_FLAGS})
588
+ set_target_properties(${target} PROPERTIES ${property} "${options}")
589
+ endfunction()
590
+
591
+ function(basalt_apply_windows_flags directory)
592
+ get_property(targets DIRECTORY ${directory} PROPERTY BUILDSYSTEM_TARGETS)
593
+ foreach(target ${targets})
594
+ get_target_property(target_type ${target} TYPE)
595
+ if(target_type STREQUAL "UTILITY")
596
+ continue()
597
+ endif()
598
+ basalt_strip_clang_flags(${target} INTERFACE_COMPILE_OPTIONS)
599
+ # An INTERFACE library has no compilation of its own, so it has no
600
+ # COMPILE_OPTIONS to strip and nothing to add them to.
601
+ if(NOT target_type STREQUAL "INTERFACE_LIBRARY")
602
+ basalt_strip_clang_flags(${target} COMPILE_OPTIONS)
603
+ target_compile_options(${target} PRIVATE ${RN_WINDOWS_FLAGS})
604
+ endif()
605
+ endforeach()
606
+ get_property(children DIRECTORY ${directory} PROPERTY SUBDIRECTORIES)
607
+ foreach(child ${children})
608
+ basalt_apply_windows_flags(${child})
609
+ endforeach()
610
+ endfunction()
611
+ basalt_apply_windows_flags(${CMAKE_CURRENT_SOURCE_DIR})
612
+ endif()