[K/N] Refactor :kotlin-native:dependencies

Move K/N dependencies handling logic into gradle plugins:

`NativeDependenciesDownloader` is instantiated in
`:kotlin-native:dependencies` and provides a single configuration that
contains all directories with the dependencies. The configuration has
a variant for each target.

`NativeDependencies` is instantiated by projects that require native
dependencies (i.e. previously used to depend on
`:kotlin-native:dependencies:update`). This plugin creates a configuration
that by default depends on `:kotlin-native:dependencies`. Its extension
provides `llvmDependency`, `libffiDependency`, `hostPlatformDependency`,
`targetDependency()` to depend on the parts needed for the project and
provides accessors `llvmPath`, `libffiPath`, `hostPlatform` that are
safe to use during configuration time, but which do not automatically
resolve those dependencies.

`llvmDir`, `*LibffiDir` properties on `:kotlin-native` are removed
completely, as their use is replaced by `NativeDependencies`. As a
consequence, `evaluationDependsOn(":kotlin-native:dependencies")` is
also gone.

All direct dependencies on `:kotlin-native:dependencies:update` are
replaced with dependencies on specific parts via `NativeDependencies`
This commit is contained in:
Alexander Shabalin
2023-08-28 11:55:32 +02:00
committed by Space Team
parent 9de791b9ac
commit 4922223bec
23 changed files with 519 additions and 186 deletions
@@ -15,17 +15,12 @@
*/
import org.jetbrains.kotlin.tools.lib
import org.jetbrains.kotlin.*
import org.jetbrains.kotlin.*
import org.jetbrains.kotlin.konan.target.ClangArgs
import org.jetbrains.kotlin.konan.target.HostManager
plugins {
id("native")
}
val llvmDir = project.findProperty("llvmDir")
native {
val obj = if (HostManager.hostIsMingw) "obj" else "o"
val cxxflags = mutableListOf(
@@ -35,7 +30,7 @@ native {
)
suffixes {
(".cpp" to ".$obj") {
tool(*platformManager.hostPlatform.clangForJni.clangCXX("").toTypedArray())
tool(*hostPlatform.clangForJni.clangCXX("").toTypedArray())
flags(*cxxflags.toTypedArray(), "-c", "-o", ruleOut(), ruleInFirst())
}
@@ -48,7 +43,7 @@ native {
val objSet = sourceSets["main"]!!.transform(".cpp" to ".$obj")
target(lib("debugInfo"), objSet) {
tool(*platformManager.hostPlatform.clangForJni.llvmAr("").toTypedArray())
tool(*hostPlatform.clangForJni.llvmAr("").toTypedArray())
flags("-qcv", ruleOut(), *ruleInAll())
}
}