You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Expose includable WEAK_NODE_API_CONFIG to CMake projects
* Use the `include(${WEAK_NODE_API_CONFIG})` syntax in our own tests
* Turn define arguments into arrays of objects with key-value-pair
* Add general documentation on weak-node-api
* Make injection of CMAKE_JS_* variables opt-in and provide our own explicit way of linking with Node-API
* Add --weak-node-api option to gyp-to-cmake
* Use weak-node-api linkage in node-addon-examples
* Opt into cmake-js compatibility in node-tests
* Fixed bug passing type through defines
* Fixed bug when calling cmake-rn in node-tests
* Fix missing set_target_properties of .node suffix
* Apply suggestion from @Copilot to documentation
* Use [] instead of Array
* Push into an array instead of creating a new on every --define
* Update packages/gyp-to-cmake/src/transformer.ts
Co-authored-by: Copilot <[email protected]>
---------
Co-authored-by: Copilot <[email protected]>
Android's dynamic linker imposes restrictions on the access to global symbols (such as the Node-API free functions): A dynamic library must explicitly declare any dependency bringing symbols it needs as `DT_NEEDED`.
4
+
5
+
The implementation of Node-API is split between Hermes and our host package and to avoid addons having to explicitly link against either, we've introduced a `weak-node-api` library (published in `react-native-node-api` package). This library exposes only Node-API and will have its implementation injected by the host.
6
+
7
+
While technically not a requirement on non-Android platforms, we choose to make this the general approach across React Native platforms. This keeps things aligned across platforms, while exposing just the Node-API without forcing libraries to build with suppression of errors for undefined symbols.
Copy file name to clipboardExpand all lines: packages/cmake-rn/README.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,3 +3,24 @@
3
3
A wrapper around Cmake making it easier to produce prebuilt binaries targeting iOS and Android matching [the prebuilt binary specification](https://github.com/callstackincubator/react-native-node-api/blob/main/docs/PREBUILDS.md).
4
4
5
5
Serves the same purpose as `cmake-js` does for the Node.js community and could potentially be upstreamed into `cmake-js` eventually.
6
+
7
+
## Linking against Node-API
8
+
9
+
Android's dynamic linker imposes restrictions on the access to global symbols (such as the Node-API free functions): A dynamic library must explicitly declare any dependency bringing symbols it needs as `DT_NEEDED`.
10
+
11
+
The implementation of Node-API is split between Hermes and our host package and to avoid addons having to explicitly link against either, we've introduced a `weak-node-api` library (published in `react-native-node-api` package). This library exposes only Node-API and will have its implementation injected by the host.
12
+
13
+
To link against `weak-node-api` just include the CMake config exposed through `WEAK_NODE_API_CONFIG` and add `weak-node-api` to the `target_link_libraries` of the addon's library target.
This is different from how `cmake-js` "injects" the Node-API for linking (via `${CMAKE_JS_INC}`, `${CMAKE_JS_SRC}` and `${CMAKE_JS_LIB}`). To allow for interoperability between these tools, we inject these when you pass `--cmake-js` to `cmake-rn`.
0 commit comments