Build: Fix usages of deprecated ConfigureUtil in kotlin-native
Required for Gradle 7+ #KTI-559
This commit is contained in:
@@ -22,7 +22,6 @@ import org.gradle.api.GradleException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.process.ExecResult
|
||||
import org.gradle.process.ExecSpec
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
import org.jetbrains.kotlin.konan.file.*
|
||||
|
||||
@@ -69,11 +68,11 @@ class ExecClang(private val project: Project) {
|
||||
// The bare ones invoke clang with system default sysroot.
|
||||
|
||||
fun execBareClang(action: Action<in ExecSpec>): ExecResult {
|
||||
return this.execClang(emptyList<String>(), action)
|
||||
return this.execClang(emptyList(), action)
|
||||
}
|
||||
|
||||
fun execBareClang(closure: Closure<in ExecSpec>): ExecResult {
|
||||
return this.execClang(emptyList<String>(), closure)
|
||||
return this.execClang(emptyList(), closure)
|
||||
}
|
||||
|
||||
// The konan ones invoke clang with konan provided sysroots.
|
||||
@@ -105,7 +104,7 @@ class ExecClang(private val project: Project) {
|
||||
*/
|
||||
fun execClangForCompilerTests(target: KonanTarget, action: Action<in ExecSpec>): ExecResult {
|
||||
val defaultArgs = platformManager.platform(target).clang.clangArgs.toList()
|
||||
return project.exec(Action<ExecSpec> {
|
||||
return project.exec {
|
||||
action.execute(this)
|
||||
executable = if (target.family.isAppleFamily) {
|
||||
resolveToolchainExecutable(target, executable)
|
||||
@@ -113,14 +112,14 @@ class ExecClang(private val project: Project) {
|
||||
resolveExecutable(executable)
|
||||
}
|
||||
args = defaultArgs + args
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see execClangForCompilerTests
|
||||
*/
|
||||
fun execClangForCompilerTests(target: KonanTarget, closure: Closure<in ExecSpec>): ExecResult =
|
||||
execClangForCompilerTests(target, ConfigureUtil.configureUsing(closure))
|
||||
execClangForCompilerTests(target) { project.configure(this, closure) }
|
||||
|
||||
// The toolchain ones execute clang from the toolchain.
|
||||
|
||||
@@ -129,7 +128,7 @@ class ExecClang(private val project: Project) {
|
||||
}
|
||||
|
||||
fun execToolchainClang(target: String?, closure: Closure<in ExecSpec>): ExecResult {
|
||||
return this.execToolchainClang(platformManager.targetManager(target).target, ConfigureUtil.configureUsing(closure))
|
||||
return this.execToolchainClang(platformManager.targetManager(target).target) { project.configure(this, closure) }
|
||||
}
|
||||
|
||||
fun execToolchainClang(target: KonanTarget, action: Action<in ExecSpec>): ExecResult {
|
||||
@@ -141,11 +140,11 @@ class ExecClang(private val project: Project) {
|
||||
}
|
||||
|
||||
fun execToolchainClang(target: KonanTarget, closure: Closure<in ExecSpec>): ExecResult {
|
||||
return this.execToolchainClang(target, ConfigureUtil.configureUsing(closure))
|
||||
return this.execToolchainClang(target) { project.configure(this, closure) }
|
||||
}
|
||||
|
||||
private fun execClang(defaultArgs: List<String>, closure: Closure<in ExecSpec>): ExecResult {
|
||||
return this.execClang(defaultArgs, ConfigureUtil.configureUsing(closure))
|
||||
return this.execClang(defaultArgs) { project.configure(this, closure) }
|
||||
}
|
||||
|
||||
private fun execClang(defaultArgs: List<String>, action: Action<in ExecSpec>): ExecResult {
|
||||
@@ -153,7 +152,7 @@ class ExecClang(private val project: Project) {
|
||||
action.execute(this)
|
||||
executable = resolveExecutable(executable)
|
||||
|
||||
val hostPlatform = project.findProperty("hostPlatform") as Platform
|
||||
val hostPlatform = platformManager.hostPlatform
|
||||
environment["PATH"] = project.files(hostPlatform.clang.clangPaths).asPath +
|
||||
java.io.File.pathSeparator + environment["PATH"]
|
||||
args = args + defaultArgs
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.gradle.api.Action
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.process.ExecResult
|
||||
import org.gradle.process.ExecSpec
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.jetbrains.kotlin.konan.util.DependencyProcessor
|
||||
|
||||
fun execLlvmUtility(project: Project, utility: String, action: Action<in ExecSpec>): ExecResult {
|
||||
@@ -22,5 +21,5 @@ fun execLlvmUtility(project: Project, utility: String, action: Action<in ExecSpe
|
||||
}
|
||||
|
||||
fun execLlvmUtility(project: Project, utility: String, closure: Closure<in ExecSpec>): ExecResult {
|
||||
return execLlvmUtility(project, utility, ConfigureUtil.configureUsing(closure))
|
||||
return execLlvmUtility(project, utility) { project.configure(this, closure) }
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.gradle.api.Action
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.process.ExecResult
|
||||
import org.gradle.process.ExecSpec
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
|
||||
import java.io.*
|
||||
@@ -38,7 +37,8 @@ import java.util.concurrent.TimeUnit
|
||||
* @see org.gradle.api.Project.exec
|
||||
*/
|
||||
interface ExecutorService {
|
||||
fun execute(closure: Closure<in ExecSpec>): ExecResult? = execute(ConfigureUtil.configureUsing(closure))
|
||||
val project: Project
|
||||
fun execute(closure: Closure<in ExecSpec>): ExecResult? = execute { project.configure(this, closure) }
|
||||
fun execute(action: Action<in ExecSpec>): ExecResult?
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ fun create(project: Project): ExecutorService {
|
||||
private fun wasmExecutor(project: Project) = object : ExecutorService {
|
||||
val absoluteTargetToolchain = project.testTargetConfigurables.absoluteTargetToolchain
|
||||
|
||||
override val project: Project get() = project
|
||||
override fun execute(action: Action<in ExecSpec>): ExecResult? = project.exec {
|
||||
action.execute(this)
|
||||
val exe = executable
|
||||
@@ -141,7 +142,7 @@ fun runProcessWithInput(executor: (Action<in ExecSpec>) -> ExecResult?,
|
||||
* @throws IllegalStateException if there are no executor in the project.
|
||||
*/
|
||||
val Project.executor: ExecutorService
|
||||
get() = this.convention.plugins["executor"] as? ExecutorService
|
||||
get() = this.extensions.findByName("executor") as? ExecutorService
|
||||
?: throw IllegalStateException("Executor wasn't found")
|
||||
|
||||
/**
|
||||
@@ -150,6 +151,7 @@ val Project.executor: ExecutorService
|
||||
* @code `executor.add(Action { it.environment = mapOf("JAVA_OPTS" to "-verbose:gc") })::execute`
|
||||
*/
|
||||
fun ExecutorService.add(actionParameter: Action<in ExecSpec>) = object : ExecutorService {
|
||||
override val project: Project get() = this@add.project
|
||||
override fun execute(action: Action<in ExecSpec>): ExecResult? =
|
||||
this@add.execute(Action {
|
||||
action.execute(this)
|
||||
@@ -182,6 +184,7 @@ fun Project.executeAndCheck(executable: Path, arguments: List<String> = emptyLis
|
||||
fun localExecutor(project: Project) = { a: Action<in ExecSpec> -> project.exec(a) }
|
||||
|
||||
fun localExecutorService(project: Project): ExecutorService = object : ExecutorService {
|
||||
override val project: Project get() = project
|
||||
override fun execute(action: Action<in ExecSpec>): ExecResult? = project.exec(action)
|
||||
}
|
||||
|
||||
@@ -190,6 +193,8 @@ private fun emulatorExecutor(project: Project, target: KonanTarget) = object : E
|
||||
?: error("$target does not support emulation!")
|
||||
val absoluteTargetSysRoot = configurables.absoluteTargetSysRoot
|
||||
|
||||
override val project: Project get() = project
|
||||
|
||||
override fun execute(action: Action<in ExecSpec>): ExecResult? = project.exec {
|
||||
action.execute(this)
|
||||
|
||||
@@ -285,6 +290,8 @@ private fun simulator(project: Project): ExecutorService = object : ExecutorServ
|
||||
else -> error("${target.architecture} can't be used in simulator.")
|
||||
}.toTypedArray()
|
||||
|
||||
override val project: Project get() = project
|
||||
|
||||
override fun execute(action: Action<in ExecSpec>): ExecResult? = project.exec {
|
||||
action.execute(this)
|
||||
// Starting Xcode 11 `simctl spawn` requires explicit `--standalone` flag.
|
||||
@@ -320,6 +327,8 @@ private fun sshExecutor(project: Project, testTarget: KonanTarget): ExecutorServ
|
||||
else -> emptyList()
|
||||
}
|
||||
|
||||
override val project: Project get() = project
|
||||
|
||||
override fun execute(action: Action<in ExecSpec>): ExecResult {
|
||||
lateinit var executableWithLibs: ExecutableWithDynamicLibs
|
||||
|
||||
@@ -402,6 +411,8 @@ private fun deviceLauncher(project: Project) = object : ExecutorService {
|
||||
|
||||
private val bundleID = "org.jetbrains.kotlin.KonanTestLauncher"
|
||||
|
||||
override val project: Project get() = project
|
||||
|
||||
override fun execute(action: Action<in ExecSpec>): ExecResult? {
|
||||
val result: ExecResult?
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user