mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Upstream CLI autolinking changes to RNGP (#45314)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45314 Fixes https://github.com/facebook/react-native/issues/45302 I'm ustreaming two changes that happened inside the CLI/Autolinking logic that are missing inside core autolinking. Changelog: [Internal] [Changed] - Upstream CLI autolinking changes to RNGP Reviewed By: blakef Differential Revision: D59460504 fbshipit-source-id: a6e7ab6a46fec26620dc965e77b13fdeba84fae3
This commit is contained in:
committed by
Blake Friedman
parent
e1d97f4621
commit
c45d450502
+2
@@ -85,6 +85,8 @@ abstract class GeneratePackageListTask : DefaultTask() {
|
||||
val packages = model?.dependencies?.values ?: emptyList()
|
||||
return packages
|
||||
.filter { it.platforms?.android != null }
|
||||
// The pure C++ dependencies won't have a .java/.kt file to import
|
||||
.filterNot { it.platforms?.android?.isPureCxxDependency == true }
|
||||
.associate { it.name to checkNotNull(it.platforms?.android) }
|
||||
}
|
||||
|
||||
|
||||
+27
@@ -177,6 +177,33 @@ class GeneratePackageListTaskTest {
|
||||
assertEquals(android, result["a-dependency"])
|
||||
}
|
||||
|
||||
@Test
|
||||
fun filterAndroidPackages_withIsPureCxxDependencyObject_returnsIt() {
|
||||
val task = createTestTask<GeneratePackageListTask>()
|
||||
val android =
|
||||
ModelAutolinkingDependenciesPlatformAndroidJson(
|
||||
sourceDir = "./a/directory/android",
|
||||
packageImportPath = "import com.facebook.react.aPackage;",
|
||||
packageInstance = "new APackage()",
|
||||
buildTypes = emptyList(),
|
||||
isPureCxxDependency = true)
|
||||
|
||||
val result =
|
||||
task.filterAndroidPackages(
|
||||
ModelAutolinkingConfigJson(
|
||||
reactNativeVersion = "1000.0.0",
|
||||
dependencies =
|
||||
mapOf(
|
||||
"a-pure-cxx-dependency" to
|
||||
ModelAutolinkingDependenciesJson(
|
||||
root = "./a/directory",
|
||||
name = "a-pure-cxx-dependency",
|
||||
platforms =
|
||||
ModelAutolinkingDependenciesPlatformJson(android = android))),
|
||||
project = null))
|
||||
assertEquals(emptyMap<String, ModelAutolinkingDependenciesPlatformAndroidJson>(), result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun composeFileContent_withNoPackages_returnsValidFile() {
|
||||
val task = createTestTask<GeneratePackageListTask>()
|
||||
|
||||
+2
@@ -135,6 +135,8 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings
|
||||
// We handle scenarios where there are deps that are
|
||||
// iOS-only or missing the Android configs.
|
||||
?.filter { it.platforms?.android?.sourceDir != null }
|
||||
// We want to skip dependencies that are pure C++ as they won't contain a .gradle file.
|
||||
?.filterNot { it.platforms?.android?.isPureCxxDependency == true }
|
||||
?.associate { deps ->
|
||||
":${deps.nameCleansed}" to File(deps.platforms?.android?.sourceDir)
|
||||
} ?: emptyMap()
|
||||
|
||||
+2
-1
@@ -86,7 +86,8 @@ class ReactSettingsExtensionTest {
|
||||
"cxxModuleCMakeListsModuleName": null,
|
||||
"cxxModuleCMakeListsPath": null,
|
||||
"cxxModuleHeaderName": null,
|
||||
"dependencyConfiguration": "implementation"
|
||||
"dependencyConfiguration": "implementation",
|
||||
"isPureCxxDependency": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -18,5 +18,6 @@ data class ModelAutolinkingDependenciesPlatformAndroidJson(
|
||||
val cxxModuleCMakeListsModuleName: String? = null,
|
||||
val cxxModuleCMakeListsPath: String? = null,
|
||||
val cxxModuleHeaderName: String? = null,
|
||||
val dependencyConfiguration: String? = null
|
||||
val dependencyConfiguration: String? = null,
|
||||
val isPureCxxDependency: Boolean? = null
|
||||
)
|
||||
|
||||
+7
-1
@@ -216,7 +216,8 @@ class JsonUtilsTest {
|
||||
"cxxModuleCMakeListsModuleName": null,
|
||||
"cxxModuleCMakeListsPath": null,
|
||||
"cxxModuleHeaderName": null,
|
||||
"dependencyConfiguration": "implementation"
|
||||
"dependencyConfiguration": "implementation",
|
||||
"isPureCxxDependency": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -298,6 +299,11 @@ class JsonUtilsTest {
|
||||
.platforms!!
|
||||
.android!!
|
||||
.dependencyConfiguration)
|
||||
assertFalse(
|
||||
parsed.dependencies!!["@react-native/oss-library-example"]!!
|
||||
.platforms!!
|
||||
.android!!
|
||||
.isPureCxxDependency!!)
|
||||
}
|
||||
|
||||
private fun createJsonFile(@Language("JSON") input: String) =
|
||||
|
||||
Reference in New Issue
Block a user