-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
fix: Prioritise local cpp (use default as fallback) #48340
base: main
Are you sure you want to change the base?
Conversation
Hi @timbocole! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
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.
Thanks for taking a stab at this.
However, I'm not sure that this is the right solution.
I'll try to explain:
- We have one case where we want to load the OnLoad.cpp provided by the app, for example when we have local Cxx modules, as described by the issue #48298
- We also have one case where we always want to load the OnLoad.cpp file provided by React Native, for example for issue #47352 that was fixed by @cortinico's commit 3956955
The proposed solution will fix the first case, but it will break the second again.
I think that the right solution should be to enhance the autolinking codegen not only to consider the dependencies in the node_modules but also to consider the modules provided by the app in the codegenConfig
property of the package.json
.
In that way, the default OnLoad.cpp will load autolinking that, at this point, will also have the information of the local modules provided by the app.
However, this is an architectural and delicate change that should be evaluated also by @cortinico once he is back from PTO.
Actually this solution does consider issue #47352 (thanks to the Having said that, I agree that the cleaner longterm approach would be to make the autolinking codegen more intelligent. |
Thanks for checking the other issue as well. The code is good to me, and I agree that the current situation is bad. Meanwhile, I can add a warning on the website for people that are trying to create a pure C++ TurboModule in their app. Website PR: facebook/react-native-website#4402 |
Summary:
#47379 removed local cpp sources from the sources being built with the app. This resulted in a local
android/app/src/main/jni/OnLoad.cpp
file being ignored at build time. I have therefore added logic to the cmake file to prioritise localcpp
files and fallback to${REACT_ANDROID_DIR}/cmake-utils/default-app-setup/*.cpp
if none exist.This resolves #48298
Changelog:
[ANDROID] [FIXED] - Prioritise local OnLoad.cpp, falling back to default-app-setup
Test Plan:
EarlyJsError: TurboModuleRegistry.getEnforcing(...): 'PlatformConstants' could not be found. Verify that a module by this name is registered in the native binary
#47352 to ensure no regression