From 76ab1300118dedec14214277ab72b0fffc716163 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Tue, 7 Feb 2023 19:49:11 +0100 Subject: [PATCH] [K/N] Make executors be separate included project This change will make possible use Executors in old, gtest and new test infrastructures. Merge-request: KT-MR-8964 --- kotlin-native/build-tools/build.gradle.kts | 4 +- kotlin-native/build-tools/gradle.properties | 3 +- kotlin-native/build-tools/settings.gradle.kts | 3 ++ .../org/jetbrains/kotlin/ExecutorService.kt | 2 +- .../org/jetbrains/kotlin/FrameworkTest.kt | 2 +- .../org/jetbrains/kotlin/cpp/RunGTest.kt | 2 +- native/executors/build.gradle.kts | 53 +++++++++++++++++++ .../native}/executors/EmulatorExecutor.kt | 4 +- .../kotlin/native}/executors/Executor.kt | 7 +-- .../kotlin/native}/executors/HostExecutor.kt | 4 +- .../kotlin/native}/executors/NoOpExecutor.kt | 7 +-- .../kotlin/native}/executors/WasmExecutor.kt | 4 +- .../native/executors}/XcRunRuntimeUtils.kt | 11 +++- .../executors/XcodeSimulatorExecutor.kt | 4 +- settings.gradle | 1 + 15 files changed, 91 insertions(+), 20 deletions(-) create mode 100644 native/executors/build.gradle.kts rename {kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin => native/executors/src/main/kotlin/org/jetbrains/kotlin/native}/executors/EmulatorExecutor.kt (94%) rename {kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin => native/executors/src/main/kotlin/org/jetbrains/kotlin/native}/executors/Executor.kt (95%) rename {kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin => native/executors/src/main/kotlin/org/jetbrains/kotlin/native}/executors/HostExecutor.kt (96%) rename {kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin => native/executors/src/main/kotlin/org/jetbrains/kotlin/native}/executors/NoOpExecutor.kt (88%) rename {kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin => native/executors/src/main/kotlin/org/jetbrains/kotlin/native}/executors/WasmExecutor.kt (92%) rename {kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin => native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors}/XcRunRuntimeUtils.kt (92%) rename {kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin => native/executors/src/main/kotlin/org/jetbrains/kotlin/native}/executors/XcodeSimulatorExecutor.kt (98%) diff --git a/kotlin-native/build-tools/build.gradle.kts b/kotlin-native/build-tools/build.gradle.kts index 4f65055cb02..ff013f0c75f 100644 --- a/kotlin-native/build-tools/build.gradle.kts +++ b/kotlin-native/build-tools/build.gradle.kts @@ -58,7 +58,9 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-metadata-klib:$metadataVersion") implementation("org.jetbrains.kotlin:kotlin-util-klib:${project.bootstrapKotlinVersion}") - api(project(":kotlin-native-shared")) + + implementation(project(":kotlin-native-shared")) + implementation(project(":kotlin-native-executors")) } java { diff --git a/kotlin-native/build-tools/gradle.properties b/kotlin-native/build-tools/gradle.properties index 26f79cb7fea..44def09fabe 100644 --- a/kotlin-native/build-tools/gradle.properties +++ b/kotlin-native/build-tools/gradle.properties @@ -2,4 +2,5 @@ cacheRedirectorEnabled=true bootstrap.kotlin.default.version=1.9.0-dev-877 kotlin.build.gradlePlugin.version=0.0.39 -kotlin.native.build.composite-bootstrap=true \ No newline at end of file +kotlin.native.build.composite-bootstrap=true +kotlin.native.enabled=true \ No newline at end of file diff --git a/kotlin-native/build-tools/settings.gradle.kts b/kotlin-native/build-tools/settings.gradle.kts index 52b429e8a74..ac053842130 100644 --- a/kotlin-native/build-tools/settings.gradle.kts +++ b/kotlin-native/build-tools/settings.gradle.kts @@ -39,3 +39,6 @@ project(":kotlin-native-shared").projectDir = File("$rootDir/../shared") //project(":native:kotlin-native-utils").projectDir = File("$rootDir/../../native/kotlin-native-utils") //project(":kotlin-util-klib").projectDir = File("$rootDir/../../compiler/util-klib") //project(":kotlin-util-io").projectDir = File("$rootDir/../../compiler/util-io") + +include(":kotlin-native-executors") +project(":kotlin-native-executors").projectDir = File("$rootDir/../../native/executors") \ No newline at end of file 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 21e65c79d09..d5d1662ddf8 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 @@ -25,7 +25,7 @@ import org.gradle.process.* import org.gradle.process.internal.DefaultExecSpec import org.gradle.process.internal.ExecException import org.jetbrains.kotlin.konan.target.* -import org.jetbrains.kotlin.executors.* +import org.jetbrains.kotlin.native.executors.* import java.io.* diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt index 028b0b9c5b8..5f0510059ee 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt @@ -12,8 +12,8 @@ import org.gradle.api.tasks.TaskAction import org.gradle.language.base.plugins.LifecycleBasePlugin import org.jetbrains.kotlin.konan.target.* +import org.jetbrains.kotlin.native.executors.* import java.io.File - import java.io.FileWriter import java.io.Serializable import java.nio.file.Files 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 56f58ec6b87..c5236c0b078 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 @@ -13,7 +13,7 @@ import org.gradle.kotlin.dsl.getByType import org.gradle.workers.WorkAction import org.gradle.workers.WorkParameters import org.gradle.workers.WorkerExecutor -import org.jetbrains.kotlin.executors.* +import org.jetbrains.kotlin.native.executors.* import org.jetbrains.kotlin.konan.target.* import javax.inject.Inject diff --git a/native/executors/build.gradle.kts b/native/executors/build.gradle.kts new file mode 100644 index 00000000000..18226c1f594 --- /dev/null +++ b/native/executors/build.gradle.kts @@ -0,0 +1,53 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +buildscript { + dependencies { + classpath("com.google.code.gson:gson:2.8.9") + } +} + +plugins { + kotlin("jvm") +} + +repositories { + mavenCentral() +} + +dependencies { + implementation("com.google.code.gson:gson:2.8.9") + configurations.all { + resolutionStrategy.eachDependency { + if (requested.group == "com.google.code.gson" && requested.name == "gson") { + useVersion("2.8.9") + because("Force using same gson version because of https://github.com/google/gson/pull/1991") + } + } + } + + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0") + if (kotlinBuildProperties.isKotlinNativeEnabled) { + implementation(project(":kotlin-native-shared")) + } else { + implementation(project(":native:kotlin-native-utils")) + } +} + +group = "org.jetbrains.kotlin" + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + } +} + +tasks.withType().configureEach { + kotlinOptions { + freeCompilerArgs += listOf( + "-Xskip-prerelease-check", + "-Xsuppress-version-warnings", + "-opt-in=kotlin.ExperimentalStdlibApi", + "-opt-in=kotlin.RequiresOptIn" + ) + } +} diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/EmulatorExecutor.kt b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/EmulatorExecutor.kt similarity index 94% rename from kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/EmulatorExecutor.kt rename to native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/EmulatorExecutor.kt index 61309c0b53a..138687e8411 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/EmulatorExecutor.kt +++ b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/EmulatorExecutor.kt @@ -1,9 +1,9 @@ /* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package org.jetbrains.kotlin.executors +package org.jetbrains.kotlin.native.executors import org.jetbrains.kotlin.konan.target.Configurables import org.jetbrains.kotlin.konan.target.ConfigurablesWithEmulator diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/Executor.kt b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/Executor.kt similarity index 95% rename from kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/Executor.kt rename to native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/Executor.kt index f3d877c19d8..dbc9329c310 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/Executor.kt +++ b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/Executor.kt @@ -1,14 +1,15 @@ /* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:OptIn(kotlin.time.ExperimentalTime::class) +@file:OptIn(ExperimentalTime::class) -package org.jetbrains.kotlin.executors +package org.jetbrains.kotlin.native.executors import java.io.* import kotlin.time.Duration +import kotlin.time.ExperimentalTime private class CloseProtectedOutputStream(stream : OutputStream) : FilterOutputStream(stream) { override fun close() { diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/HostExecutor.kt b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/HostExecutor.kt similarity index 96% rename from kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/HostExecutor.kt rename to native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/HostExecutor.kt index f46d3d0b09f..3e7f7c70f6a 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/HostExecutor.kt +++ b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/HostExecutor.kt @@ -1,11 +1,11 @@ /* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @file:OptIn(ExperimentalTime::class) -package org.jetbrains.kotlin.executors +package org.jetbrains.kotlin.native.executors import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/NoOpExecutor.kt b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/NoOpExecutor.kt similarity index 88% rename from kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/NoOpExecutor.kt rename to native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/NoOpExecutor.kt index 344270a5550..30acd614bee 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/NoOpExecutor.kt +++ b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/NoOpExecutor.kt @@ -1,15 +1,16 @@ /* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:OptIn(kotlin.time.ExperimentalTime::class) +@file:OptIn(ExperimentalTime::class) -package org.jetbrains.kotlin.executors +package org.jetbrains.kotlin.native.executors import java.io.File import java.util.logging.Logger import kotlin.time.Duration +import kotlin.time.ExperimentalTime /** * [Executor] that does not run the process and immediately returns a successful response. diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/WasmExecutor.kt b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/WasmExecutor.kt similarity index 92% rename from kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/WasmExecutor.kt rename to native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/WasmExecutor.kt index 8bb04a11309..b8148319b15 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/WasmExecutor.kt +++ b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/WasmExecutor.kt @@ -1,9 +1,9 @@ /* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package org.jetbrains.kotlin.executors +package org.jetbrains.kotlin.native.executors import org.jetbrains.kotlin.konan.target.Configurables import org.jetbrains.kotlin.konan.target.WasmConfigurables diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/XcRunRuntimeUtils.kt b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/XcRunRuntimeUtils.kt similarity index 92% rename from kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/XcRunRuntimeUtils.kt rename to native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/XcRunRuntimeUtils.kt index 6c6a3553c13..d9fec58eb69 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/XcRunRuntimeUtils.kt +++ b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/XcRunRuntimeUtils.kt @@ -1,10 +1,19 @@ -package org.jetbrains.kotlin +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ +package org.jetbrains.kotlin.native.executors + +import com.google.gson.Gson +import com.google.gson.GsonBuilder import com.google.gson.annotations.Expose import org.jetbrains.kotlin.konan.target.Family import org.jetbrains.kotlin.konan.target.Xcode import kotlin.math.min +internal val gson: Gson by lazy { GsonBuilder().excludeFieldsWithoutExposeAnnotation().create()!! } + /** * Compares two strings assuming that both are representing numeric version strings. * Examples of numeric version strings: "12.4.1.2", "9", "0.5". diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/XcodeSimulatorExecutor.kt b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/XcodeSimulatorExecutor.kt similarity index 98% rename from kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/XcodeSimulatorExecutor.kt rename to native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/XcodeSimulatorExecutor.kt index 5620dfc7389..370e597aa16 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/executors/XcodeSimulatorExecutor.kt +++ b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/XcodeSimulatorExecutor.kt @@ -1,9 +1,9 @@ /* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package org.jetbrains.kotlin.executors +package org.jetbrains.kotlin.native.executors import org.jetbrains.kotlin.konan.target.* import org.jetbrains.kotlin.* diff --git a/settings.gradle b/settings.gradle index 86d2a26f635..94a07770759 100644 --- a/settings.gradle +++ b/settings.gradle @@ -101,6 +101,7 @@ include ":benchmarks", ":native:kotlin-klib-commonizer", ":native:kotlin-klib-commonizer-api", ":native:kotlin-klib-commonizer-embeddable", + ":native:executors", ":core:compiler.common", ":core:compiler.common.jvm", ":core:compiler.common.js",