[Gradle] Don't sync freeCompilerArgs second time for the Native link task
Since CompilerOptions and LanguageSettings are synchronized between each other, we don't need this additional sync that actually duplicates arguments. ^KT-61700 Fixed
This commit is contained in:
committed by
Space Team
parent
fda47c45ec
commit
d5f4cd72b7
+8
-20
@@ -28,7 +28,11 @@ internal class KotlinNativeLinkIT : KGPBaseTest() {
|
|||||||
@DisplayName("KT-56280: should propagate freeCompilerArgs from compilation")
|
@DisplayName("KT-56280: should propagate freeCompilerArgs from compilation")
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun shouldUseCompilationFreeCompilerArgs(gradleVersion: GradleVersion) {
|
fun shouldUseCompilationFreeCompilerArgs(gradleVersion: GradleVersion) {
|
||||||
nativeProject("native-link-simple", gradleVersion) {
|
nativeProject(
|
||||||
|
"native-link-simple",
|
||||||
|
gradleVersion,
|
||||||
|
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
|
||||||
|
) {
|
||||||
buildGradle.appendText(
|
buildGradle.appendText(
|
||||||
"""
|
"""
|
||||||
|
|
|
|
||||||
@@ -47,25 +51,9 @@ internal class KotlinNativeLinkIT : KGPBaseTest() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
build("linkReleaseExecutableHost") {
|
build("linkReleaseExecutableHost") {
|
||||||
val linkTaskOutput = output
|
extractNativeTasksCommandLineArgumentsFromOutput(":linkReleaseExecutableHost") {
|
||||||
.substringAfter("Task :linkReleaseExecutableHost")
|
assertCommandLineArgumentsContain("-e", "main")
|
||||||
.substringBefore("Task :linkHost")
|
assertNoDuplicates()
|
||||||
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'!"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-1
@@ -328,4 +328,14 @@ fun CommandLineArguments.assertCommandLineArgumentsContain(
|
|||||||
"There is no ${it} in actual command line arguments are: ${args}"
|
"There is no ${it} in actual command line arguments are: ${args}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the command line arguments do not contain any duplicates.
|
||||||
|
*/
|
||||||
|
fun CommandLineArguments.assertNoDuplicates() {
|
||||||
|
assert(args.size == args.toSet().size) {
|
||||||
|
buildResult.printBuildOutput()
|
||||||
|
"Link task has duplicated arguments: ${args.joinToString()}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
-14
@@ -88,15 +88,6 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget> : AbstractKotl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Project.syncLanguageSettingsToLinkTask(binary: NativeBinary) {
|
|
||||||
tasks.named<KotlinNativeLink>(binary.linkTaskName).configure { linkTask ->
|
|
||||||
// We propagate compilation free args to the link task for now (see KT-33717).
|
|
||||||
linkTask.toolOptions.freeCompilerArgs.addAll(
|
|
||||||
binary.compilation.compilerOptions.options.freeCompilerArgs
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Project.createRunTask(binary: Executable) {
|
private fun Project.createRunTask(binary: Executable) {
|
||||||
val taskName = binary.runTaskName ?: return
|
val taskName = binary.runTaskName ?: return
|
||||||
registerTask<Exec>(taskName) { exec ->
|
registerTask<Exec>(taskName) { exec ->
|
||||||
@@ -236,11 +227,6 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget> : AbstractKotl
|
|||||||
target.binaries.all {
|
target.binaries.all {
|
||||||
project.createLinkTask(it)
|
project.createLinkTask(it)
|
||||||
}
|
}
|
||||||
project.runOnceAfterEvaluated("Sync language settings for NativeLinkTask") {
|
|
||||||
target.binaries.all { binary ->
|
|
||||||
project.syncLanguageSettingsToLinkTask(binary)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
target.binaries.withType(Executable::class.java).all {
|
target.binaries.withType(Executable::class.java).all {
|
||||||
project.createRunTask(it)
|
project.createRunTask(it)
|
||||||
|
|||||||
Reference in New Issue
Block a user