[Native] Use library paths instead of library names in K/N build infra
Use library paths instead of library names in K/N build infra when passing a library through `-library` compiler argument. ^KT-61098
This commit is contained in:
committed by
Space Team
parent
e7b8f3ecde
commit
c3da16a1d8
@@ -225,7 +225,7 @@ Task linkTest(String name, Closure<KonanLinkTest> configureClosure) {
|
|||||||
// Build an executable with library
|
// Build an executable with library
|
||||||
program(name, targets: [targetName]) {
|
program(name, targets: [targetName]) {
|
||||||
libraries {
|
libraries {
|
||||||
klib lib
|
klibFile file("$testOutputLocal/$name/$targetName/${lib}.klib")
|
||||||
}
|
}
|
||||||
baseDir "$testOutputLocal/$name"
|
baseDir "$testOutputLocal/$name"
|
||||||
srcFiles task.getSources()
|
srcFiles task.getSources()
|
||||||
@@ -3949,7 +3949,7 @@ Task interopTestBase(String name, boolean multiFile, boolean interop2ForMainOnly
|
|||||||
artifact interopLib
|
artifact interopLib
|
||||||
if (interopLib2 != null) artifact interopLib2
|
if (interopLib2 != null) artifact interopLib2
|
||||||
if (hasIntermediateLib)
|
if (hasIntermediateLib)
|
||||||
klib lib
|
klibFile file("$testOutputLocal/$name/$targetName/${lib}.klib")
|
||||||
}
|
}
|
||||||
srcFiles multiFile ? fileTree(task.source) { include '**/*.kt' } : task.getSources()
|
srcFiles multiFile ? fileTree(task.source) { include '**/*.kt' } : task.getSources()
|
||||||
baseDir "$testOutputLocal/$name"
|
baseDir "$testOutputLocal/$name"
|
||||||
@@ -5025,7 +5025,7 @@ Task frameworkTest(String name, Closure<FrameworkTest> configurator) {
|
|||||||
fr.libraries.forEach { library ->
|
fr.libraries.forEach { library ->
|
||||||
dependsOn konanArtifacts[library].getByTarget(target.name)
|
dependsOn konanArtifacts[library].getByTarget(target.name)
|
||||||
libraries {
|
libraries {
|
||||||
file konanArtifacts[library].getArtifactByTarget(target.name)
|
klibFile konanArtifacts[library].getArtifactByTarget(target.name)
|
||||||
}
|
}
|
||||||
linkerOpts "-L$buildDir"
|
linkerOpts "-L$buildDir"
|
||||||
UtilsKt.dependsOnKonanBuildingTask(task, library, target)
|
UtilsKt.dependsOnKonanBuildingTask(task, library, target)
|
||||||
|
|||||||
+4
-26
@@ -23,9 +23,7 @@ open class KonanLibrariesSpec(
|
|||||||
@Internal val project: Project
|
@Internal val project: Project
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@InputFiles @PathSensitive(PathSensitivity.RELATIVE) val files = mutableSetOf<FileCollection>()
|
@InputFiles @PathSensitive(PathSensitivity.RELATIVE) val klibFiles = mutableSetOf<FileCollection>()
|
||||||
|
|
||||||
@Input val namedKlibs = mutableSetOf<String>()
|
|
||||||
|
|
||||||
@Internal val artifacts = mutableListOf<KonanBuildingTask>()
|
@Internal val artifacts = mutableListOf<KonanBuildingTask>()
|
||||||
|
|
||||||
@@ -57,14 +55,9 @@ open class KonanLibrariesSpec(
|
|||||||
// DSL Methods
|
// DSL Methods
|
||||||
|
|
||||||
/** Absolute path */
|
/** Absolute path */
|
||||||
fun file(file: Any) = files.add(project.files(file))
|
fun klibFile(file: Any) { klibFiles.add(project.files(file)) }
|
||||||
fun files(vararg files: Any) = this.files.addAll(files.map { project.files(it) })
|
fun klibFiles(vararg files: Any) { klibFiles.addAll(files.map { project.files(it) }) }
|
||||||
fun files(collection: FileCollection) = this.files.add(collection)
|
fun klibFiles(collection: FileCollection) { klibFiles.add(collection) }
|
||||||
|
|
||||||
/** The compiler with search the library in repos */
|
|
||||||
fun klib(lib: String) = namedKlibs.add(lib)
|
|
||||||
fun klibs(vararg libs: String) = namedKlibs.addAll(libs)
|
|
||||||
fun klibs(libs: Iterable<String>) = namedKlibs.addAll(libs)
|
|
||||||
|
|
||||||
private fun klibInternal(lib: KonanBuildingConfig<*>, friend: Boolean) {
|
private fun klibInternal(lib: KonanBuildingConfig<*>, friend: Boolean) {
|
||||||
if (!(lib is KonanLibrary || lib is KonanInteropLibrary)) {
|
if (!(lib is KonanLibrary || lib is KonanInteropLibrary)) {
|
||||||
@@ -135,19 +128,4 @@ open class KonanLibrariesSpec(
|
|||||||
private fun Project.evaluationDependsOn(another: Project) {
|
private fun Project.evaluationDependsOn(another: Project) {
|
||||||
if (this != another) { evaluationDependsOn(another.path) }
|
if (this != another) { evaluationDependsOn(another.path) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun asFiles(): List<File> = asFiles(
|
|
||||||
defaultResolver(
|
|
||||||
repos.map { it.absolutePath },
|
|
||||||
task.konanTarget,
|
|
||||||
Distribution(project.konanHome)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
fun asFiles(resolver: SearchPathResolver<*>): List<File> = mutableListOf<File>().apply {
|
|
||||||
files.flatMapTo(this) { it.files }
|
|
||||||
addAll(artifactFiles)
|
|
||||||
addAll(task.platformConfiguration.files)
|
|
||||||
namedKlibs.mapTo(this) { project.file(resolver.resolve(it).libraryFile.absolutePath) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -207,11 +207,10 @@ internal fun dumpProperties(task: Task) {
|
|||||||
println("artifact : ${artifact.canonicalPath}")
|
println("artifact : ${artifact.canonicalPath}")
|
||||||
println("srcFiles : ${srcFiles.dump()}")
|
println("srcFiles : ${srcFiles.dump()}")
|
||||||
println("produce : $produce")
|
println("produce : $produce")
|
||||||
println("libraries : ${libraries.files.dump()}")
|
println("klibFiles : ${libraries.klibFiles.dump()}")
|
||||||
println(" : ${libraries.artifacts.map {
|
println(" : ${libraries.artifacts.map {
|
||||||
it.artifact.canonicalPath
|
it.artifact.canonicalPath
|
||||||
}.dump()}")
|
}.dump()}")
|
||||||
println(" : ${libraries.namedKlibs.dump()}")
|
|
||||||
println("nativeLibraries : ${nativeLibraries.dump()}")
|
println("nativeLibraries : ${nativeLibraries.dump()}")
|
||||||
println("linkerOpts : $linkerOpts")
|
println("linkerOpts : $linkerOpts")
|
||||||
println("enableDebug : $enableDebug")
|
println("enableDebug : $enableDebug")
|
||||||
@@ -233,11 +232,10 @@ internal fun dumpProperties(task: Task) {
|
|||||||
println("Stub generation task: $name")
|
println("Stub generation task: $name")
|
||||||
println("destinationDir : $destinationDir")
|
println("destinationDir : $destinationDir")
|
||||||
println("artifact : $artifact")
|
println("artifact : $artifact")
|
||||||
println("libraries : ${libraries.files.dump()}")
|
println("klibFiles : ${libraries.klibFiles.dump()}")
|
||||||
println(" : ${libraries.artifacts.map {
|
println(" : ${libraries.artifacts.map {
|
||||||
it.artifact.canonicalPath
|
it.artifact.canonicalPath
|
||||||
}.dump()}")
|
}.dump()}")
|
||||||
println(" : ${libraries.namedKlibs.dump()}")
|
|
||||||
println("defFile : $defFile")
|
println("defFile : $defFile")
|
||||||
println("target : $target")
|
println("target : $target")
|
||||||
println("packageName : $packageName")
|
println("packageName : $packageName")
|
||||||
|
|||||||
+3
-5
@@ -180,13 +180,11 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
|||||||
if (platformConfiguration.files.isNotEmpty()) {
|
if (platformConfiguration.files.isNotEmpty()) {
|
||||||
platformConfiguration.files.filter { it.name.endsWith(".klib") }.forEach {
|
platformConfiguration.files.filter { it.name.endsWith(".klib") }.forEach {
|
||||||
// The library's directory is added in libraries.repos.
|
// The library's directory is added in libraries.repos.
|
||||||
addArg("-library", it.nameWithoutExtension)
|
addArg("-library", it.absolutePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addFileArgs("-library", libraries.files)
|
addFileArgs("-library", libraries.klibFiles)
|
||||||
addArgs("-library", libraries.namedKlibs)
|
addArgs("-library", libraries.artifacts.map { it.artifact.canonicalPath })
|
||||||
// The library's directory is added in libraries.repos.
|
|
||||||
addArgs("-library", libraries.artifacts.map { it.artifact.nameWithoutExtension })
|
|
||||||
|
|
||||||
addArgIfNotNull("-target", konanTarget.visibleName)
|
addArgIfNotNull("-target", konanTarget.visibleName)
|
||||||
addArgIfNotNull("-language-version", languageVersion)
|
addArgIfNotNull("-language-version", languageVersion)
|
||||||
|
|||||||
+1
-2
@@ -100,8 +100,7 @@ open class KonanInteropTask @Inject constructor(@Internal val workerExecutor: Wo
|
|||||||
|
|
||||||
addArgs("-repo", libraries.repos.map { it.canonicalPath })
|
addArgs("-repo", libraries.repos.map { it.canonicalPath })
|
||||||
|
|
||||||
addFileArgs("-library", libraries.files)
|
addFileArgs("-library", libraries.klibFiles)
|
||||||
addArgs("-library", libraries.namedKlibs)
|
|
||||||
addArgs("-library", libraries.artifacts.map { it.artifact.canonicalPath })
|
addArgs("-library", libraries.artifacts.map { it.artifact.canonicalPath })
|
||||||
|
|
||||||
addKey("-no-default-libs", noDefaultLibs)
|
addKey("-no-default-libs", noDefaultLibs)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ konanTargetList.forEach { target ->
|
|||||||
noEndorsedLibs(true)
|
noEndorsedLibs(true)
|
||||||
noPack(true)
|
noPack(true)
|
||||||
libraries {
|
libraries {
|
||||||
klibs(df.config.depends.map { "${fileNamePrefix}${it}" })
|
klibFiles(df.config.depends.map { "$konanHome/klib/platform/$targetName/${fileNamePrefix}${it}" })
|
||||||
}
|
}
|
||||||
extraOpts("-Xpurge-user-libs", "-Xshort-module-name", df.name, "-Xdisable-experimental-annotation")
|
extraOpts("-Xpurge-user-libs", "-Xshort-module-name", df.name, "-Xdisable-experimental-annotation")
|
||||||
compilerOpts("-fmodules-cache-path=${project.buildDir}/clangModulesCache")
|
compilerOpts("-fmodules-cache-path=${project.buildDir}/clangModulesCache")
|
||||||
|
|||||||
Reference in New Issue
Block a user