Skip to content
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

Breaking: Remove androidMkPath from react-native config #1843

Merged
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: 0 additions & 1 deletion docs/autolinking.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ module.exports = {
android: {
libraryName: null,
componentDescriptors: null,
androidMkPath: null,
cmakeListsPath: null,
},
},
Expand Down
7 changes: 0 additions & 7 deletions docs/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ type AndroidDependencyParams = {
buildTypes?: string[];
libraryName?: string | null;
componentDescriptors?: string[] | null;
androidMkPath?: string | null;
cmakeListsPath?: string | null;
};
```
Expand Down Expand Up @@ -136,12 +135,6 @@ A string indicating your custom library name. By default it's taken from the `li

An array of custom component descriptor strings. By default they're generated based on `codegenNativeComponent` calls.

#### platforms.android.androidMkPath

> 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.
Expand Down
1 change: 0 additions & 1 deletion docs/platforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ type AndroidDependencyConfig = {
buildTypes: string[];
libraryName?: string | null;
componentDescriptors?: string[] | null;
androidMkPath?: string | null;
cmakeListsPath?: string | null;
};
```
2 changes: 0 additions & 2 deletions packages/cli-config/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export const dependencyConfig = t
buildTypes: t.array().items(t.string()).default([]),
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,7 +136,6 @@ export const projectConfig = t
buildTypes: t.array().items(t.string()).default([]),
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
46 changes: 0 additions & 46 deletions packages/cli-platform-android/native_modules.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ public class PackageList {
}
"""

def androidMkTemplate = """# This code was generated by [React Native CLI](https://www.npmjs.com/package/@react-native-community/cli)

{{ libraryIncludes }}

import-codegen-modules := \\
{{ libraryModules }}
"""

def cmakeTemplate = """# This code was generated by [React Native CLI](https://www.npmjs.com/package/@react-native-community/cli)

cmake_minimum_required(VERSION 3.13)
Expand Down Expand Up @@ -260,37 +252,6 @@ class ReactNativeModules {
}
}

void generateAndroidMkFile(File outputDir, String generatedFileName, String generatedFileContentsTemplate) {
ArrayList<HashMap<String, String>> packages = this.reactNativeModules
String packageName = this.packageName
String codegenLibPrefix = "libreact_codegen_"
String libraryIncludes = ""
String libraryModules = ""

if (packages.size() > 0) {
libraryIncludes = packages.collect {
if (it.androidMkPath != null && it.libraryName != null) {
"include ${it.androidMkPath}"
} else {
null
}
}.minus(null).join('\n')
libraryModules = packages.collect {
it.libraryName ? "${codegenLibPrefix}${it.libraryName}" : null
}.minus(null).join(" \\\n ")
}

String generatedFileContents = generatedFileContentsTemplate
.replace("{{ libraryIncludes }}", libraryIncludes)
.replace("{{ libraryModules }}", libraryModules)

outputDir.mkdirs()
final FileTreeBuilder treeBuilder = new FileTreeBuilder(outputDir)
treeBuilder.file(generatedFileName).newWriter().withWriter { w ->
w << generatedFileContents
}
}

void generateCmakeFile(File outputDir, String generatedFileName, String generatedFileContentsTemplate) {
ArrayList<HashMap<String, String>> packages = this.reactNativeModules
String packageName = this.packageName
Expand All @@ -304,11 +265,6 @@ class ReactNativeModules {
// 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 {
null
}
Expand Down Expand Up @@ -474,7 +430,6 @@ class ReactNativeModules {
reactNativeModuleConfig.put("packageImportPath", androidConfig["packageImportPath"])
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()) {
Expand Down Expand Up @@ -541,7 +496,6 @@ ext.applyNativeModulesAppBuildGradle = { Project project, String root = null ->

task generateNewArchitectureFiles {
doLast {
autoModules.generateAndroidMkFile(generatedJniDir, "Android-rncli.mk", androidMkTemplate)
autoModules.generateCmakeFile(generatedJniDir, "Android-rncli.cmake", cmakeTemplate)
autoModules.generateRncliCpp(generatedJniDir, "rncli.cpp", rncliCppTemplate)
autoModules.generateRncliH(generatedJniDir, "rncli.h", rncliHTemplate)
Expand Down
4 changes: 0 additions & 4 deletions packages/cli-platform-android/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ export function dependencyConfig(
userConfig.libraryName || findLibraryName(root, sourceDir);
const componentDescriptors =
userConfig.componentDescriptors || findComponentDescriptors(root);
const androidMkPath = userConfig.androidMkPath
? path.join(sourceDir, userConfig.androidMkPath)
: path.join(sourceDir, 'build/generated/source/codegen/jni/Android.mk');
let cmakeListsPath = userConfig.cmakeListsPath
? path.join(sourceDir, userConfig.cmakeListsPath)
: path.join(sourceDir, 'build/generated/source/codegen/jni/CMakeLists.txt');
Expand All @@ -146,7 +143,6 @@ export function dependencyConfig(
dependencyConfiguration,
libraryName,
componentDescriptors,
androidMkPath,
cmakeListsPath,
};
}
2 changes: 0 additions & 2 deletions packages/cli-types/src/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export type AndroidDependencyConfig = {
buildTypes: string[];
libraryName?: string | null;
componentDescriptors?: string[] | null;
androidMkPath?: string | null;
cmakeListsPath?: string | null;
};

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