[K/N] Fix handling custom llvm and libffi distributions ^KT-63220
This commit is contained in:
committed by
Space Team
parent
eba1fdec1d
commit
fe94876d9a
+16
-1
@@ -19,7 +19,9 @@ import org.jetbrains.kotlin.konan.target.TargetDomainObjectContainer
|
||||
import org.jetbrains.kotlin.konan.target.TargetWithSanitizer
|
||||
import org.jetbrains.kotlin.konan.util.DependencyProcessor
|
||||
import org.jetbrains.kotlin.utils.capitalized
|
||||
import java.nio.file.Paths
|
||||
import javax.inject.Inject
|
||||
import kotlin.io.path.name
|
||||
|
||||
/**
|
||||
* Downloading native dependencies.
|
||||
@@ -109,7 +111,7 @@ abstract class NativeDependenciesDownloaderExtension @Inject constructor(private
|
||||
}
|
||||
}
|
||||
|
||||
val dependencies by loader::dependencies
|
||||
private val dependencies by loader::dependencies
|
||||
|
||||
val task = project.tasks.register<NativeDependenciesDownloader>("nativeDependencies${_target.name.capitalized}") {
|
||||
description = "Download dependencies for $_target"
|
||||
@@ -132,6 +134,19 @@ abstract class NativeDependenciesDownloaderExtension @Inject constructor(private
|
||||
builtBy(task)
|
||||
}
|
||||
}
|
||||
// Check for overridden distributions. They'll be absent from `depedencies` and
|
||||
// so should be added manually.
|
||||
listOf(loader.llvmHome!!, loader.libffiDir!!).forEach { dependency ->
|
||||
val dependencyPath = Paths.get(dependency)
|
||||
// If dependency is an absolute path - it's overridden.
|
||||
if (dependencyPath.isAbsolute) {
|
||||
artifact(dependencyPath.toFile()) {
|
||||
name = dependencyPath.name
|
||||
type = "directory"
|
||||
extension = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-2
@@ -13,7 +13,19 @@ import org.gradle.api.attributes.Usage
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
import java.io.File
|
||||
import java.nio.file.Paths
|
||||
import javax.inject.Inject
|
||||
import kotlin.io.path.isSameFileAs
|
||||
|
||||
private fun File.matchesDependency(dependency: String): Boolean {
|
||||
val path = Paths.get(dependency)
|
||||
return if (path.isAbsolute) {
|
||||
path.isSameFileAs(this.toPath())
|
||||
} else {
|
||||
this.name == dependency
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Consuming native dependencies.
|
||||
@@ -47,11 +59,11 @@ abstract class NativeDependenciesExtension @Inject constructor(private val proje
|
||||
}
|
||||
|
||||
private val llvmFileCollection: FileCollection = nativeDependencies.incoming.artifacts.artifactFiles.filter {
|
||||
it.name == platformManager.hostPlatform.llvmHome
|
||||
it.matchesDependency(platformManager.hostPlatform.llvmHome!!)
|
||||
}
|
||||
|
||||
private val libffiFileCollection: FileCollection = nativeDependencies.incoming.artifacts.artifactFiles.filter {
|
||||
it.name == platformManager.hostPlatform.libffiDir
|
||||
it.matchesDependency(platformManager.hostPlatform.libffiDir!!)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user