[Build] Migrate most of the build logic from Project.buildDir usage

It's going to be deprecated in Gradle 8.3

There's currently no way to pass a `org.gradle.api.provider.Provider` to the JavaExec.systemProperty or Test.systemProperty. There's a workaround using `org.gradle.process.CommandLineArgumentProvider`, but I intentionally don't rework these calls as Gradle is going to allow passing providers to configure system properties: https://github.com/gradle/gradle/issues/12247#issuecomment-1568427242
^KTI-1473 In Progress
This commit is contained in:
Alexander.Likhachev
2023-10-11 22:42:51 +02:00
committed by Space Team
parent b784544f8d
commit a19bd2ed2e
69 changed files with 328 additions and 306 deletions
@@ -22,7 +22,7 @@ plugins {
val libclangextProject = project(":kotlin-native:libclangext")
val libclangextTask = libclangextProject.path + ":build"
val libclangextDir = libclangextProject.buildDir
val libclangextDir = libclangextProject.layout.buildDirectory.get().asFile
val libclangextIsEnabled = libclangextProject.findProperty("isEnabled")!! as Boolean
@@ -148,8 +148,8 @@ val nativelibs = project.tasks.register<Copy>("nativelibs") {
val clangstubsSolib = solib("clangstubs")
dependsOn(clangstubsSolib)
from("$buildDir/$clangstubsSolib")
into("$buildDir/nativelibs/")
from(layout.buildDirectory.dir(clangstubsSolib))
into(layout.buildDirectory.dir("nativelibs"))
}
kotlinNativeInterop {
@@ -183,7 +183,7 @@ tasks.withType<Test>().configureEach {
dependsOn(projectsWithNativeLibs.map { "${it.path}:nativelibs" })
dependsOn(nativeDependencies.llvmDependency)
systemProperty("java.library.path", projectsWithNativeLibs.joinToString(File.pathSeparator) {
File(it.buildDir, "nativelibs").absolutePath
it.layout.buildDirectory.dir("nativelibs").get().asFile.absolutePath
})
systemProperty("kotlin.native.llvm.libclang", "${nativeDependencies.llvmPath}/" + if (HostManager.hostIsMingw) {
@@ -192,7 +192,7 @@ tasks.withType<Test>().configureEach {
"lib/${System.mapLibraryName("clang")}"
})
systemProperty("kotlin.native.interop.indexer.temp", File(buildDir, "testTemp"))
systemProperty("kotlin.native.interop.indexer.temp", layout.buildDirectory.dir("testTemp").get().asFile)
}
// Please note that list of headers should be fixed manually.
@@ -202,14 +202,14 @@ tasks.register("updatePrebuilt") {
doLast {
copy {
from("$buildDir/nativeInteropStubs/clang/kotlin") {
from(layout.buildDirectory.dir("nativeInteropStubs/clang/kotlin")) {
include("clang/clang.kt")
}
into("prebuilt/nativeInteropStubs/kotlin")
}
copy {
from("$buildDir/interopTemp") {
from(layout.buildDirectory.dir("interopTemp")) {
include("clangstubs.c")
}
into("prebuilt/nativeInteropStubs/c")
@@ -36,7 +36,7 @@ native {
tool(*hostPlatform.clangForJni.clangCXX("").toTypedArray())
flags("-shared",
"-o",ruleOut(), *ruleInAll(),
"-L${project(":kotlin-native:libclangext").buildDir}",
"-L${project(":kotlin-native:libclangext").layout.buildDirectory.get().asFile}",
"${nativeDependencies.libffiPath}/lib/libffi.$lib",
"-lclangext")
}
@@ -54,7 +54,7 @@ dependencies {
val prepareSharedSourcesForJvm by tasks.registering(Sync::class) {
from("src/main/kotlin")
into("$buildDir/src/main/kotlin")
into(project.layout.buildDirectory.dir("src/main/kotlin"))
}
val prepareKotlinIdeaImport by tasks.registering {
dependsOn(prepareSharedSourcesForJvm)
@@ -83,6 +83,6 @@ val nativelibs = project.tasks.create<Copy>("nativelibs") {
val callbacksSolib = solib("callbacks")
dependsOn(callbacksSolib)
from("$buildDir/$callbacksSolib")
into("$buildDir/nativelibs/")
from(layout.buildDirectory.dir(callbacksSolib))
into(layout.buildDirectory.dir("nativelibs"))
}
@@ -62,7 +62,7 @@ tasks {
dependsOn(projectsWithNativeLibs.map { "${it.path}:nativelibs" })
dependsOn(nativeDependencies.llvmDependency)
systemProperty("java.library.path", projectsWithNativeLibs.joinToString(File.pathSeparator) {
File(it.buildDir, "nativelibs").absolutePath
it.layout.buildDirectory.dir("nativelibs").get().asFile.absolutePath
})
val libclangPath = "${nativeDependencies.llvmPath}/" + if (org.jetbrains.kotlin.konan.target.HostManager.hostIsMingw) {
"bin/libclang.dll"
@@ -70,7 +70,7 @@ tasks {
"lib/${System.mapLibraryName("clang")}"
}
systemProperty("kotlin.native.llvm.libclang", libclangPath)
systemProperty("kotlin.native.interop.stubgenerator.temp", File(buildDir, "stubGeneratorTestTemp"))
systemProperty("kotlin.native.interop.stubgenerator.temp", layout.buildDirectory.dir("stubGeneratorTestTemp").get().asFile)
// Set the konan.home property because we run the cinterop tool not from a distribution jar
// so it will not be able to determine this path by itself.