Don't override compilation freeCompilerArgs in link task
Calling '.addAll()' was replacing convention value leading for inability to add/modify Kotlin/Native link task freeCompilerArgs via KotlinCompilation.options.freeCompilerArgs. For now convention was replaced by normal value. ^KT-56280 Fixed
This commit is contained in:
committed by
Space Team
parent
ff2db23c11
commit
752de6c622
+47
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.gradle.native
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import kotlin.io.path.appendText
|
||||
|
||||
@DisplayName("KotlinNativeLink task tests")
|
||||
@NativeGradlePluginTests
|
||||
@@ -20,4 +21,50 @@ internal class KotlinNativeLinkIT : KGPBaseTest() {
|
||||
build("tasks")
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("KT-56280: should propagate freeCompilerArgs from compilation")
|
||||
@GradleTest
|
||||
fun shouldUseCompilationFreeCompilerArgs(gradleVersion: GradleVersion) {
|
||||
nativeProject("native-link-simple", gradleVersion) {
|
||||
buildGradle.appendText(
|
||||
"""
|
||||
|
|
||||
|kotlin {
|
||||
| targets.named("host").configure {
|
||||
| binaries.executable()
|
||||
| }
|
||||
|
|
||||
| targets.withType(org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget.class) {
|
||||
| compilations.main.kotlinOptions {
|
||||
| freeCompilerArgs += ["-e", "main"]
|
||||
| }
|
||||
| }
|
||||
|}
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
build("linkReleaseExecutableHost") {
|
||||
val linkTaskOutput = output
|
||||
.substringAfter("Task :linkReleaseExecutableHost")
|
||||
.substringBefore("Task :linkHost")
|
||||
assert(linkTaskOutput.isNotEmpty()) {
|
||||
"Could not get :linkReleaseExecutableHost task output!"
|
||||
}
|
||||
|
||||
val args = linkTaskOutput
|
||||
.substringAfterLast("Transformed arguments = [")
|
||||
.substringBefore("]")
|
||||
.lines()
|
||||
.map { it.trim() }
|
||||
assert(
|
||||
args.isNotEmpty() &&
|
||||
args.contains("-e") &&
|
||||
args.contains("main")
|
||||
) {
|
||||
printBuildOutput()
|
||||
"Link task arguments does not contain '-e main'!"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user