Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/autolinking.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ module.exports = {
libraryName: null,
componentDescriptors: null,
androidMkPath: null,
cmakeListsPath: null,
},
},
},
Expand Down
7 changes: 7 additions & 0 deletions docs/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type AndroidDependencyParams = {
libraryName?: string | null;
componentDescriptors?: string[] | null;
androidMkPath?: string | null;
cmakeListsPath?: string | null;
};
```

Expand Down Expand Up @@ -140,3 +141,9 @@ An array of custom component descriptor strings. By default they're generated ba
> Note: Only applicable when new architecture is turned on.

A relative path to a custom _Android.mk_ file not registered by codegen. Relative to `sourceDir`.

#### platforms.android.cmakeListsPath

> Note: Only applicable when new architecture is turned on.

A relative path to a custom _CMakeLists.txt_ file not registered by codegen. Relative to `sourceDir`.
1 change: 1 addition & 0 deletions docs/platforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@ type AndroidDependencyConfig = {
libraryName?: string | null;
componentDescriptors?: string[] | null;
androidMkPath?: string | null;
cmakeListsPath?: string | null;
};
```
2 changes: 2 additions & 0 deletions packages/cli-config/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const dependencyConfig = t
libraryName: t.string().allow(null),
componentDescriptors: t.array().items(t.string()).allow(null),
androidMkPath: t.string().allow(null),
cmakeListsPath: t.string().allow(null),
})
.allow(null),
})
Expand Down Expand Up @@ -137,6 +138,7 @@ export const projectConfig = t
libraryName: t.string().allow(null),
componentDescriptors: t.array().items(t.string()).allow(null),
androidMkPath: t.string().allow(null),
cmakeListsPath: t.string().allow(null),
})
.allow(null),
}),
Expand Down
10 changes: 8 additions & 2 deletions packages/cli-platform-android/native_modules.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,13 @@ class ReactNativeModules {

if (packages.size() > 0) {
libraryIncludes = packages.collect {
if (it.libraryName != null && it.androidMkPath != null) {
// The CMakeLists.txt file is in the same folder as the Android.mk
if (it.libraryName != null && it.cmakeListsPath != null) {
// If user provided a custom cmakeListsPath, let's honor it.
String nativeFolderPath = it.cmakeListsPath.replace("CMakeLists.txt", "")
"add_subdirectory($nativeFolderPath ${it.libraryName}_autolinked_build)"
} else if (it.libraryName != null && it.androidMkPath != null) {
// Fallback to previous behavior: reusing androidMkPath.
// We assume CMakeLists.txt file is in the same folder as the Android.mk
String nativeFolderPath = it.androidMkPath.replace("Android.mk", "")
"add_subdirectory($nativeFolderPath ${it.libraryName}_autolinked_build)"
} else {
Expand Down Expand Up @@ -470,6 +475,7 @@ class ReactNativeModules {
reactNativeModuleConfig.put("libraryName", androidConfig["libraryName"])
reactNativeModuleConfig.put("componentDescriptors", androidConfig["componentDescriptors"])
reactNativeModuleConfig.put("androidMkPath", androidConfig["androidMkPath"])
reactNativeModuleConfig.put("cmakeListsPath", androidConfig["cmakeListsPath"])

if (androidConfig["buildTypes"] && !androidConfig["buildTypes"].isEmpty()) {
reactNativeModulesBuildVariants.put(nameCleansed, androidConfig["buildTypes"])
Expand Down
4 changes: 4 additions & 0 deletions packages/cli-platform-android/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export function dependencyConfig(
const androidMkPath = userConfig.androidMkPath
? path.join(sourceDir, userConfig.androidMkPath)
: path.join(sourceDir, 'build/generated/source/codegen/jni/Android.mk');
const cmakeListsPath = userConfig.cmakeListsPath
? path.join(sourceDir, userConfig.cmakeListsPath)
: path.join(sourceDir, 'build/generated/source/codegen/jni/CMakeLists.txt');

return {
sourceDir,
Expand All @@ -137,5 +140,6 @@ export function dependencyConfig(
libraryName,
componentDescriptors,
androidMkPath,
cmakeListsPath,
};
}
2 changes: 2 additions & 0 deletions packages/cli-types/src/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type AndroidDependencyConfig = {
libraryName?: string | null;
componentDescriptors?: string[] | null;
androidMkPath?: string | null;
cmakeListsPath?: string | null;
};

export type AndroidDependencyParams = {
Expand All @@ -35,4 +36,5 @@ export type AndroidDependencyParams = {
libraryName?: string | null;
componentDescriptors?: string[] | null;
androidMkPath?: string | null;
cmakeListsPath?: string | null;
};