From 774bed875a2bbb6287a441ef41d8b74c5d1e247e Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 22 Nov 2022 11:52:08 +0100 Subject: [PATCH] Fix opt-in related bootstrap problem in kotlin-native/build-tools --- .../main/kotlin/org/jetbrains/kotlin/ExecutorService.kt | 2 +- .../src/main/kotlin/org/jetbrains/kotlin/cpp/RunGTest.kt | 3 +-- .../main/kotlin/org/jetbrains/kotlin/executors/Executor.kt | 7 +++++++ .../jetbrains/kotlin/executors/XcodeSimulatorExecutor.kt | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecutorService.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecutorService.kt index 90465e96b90..a93d0548534 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecutorService.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecutorService.kt @@ -53,7 +53,7 @@ private fun Executor.service(project: Project) = object: ExecutorService { val execSpec = project.objects.newInstance().apply { action.execute(this) } - val request = ExecuteRequest( + val request = executeRequest( executableAbsolutePath = execSpec.executable, args = execSpec.args, ).apply { diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/cpp/RunGTest.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/cpp/RunGTest.kt index 7fbc2c46810..56f58ec6b87 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/cpp/RunGTest.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/cpp/RunGTest.kt @@ -10,7 +10,6 @@ import org.gradle.api.file.RegularFileProperty import org.gradle.api.provider.Property import org.gradle.api.tasks.* import org.gradle.kotlin.dsl.getByType -import org.gradle.process.ExecOperations import org.gradle.workers.WorkAction import org.gradle.workers.WorkParameters import org.gradle.workers.WorkerExecutor @@ -51,7 +50,7 @@ private abstract class RunGTestJob : WorkAction { with(parameters) { reportFileUnprocessed.asFile.get().parentFile.mkdirs() - executor.execute(ExecuteRequest(this@with.executable.asFile.get().absolutePath).apply { + executor.execute(executeRequest(this@with.executable.asFile.get().absolutePath).apply { this.args.add("--gtest_output=xml:${reportFileUnprocessed.asFile.get().absolutePath}") filter.orNull?.also { this.args.add("--gtest_filter=${it}") diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/Executor.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/Executor.kt index 892169ae477..f3d877c19d8 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/Executor.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/Executor.kt @@ -61,6 +61,13 @@ data class ExecuteRequest( inline fun copying(block: ExecuteRequest.() -> Unit): ExecuteRequest = copy().apply(block) } +/** + * Helper for [ExecuteRequest] creation. + * Allows to create it without opting in [kotlin.time.ExperimentalTime] for API < 1.6. + */ +fun executeRequest(executableAbsolutePath: String, args: MutableList = mutableListOf()): ExecuteRequest = + ExecuteRequest(executableAbsolutePath, args) + data class ExecuteResponse( /** * Process exit code if it exited by itself, or `null` if it was killed by a timeout. diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/XcodeSimulatorExecutor.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/XcodeSimulatorExecutor.kt index b60a88c20e1..10cf4e2200e 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/XcodeSimulatorExecutor.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/XcodeSimulatorExecutor.kt @@ -17,7 +17,7 @@ private fun defaultDeviceName(target: KonanTarget) = when (target.family) { } private fun Executor.run(executableAbsolutePath: String, vararg args: String) = ByteArrayOutputStream().let { - this.execute(ExecuteRequest(executableAbsolutePath).apply { + this.execute(executeRequest(executableAbsolutePath).apply { this.args.addAll(args) stdout = it workingDirectory = File("").absoluteFile