From 6a8ebeb1bc82796396cb18bcb76de0b6933ccb69 Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Fri, 8 Apr 2022 16:26:26 +0300 Subject: [PATCH] [K/N] Test case for KT-50983 --- kotlin-native/backend.native/tests/build.gradle | 13 +++++++++++++ .../tests/windows/KT-50983/File.rc | 16 ++++++++++++++++ .../tests/windows/KT-50983/main.kt | 8 ++++++++ .../main/kotlin/org/jetbrains/kotlin/Utils.kt | 5 +++++ 4 files changed, 42 insertions(+) create mode 100644 kotlin-native/backend.native/tests/windows/KT-50983/File.rc create mode 100644 kotlin-native/backend.native/tests/windows/KT-50983/main.kt diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index d918c0c044f..eae1b330720 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -5049,6 +5049,19 @@ if (PlatformInfo.isAppleTarget(project)) { } } +tasks.register("KT-50983", KonanDriverTest) { + enabled = PlatformInfo.isWindows() && (project.target.family == Family.MINGW) + doBeforeBuild { + mkdir(buildDir) + exec { + commandLine UtilsKt.binaryFromToolchain(project, "windres") + args "$projectDir/windows/KT-50983/File.rc", "-O", "coff", "-o", "$buildDir/File.res" + } + } + source = "windows/KT-50983/main.kt" + flags = ['-linker-option', "$buildDir/File.res"] +} + standaloneTest("jsinterop_math") { doBeforeBuild { def jsinteropScript = isWindows() ? "jsinterop.bat" : "jsinterop" diff --git a/kotlin-native/backend.native/tests/windows/KT-50983/File.rc b/kotlin-native/backend.native/tests/windows/KT-50983/File.rc new file mode 100644 index 00000000000..7f3d40bf503 --- /dev/null +++ b/kotlin-native/backend.native/tests/windows/KT-50983/File.rc @@ -0,0 +1,16 @@ +1 VERSIONINFO + FILEVERSION 5,0,0,1 + PRODUCTVERSION 5,0,0,1 + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904E4" + BEGIN + VALUE "CompanyName", "CompanyName" + VALUE "FileDescription", "Test Application" + VALUE "FileVersion", "1.0" + VALUE "InternalName", "Test" + VALUE "OriginalFilename", "Test.exe" + END + END + END \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/windows/KT-50983/main.kt b/kotlin-native/backend.native/tests/windows/KT-50983/main.kt new file mode 100644 index 00000000000..fa2c9829e74 --- /dev/null +++ b/kotlin-native/backend.native/tests/windows/KT-50983/main.kt @@ -0,0 +1,8 @@ +/* + * Copyright 2010-2022 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. + */ + +fun main() { + println("hello") +} \ No newline at end of file diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt index 29a2fce19fe..8c524c73cac 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt @@ -498,6 +498,11 @@ fun Project.buildStaticLibrary(cSources: Collection, output: File, objDir: } } +fun Project.binaryFromToolchain(toolName: String): File { + val platform = platformManager.platform(testTarget) + return File("${platform.configurables.absoluteTargetToolchain}/bin/$toolName") +} + // Workaround the deprecation warning from stdlib's appendln, which is reported because this module is compiled with API version 1.3. internal fun StringBuilder.appendln(o: Any?) { append(o)