Skip to content

Commit ef06690

Browse files
committed
fix: add name cleasing to dependency names
1 parent 7e0a6f2 commit ef06690

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTask.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ abstract class GenerateAutolinkingNewArchitecturesFileTask : DefaultTask() {
6363
val cxxModuleCMakeListsPath = dep.cxxModuleCMakeListsPath
6464

6565
if (dep.hasCodegenPrefab) {
66-
addDirectoryString += "find_package($depName CONFIG REQUIRED)"
66+
addDirectoryString += "find_package(${cleanseDepName(depName)} CONFIG REQUIRED)"
6767
} else {
6868
if (libraryName != null && cmakeListsPath != null) {
6969
val nativeFolderPath = sanitizeCmakeListsPath(cmakeListsPath)
@@ -98,7 +98,7 @@ abstract class GenerateAutolinkingNewArchitecturesFileTask : DefaultTask() {
9898
dependenciesWithNames.joinToString("\n ") { (depName, dep) ->
9999
var prefabLibraries = ""
100100
if (dep.hasCodegenPrefab) {
101-
prefabLibraries += "$depName::$CODEGEN_LIB_PREFIX${dep.libraryName}"
101+
prefabLibraries += "${cleanseDepName(depName)}::$CODEGEN_LIB_PREFIX${dep.libraryName}"
102102
}
103103
prefabLibraries
104104
}
@@ -182,6 +182,9 @@ abstract class GenerateAutolinkingNewArchitecturesFileTask : DefaultTask() {
182182
internal fun sanitizeCmakeListsPath(cmakeListsPath: String): String =
183183
cmakeListsPath.replace("CMakeLists.txt", "").replace(" ", "\\ ")
184184

185+
internal fun cleanseDepName(depName: String): String =
186+
depName.replace(Regex("[~*!'()]+"), "_").replace(Regex("^@([\\w-.]+)/"), "$1_")
187+
185188
// language=cmake
186189
val CMAKE_TEMPLATE =
187190
"""

0 commit comments

Comments
 (0)