Uh oh!
There was an error while loading. Please reload this page.
Handle autolinking for pure C++ turbo modules without includesGeneratedCode - #56938
Handle autolinking for pure C++ turbo modules without includesGeneratedCode#56938satya164 wants to merge 5 commits into
includesGeneratedCode#56938Conversation
…tedCode` Currently, pure C++ modules require `includesGeneratedCode: true`, and the library to be shipping codegen files to work. This is inconsistent with regular turbo modules that work with both setups. The issue is in 2 places: 1. CLI returns hardcoded default for C++ modules 2. Autolinking logic doesn't run codegen for C++ modules PR removing hardcoded default from CLI: react-native-community/cli#2799 This change updates the autolinking logic to detect pure C++ libraries without `includesGeneratedCode: true`, run codegen for them and use correct path for CMakeLists based on the codegen output.
@fabriziocucci has imported this pull request. If you are a Meta employee, you can view this in D106094034. |
| private fun configurePureCxxDependenciesCodegen( | ||
| project: Project, | ||
| extension: ReactExtension, | ||
| rootExtension: PrivateReactExtension, | ||
| generatedPureCxxSourceDir: Provider<Directory>, | ||
| dependencies: List<ModelAutolinkingDependenciesJson>, | ||
| ): List<TaskProvider<GenerateCodegenArtifactsTask>> { |
There was a problem hiding this comment.
Here there is a bunch of duplicated code.
Can you extract the common logic from configureCodegen into a reusable helper, then call it here for pure C++ deps instead?
There was a problem hiding this comment.
@cortinico extracted duplicated task registration code to registerCodegenTasks
Uh oh!
There was an error while loading. Please reload this page.
cortinico
left a comment
There was a problem hiding this comment.
Code looks good but let's add a couple of tests for the 2 functions I suggested
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
react-native-bot
commented
Jun 1, 2026
This pull request was successfully merged by @satya164 in c789880 When will my fix make it into a release? | How to file a pick request? |
…re c++ modules This removes the incorrect default `cmakeListsPath` from android autolinking for pure C++ modules. Currently, the path is always defaulted to a generated file path in the library. This breaks autolinking when a C++ library doesn't ship with prebuilt codegen files (with `includesGeneratedCode: false`). Mirrors the same change in Community CLI: react-native-community/cli#2799 Related fix in react-native: react/react-native#56938
…re C++ modules This removes the incorrect default `cmakeListsPath` from android autolinking for pure C++ modules. Currently, the path is always defaulted to a generated file path in the library. This breaks autolinking when a C++ library doesn't ship with prebuilt codegen files (with `includesGeneratedCode: false`). Mirrors the same change in Community CLI: react-native-community/cli#2799 Related fix in react-native: react/react-native#56938
…re C++ modules This removes the incorrect default `cmakeListsPath` from android autolinking for pure C++ modules. Currently, the path is always defaulted to a generated file path in the library. This breaks autolinking when a C++ library doesn't ship with prebuilt codegen files (with `includesGeneratedCode: false`). Mirrors the same change in Community CLI: react-native-community/cli#2799 Related fix in react-native: react/react-native#56938
Summary:
Currently, pure C++ modules require
includesGeneratedCode: true, and the library to be shipping codegen files to work. This is inconsistent with regular turbo modules that work with both setups.The issue is in 2 places:
PR removing hardcoded default from CLI: react-native-community/cli#2799
This change updates the autolinking logic to detect pure C++ libraries without
includesGeneratedCode: true, run codegen for them and use correct path for CMakeLists based on the codegen output.Changelog:
[ANDROID] [FIXED] - Fix pure C++ turbo modules not working without
includesGeneratedCode: trueTest Plan:
npx create-react-native-library@latest awesome-library --yes --description "my library" --type turbo-module --languages cppyarn example androidand notice that the build worksincludesGeneratedCode: true:yarn example androidand notice that the build failscmakeListsPathfor pure c++ modules react-native-community/cli#2799 and notice that the module works correctlyscreenshot from the test library: