Handle autolinking for pure C++ turbo modules without includesGeneratedCode#56938
Handle autolinking for pure C++ turbo modules without includesGeneratedCode#56938satya164 wants to merge 4 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
|
|
||
| @get:OutputDirectory abstract val generatedOutputDirectory: DirectoryProperty | ||
|
|
||
| @get:Input abstract val generatedPureCxxCmakeListsPaths: MapProperty<String, String> |
There was a problem hiding this comment.
Why do we need a MapProperty<String, String> here?
Can we replace it with a single optional DirectoryProperty pointing to the codegen output (i.e. build/generated/source/codegen/pureCxx)?
The autolinking task can derive each dep's CMake path itself: when cmakeListsPath is null and isPureCxxDependency is true, just look at {pureCxxDir}/{libraryName}/jni/CMakeLists.txt.
There was a problem hiding this comment.
@cortinico updated to a DirectoryProperty
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: