Pass absolute library paths to native compiler

This commit is contained in:
Ilya Matveev
2018-09-19 21:30:35 +03:00
committed by Ilya Matveev
parent 09cd038e4b
commit a6f2af03e7
3 changed files with 21 additions and 7 deletions
@@ -620,6 +620,11 @@ open class KotlinNativeTargetConfigurator(
val interopOutput = project.files(outputFileProvider).builtBy(this)
with(compilation) {
project.dependencies.add(compileDependencyConfigurationName, interopOutput)
if (isMainCompilation) {
target.compilations.findByName(TEST_COMPILATION_NAME)?.let {
project.dependencies.add(it.compileDependencyConfigurationName, interopOutput)
}
}
project.dependencies.add(target.apiElementsConfigurationName, interopOutput)
}
}
@@ -68,6 +68,17 @@ internal fun MutableList<String>.addListArg(parameter: String, values: List<Stri
private fun File.providedByCompiler(project: Project): Boolean =
toPath().startsWith(project.file(project.konanHome).toPath())
// We need to filter out interop duplicates because we create copy of them for IDE.
// TODO: Remove this after interop rework.
private fun FileCollection.filterOutPublishableInteropLibs(project: Project): FileCollection {
val libDirectories = project.rootProject.allprojects.map { it.buildDir.resolve("libs").absoluteFile.toPath() }
return filter { file ->
!(file.name.contains("-cinterop-") && libDirectories.any { file.toPath().startsWith(it) })
}
}
// endregion
@@ -101,7 +112,7 @@ open class KotlinNativeCompile : AbstractCompile() {
get() = project.files(compilation.commonSources).asFileTree
val libraries: FileCollection
@InputFiles get() = compilation.compileDependencyFiles
@InputFiles get() = compilation.compileDependencyFiles.filterOutPublishableInteropLibs(project)
private val friendModule: FileCollection?
get() = compilation.friendCompilation?.output
@@ -237,8 +248,7 @@ open class KotlinNativeCompile : AbstractCompile() {
// Support only klib files for now.
it.extension == "klib" && !it.providedByCompiler(project)
}.forEach { library ->
library.parent?.let { addArg("-r", it) }
addArg("-l", library.nameWithoutExtension)
addArg("-l", library.absolutePath)
}
}
@@ -319,7 +329,7 @@ open class CInteropProcess: DefaultTask() {
@Input get() = settings.includeDirs.headerFilterDirs.files
val libraries: FileCollection
@InputFiles get() = settings.dependencyFiles
@InputFiles get() = settings.dependencyFiles.filterOutPublishableInteropLibs(project)
val extraOpts: List<String>
@Input get() = settings.extraOpts
@@ -349,8 +359,7 @@ open class CInteropProcess: DefaultTask() {
// Support only klib files for now.
it.extension == "klib" && !it.providedByCompiler(project)
}.forEach { library ->
library.parent?.let { addArg("-r", it) }
addArg("-l", library.nameWithoutExtension)
addArg("-l", library.absolutePath)
}
addArgs("-copt", allHeadersDirs.map { "-I${it.absolutePath}" })
@@ -24,7 +24,7 @@ class NativeCompilerDownloader(
) {
internal companion object {
val DEFAULT_KONAN_VERSION = KonanVersionImpl(MetaVersion.RELEASE, 0, 9, 1)
val DEFAULT_KONAN_VERSION = KonanVersionImpl(MetaVersion.DEV, 0, 9, 2, 4027)
const val BASE_DOWNLOAD_URL = "https://download.jetbrains.com/kotlin/native/builds"
}