-
Notifications
You must be signed in to change notification settings - Fork 6
Add weak-node-api dynamic library
#37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for a dynamic weak-node-api library while refactoring several build scripts into TypeScript. Key changes include:
- Adding an option to skip auto-linking and weak-node-api linking.
- Introducing scripts to generate and build a stubbed weak-node-api C++ file based on the Node-API header AST.
- Updating the CMake CLI and associated modules to support both Android and Apple triplet builds.
Reviewed Changes
Copilot reviewed 9 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-node-api-modules/scripts/copy-node-api-headers.ts | Updated header path resolution using an import from node-api-headers and using __dirname for a consistent destination path. |
| packages/react-native-node-api-modules/scripts/build-weak-node-api.ts | New script generating the fake Node API source; uses clang AST dump and builds stub implementations with weak symbols. |
| packages/react-native-node-api-cmake/src/weak-node-api.ts | Retrieves the weak-node-api path based on the target triplet. |
| packages/react-native-node-api-cmake/src/triplets.ts | Updated the supported triplets, consolidating Android and Apple values. |
| packages/react-native-node-api-cmake/src/cli.ts | Refactored the CLI to include new options for Android/Apple builds and to pass along auto-linking and weak-node-api linkage options. |
| packages/react-native-node-api-cmake/src/apple.ts | Adjusted Apple configuration with updated naming for SDK and system names, and ensured autoLink behavior in XCFramework creation. |
| packages/react-native-node-api-cmake/src/android.ts | Added new Android build configurations and a routine to assemble the Android libs directory with weak-node-api integration. |
Files not reviewed (6)
- packages/react-native-node-api-modules/.gitignore: Language not supported
- packages/react-native-node-api-modules/package.json: Language not supported
- packages/react-native-node-api-modules/tsconfig.json: Language not supported
- packages/react-native-node-api-modules/tsconfig.node-scripts.json: Language not supported
- packages/react-native-node-api-modules/tsconfig.node.json: Language not supported
- packages/react-native-node-api-modules/weak-node-api/CMakeLists.txt: Language not supported
| ); | ||
| lines.push( | ||
| `__attribute__((weak)) ${returnType} ${node.name}(${argumentTypes}) {`, | ||
| returnType === "void" ? "" : " napi_status::napi_generic_failure;", |
Copilot
AI
May 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For functions with non-void return types, the generated stub code might be invalid because it lacks a 'return' keyword. Consider updating the line to include 'return' (e.g. 'return napi_status::napi_generic_failure;') to ensure proper stub implementation.
| returnType === "void" ? "" : " napi_status::napi_generic_failure;", | |
| returnType === "void" ? "" : " return napi_status::napi_generic_failure;", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line will go away in #39
025310b to
5ad833d
Compare
This PR is stacked on the branch of #33 and merging it will:
--skip-autolinkoption toreact-native-node-api-cmakeCLI #13 (I needed this to build theweak-node-apibinary).weak-node-apidynamic library (because - recursion 😬)weak-node-apiclangto dump and AST__attribute__((weak))annotations in case we'd actually want to link this in some day and allow for the real native code to override the implementations.