From 625f14d9d176f8bd45270649a2f59bfd42d4ac71 Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Fri, 4 Oct 2019 15:43:55 +0300 Subject: [PATCH] [samples][coverage] Add support for Windows and Linux hosts. --- samples/coverage/build.gradle.kts | 18 +++++++++++++++--- samples/settings.gradle.kts | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/samples/coverage/build.gradle.kts b/samples/coverage/build.gradle.kts index da5c3fea60f..2391ccffd64 100644 --- a/samples/coverage/build.gradle.kts +++ b/samples/coverage/build.gradle.kts @@ -19,7 +19,19 @@ kotlin { } } - macosX64("macos") { + // Determine host preset. + val hostOs = System.getProperty("os.name") + val isMingwX64 = hostOs.startsWith("Windows") + + // Create a target for the host platform. + val hostTarget = when { + hostOs == "Mac OS X" -> macosX64("coverage") + hostOs == "Linux" -> linuxX64("coverage") + isMingwX64 -> mingwX64("coverage") + else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.") + } + + hostTarget.apply { binaries { executable(listOf(DEBUG)) } @@ -30,12 +42,12 @@ kotlin { } tasks.create("createCoverageReport") { - dependsOn("macosTest") + dependsOn("coverageTest") description = "Create coverage report" doLast { - val testDebugBinary = kotlin.targets["macos"].let { it as KotlinNativeTarget }.binaries.getExecutable("test", "debug").outputFile + val testDebugBinary = kotlin.targets["coverage"].let { it as KotlinNativeTarget }.binaries.getTest("DEBUG").outputFile exec { commandLine("llvm-profdata", "merge", "$testDebugBinary.profraw", "-o", "$testDebugBinary.profdata") } diff --git a/samples/settings.gradle.kts b/samples/settings.gradle.kts index 0ca74cea3fb..becffd3b35e 100644 --- a/samples/settings.gradle.kts +++ b/samples/settings.gradle.kts @@ -31,6 +31,7 @@ if (isMacos || isLinux || isWindows) { include(":tetris") include(":videoplayer") include(":workers") + include(":coverage") } if (isMacos || isLinux) { @@ -43,7 +44,6 @@ if (isMacos) { include(":objc") include(":opengl") include(":uikit") - include(":coverage") include(":watchos") }