Support getting the default K/N test binary from a compilation
Fix for https://github.com/JetBrains/kotlin-native/issues/2487
This commit is contained in:
+20
@@ -183,6 +183,26 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
build("checkBinaryGetters") {
|
||||
assertTrue(output.contains("Wasm binary file: main.wasm"))
|
||||
assertTrue(output.contains("Wasm link task: linkMainReleaseExecutableWasm32"))
|
||||
|
||||
val testFiles = listOf(
|
||||
"MacOS" to "test.kexe",
|
||||
"Windows" to "test.exe",
|
||||
"Linux" to "test.kexe"
|
||||
)
|
||||
|
||||
val testLinkTasks = listOf(
|
||||
"MacOS" to "linkTestDebugExecutableMacos64",
|
||||
"Windows" to "linkTestDebugExecutableMingw64",
|
||||
"Linux" to "linkTestDebugExecutableLinux64"
|
||||
)
|
||||
|
||||
testFiles.forEach { (platform, file) ->
|
||||
assertTrue(output.contains("$platform test file: $file"), "Cannot get test binary for platform $platform")
|
||||
}
|
||||
|
||||
testLinkTasks.forEach { (platform, task) ->
|
||||
assertTrue(output.contains("$platform test link task: $task"), "Cannot get test link task for platform $platform")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -64,6 +64,15 @@ kotlin {
|
||||
doLast {
|
||||
println("Wasm binary file: ${wasm32.compilations.getByName("main").getBinary("EXECUTABLE", "RELEASE").name}")
|
||||
println("Wasm link task: ${wasm32.compilations.getByName("main").getLinkTask("EXECUTABLE", "RELEASE").name}")
|
||||
|
||||
println("Windows test file: ${mingw64.compilations.getByName("test").getBinary("EXECUTABLE", "DEBUG").name}")
|
||||
println("Windows test link task: ${mingw64.compilations.getByName("test").getLinkTask("EXECUTABLE", "DEBUG").name}")
|
||||
|
||||
println("MacOS test file: ${macos64.compilations.getByName("test").getBinary("EXECUTABLE", "DEBUG").name}")
|
||||
println("MacOS test link task: ${macos64.compilations.getByName("test").getLinkTask("EXECUTABLE", "DEBUG").name}")
|
||||
|
||||
println("Linux test file: ${linux64.compilations.getByName("test").getBinary("EXECUTABLE", "DEBUG").name}")
|
||||
println("Linux test link task: ${linux64.compilations.getByName("test").getLinkTask("EXECUTABLE", "DEBUG").name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -84,5 +84,14 @@ task checkBinaryGetters {
|
||||
doLast {
|
||||
println("Wasm binary file: ${kotlin.targets.wasm32.compilations.main.getBinary("EXECUTABLE", "RELEASE").name}")
|
||||
println("Wasm link task: ${kotlin.targets.wasm32.compilations.main.getLinkTask("EXECUTABLE", "RELEASE").name}")
|
||||
|
||||
println("Windows test file: ${kotlin.targets.mingw64.compilations.test.getBinary("EXECUTABLE", "DEBUG").name}")
|
||||
println("Windows test link task: ${kotlin.targets.mingw64.compilations.test.getLinkTask("EXECUTABLE", "DEBUG").name}")
|
||||
|
||||
println("MacOS test file: ${kotlin.targets.macos64.compilations.test.getBinary("EXECUTABLE", "DEBUG").name}")
|
||||
println("MacOS test link task: ${kotlin.targets.macos64.compilations.test.getLinkTask("EXECUTABLE", "DEBUG").name}")
|
||||
|
||||
println("Linux test file: ${kotlin.targets.linux64.compilations.test.getBinary("EXECUTABLE", "DEBUG").name}")
|
||||
println("Linux test link task: ${kotlin.targets.linux64.compilations.test.getLinkTask("EXECUTABLE", "DEBUG").name}")
|
||||
}
|
||||
}
|
||||
-20
@@ -74,23 +74,3 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+5
-1
@@ -140,12 +140,16 @@ open class KotlinNativeBinaryContainer @Inject constructor(
|
||||
"test",
|
||||
"test",
|
||||
NativeOutputKind.EXECUTABLE,
|
||||
listOf(NativeBuildType.DEBUG),
|
||||
listOf(DEFAULT_TEST_BUILD_TYPE),
|
||||
{ name, baseName, buildType, compilation ->
|
||||
Executable(name, baseName, buildType, compilation, true)
|
||||
},
|
||||
configure
|
||||
)
|
||||
|
||||
companion object {
|
||||
internal val DEFAULT_TEST_BUILD_TYPE = NativeBuildType.DEBUG
|
||||
}
|
||||
// endregion.
|
||||
|
||||
internal inner class PrefixGroup(
|
||||
|
||||
+4
-5
@@ -25,9 +25,8 @@ import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import org.gradle.language.base.plugins.LifecycleBasePlugin
|
||||
import org.gradle.language.jvm.tasks.ProcessResources
|
||||
import org.gradle.nativeplatform.test.tasks.RunTestExecutable
|
||||
import org.jetbrains.kotlin.backend.common.atMostOne
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinNativeBinaryContainer
|
||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.TEST_COMPILATION_NAME
|
||||
@@ -38,8 +37,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink
|
||||
import org.jetbrains.kotlin.gradle.utils.isGradleVersionAtLeast
|
||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import java.util.concurrent.Callable
|
||||
@@ -587,6 +584,8 @@ open class KotlinNativeTargetConfigurator(
|
||||
override fun configureTest(target: KotlinNativeTarget) {
|
||||
target.binaries.defaultTestExecutable {
|
||||
compilation = target.compilations.maybeCreate(KotlinCompilation.TEST_COMPILATION_NAME)
|
||||
// Allow accessing the test binary using the old getters (e.g. compilations.test.getBinary('EXECUTABLE', 'DEBUG'))
|
||||
compilation.binaries[NativeOutputKind.EXECUTABLE to KotlinNativeBinaryContainer.DEFAULT_TEST_BUILD_TYPE] = this
|
||||
}
|
||||
}
|
||||
|
||||
@@ -652,7 +651,7 @@ open class KotlinNativeTargetConfigurator(
|
||||
if (this is Executable) {
|
||||
entryPoint = compilation.entryPoint
|
||||
}
|
||||
compilation.binaryTasks[outputKind to buildType] = this
|
||||
compilation.binaries[outputKind to buildType] = this
|
||||
}
|
||||
|
||||
for (kind in availableOutputKinds) {
|
||||
|
||||
+2
-2
@@ -328,7 +328,7 @@ class KotlinNativeCompilation(
|
||||
}
|
||||
|
||||
// Used only to support the old APIs. TODO: Remove when the old APIs are removed.
|
||||
internal val binaryTasks = mutableMapOf<Pair<NativeOutputKind, NativeBuildType>, NativeBinary>()
|
||||
internal val binaries = mutableMapOf<Pair<NativeOutputKind, NativeBuildType>, NativeBinary>()
|
||||
|
||||
// Native-specific DSL.
|
||||
var extraOpts = mutableListOf<String>()
|
||||
@@ -383,7 +383,7 @@ class KotlinNativeCompilation(
|
||||
}
|
||||
|
||||
// Task accessors.
|
||||
fun findLinkTask(kind: NativeOutputKind, buildType: NativeBuildType): KotlinNativeLink? = binaryTasks[kind to buildType]?.linkTask
|
||||
fun findLinkTask(kind: NativeOutputKind, buildType: NativeBuildType): KotlinNativeLink? = binaries[kind to buildType]?.linkTask
|
||||
|
||||
fun getLinkTask(kind: NativeOutputKind, buildType: NativeBuildType): KotlinNativeLink =
|
||||
findLinkTask(kind, buildType)
|
||||
|
||||
Reference in New Issue
Block a user