Platform libs: Use FQ-names for platform libraries
This patch changes the platform libraries naming scheme. Earlier the platform libraries used to have simple names, like posix or Foundation. But these names are not unique enough. This causes issues with library resolution and cache building if a user library has the same simple name. With this patch all platform libraries have FQ names like org.jetbrains.konan.platform.posix. Corresponding change for user libraries will be added separately at the Gradle plugin side. Fix for #KT-36720.
This commit is contained in:
committed by
Ilya Matveev
parent
c7cd560228
commit
2562522392
@@ -73,15 +73,18 @@ project.rootProject.ext.platformManager.enabled.each { target ->
|
||||
|
||||
targetDefFiles(target).each { df ->
|
||||
def libName = defFileToLibName(targetName, df.name)
|
||||
def fileNamePrefix = PlatformLibsInfo.namePrefix
|
||||
|
||||
konanArtifacts {
|
||||
interop (libName, targets: [targetName]) {
|
||||
defFile df.file
|
||||
artifactName df.name
|
||||
artifactName "${fileNamePrefix}${df.name}"
|
||||
noDefaultLibs true
|
||||
noEndorsedLibs true
|
||||
libraries {
|
||||
klibs df.config.depends
|
||||
klibs df.config.depends.collect {
|
||||
"${fileNamePrefix}${it}".toString()
|
||||
}
|
||||
}
|
||||
extraOpts '-Xpurge-user-libs'
|
||||
compilerOpts "-fmodules-cache-path=${project.buildDir}/clangModulesCache"
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.jetbrains.kotlin.konan.util
|
||||
|
||||
object PlatformLibsInfo {
|
||||
const val namePrefix = "org.jetbrains.kotlin.native.platform."
|
||||
}
|
||||
+8
-4
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.target.customerDistribution
|
||||
import org.jetbrains.kotlin.konan.util.PlatformLibsInfo
|
||||
import org.jetbrains.kotlin.konan.util.visibleName
|
||||
import org.jetbrains.kotlin.native.interop.tool.CommonInteropArguments.Companion.DEFAULT_MODE
|
||||
import org.jetbrains.kotlin.native.interop.tool.CommonInteropArguments.Companion.MODE_METADATA
|
||||
@@ -163,6 +164,9 @@ private data class CacheInfo(val cacheDirectory: File, val cacheKind: String,
|
||||
|
||||
private class DefFile(val name: String, val depends: MutableList<DefFile>) {
|
||||
override fun toString(): String = "$name: [${depends.joinToString(separator = ", ") { it.name }}]"
|
||||
|
||||
val libraryName: String
|
||||
get() = "${PlatformLibsInfo.namePrefix}$name"
|
||||
}
|
||||
|
||||
private fun createTempDir(prefix: String, parent: File): File =
|
||||
@@ -214,14 +218,14 @@ private fun generateLibrary(
|
||||
logger: Logger
|
||||
) = with(directories) {
|
||||
val defFile = inputDirectory.child("${def.name}.def")
|
||||
val outKlib = outputDirectory.child(def.name)
|
||||
val outKlib = outputDirectory.child(def.libraryName)
|
||||
|
||||
if (outKlib.exists && !rebuild) {
|
||||
logger.verbose("Skip generating ${def.name} as it's already generated")
|
||||
return
|
||||
}
|
||||
|
||||
val tmpKlib = tmpDirectory.child(def.name)
|
||||
val tmpKlib = tmpDirectory.child(def.libraryName)
|
||||
|
||||
try {
|
||||
val cinteropArgs = arrayOf(
|
||||
@@ -232,7 +236,7 @@ private fun generateLibrary(
|
||||
"-repo", outputDirectory.absolutePath,
|
||||
"-no-default-libs", "-no-endorsed-libs", "-Xpurge-user-libs", "-nopack",
|
||||
"-mode", mode,
|
||||
*def.depends.flatMap { listOf("-l", "$outputDirectory/${it.name}") }.toTypedArray()
|
||||
*def.depends.flatMap { listOf("-l", "$outputDirectory/${it.libraryName}") }.toTypedArray()
|
||||
)
|
||||
logger.verbose("Run cinterop with args: ${cinteropArgs.joinToString(separator = " ")}")
|
||||
invokeInterop("native", cinteropArgs)?.let { K2Native.mainNoExit(it) }
|
||||
@@ -283,7 +287,7 @@ private fun buildCache(
|
||||
"-p", cacheKind,
|
||||
"-target", target.visibleName,
|
||||
"-repo", outputDirectory.absolutePath,
|
||||
"-Xadd-cache=${outputDirectory.absolutePath}/${def.name}",
|
||||
"-Xadd-cache=${outputDirectory.absolutePath}/${def.libraryName}",
|
||||
"-Xcache-directory=${cacheDirectory.absolutePath}",
|
||||
*cacheArgs.toTypedArray()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user