Gradle, native: Report passing binary-specific args to compilation
Earlier we propagated all free args specified for a compilation into a link task. It was required because the link task actually compiled the same source as the compile task but with another output kind. But currently a link task produces a final binary from a klib instead of sources. It means that such a propagation becomes incorrect. Now options related to the compiler frontend like -Xexperimental must be specified per compilation while options related to the compiler backend (e.g. -opt, -g, -Xstatic-framework etc) - per binary. This path shows a special warning if some of "binary-specific" arguments are passed to a compilation.
This commit is contained in:
+35
@@ -1117,6 +1117,41 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNativeFreeArgsWarning() = with(transformProjectWithPluginsDsl("kotlin-dsl", gradleVersion, "new-mpp-native-binaries")) {
|
||||
gradleBuildScript().appendText(
|
||||
"""kotlin.targets["macos64"].compilations["main"].kotlinOptions.freeCompilerArgs += "-opt""""
|
||||
)
|
||||
gradleBuildScript("exported").appendText(
|
||||
"""
|
||||
kotlin.targets["macos64"].compilations["main"].kotlinOptions.freeCompilerArgs += "-opt"
|
||||
kotlin.targets["macos64"].compilations["test"].kotlinOptions.freeCompilerArgs += "-g"
|
||||
kotlin.targets["linux64"].compilations["main"].kotlinOptions.freeCompilerArgs +=
|
||||
listOf("-g", "-Xdisable-phases=Devirtualization,BuildDFG")
|
||||
""".trimIndent()
|
||||
)
|
||||
build("tasks") {
|
||||
assertSuccessful()
|
||||
assertContains(
|
||||
"""
|
||||
The following free compiler arguments must be specified for a binary instead of a compilation:
|
||||
* In project ':':
|
||||
* In target 'macos64':
|
||||
* Compilation: 'main', arguments: [-opt]
|
||||
* In project ':exported':
|
||||
* In target 'linux64':
|
||||
* Compilation: 'main', arguments: [-g, -Xdisable-phases=Devirtualization,BuildDFG]
|
||||
* In target 'macos64':
|
||||
* Compilation: 'main', arguments: [-opt]
|
||||
* Compilation: 'test', arguments: [-g]
|
||||
|
||||
Please move them into final binary declarations. E.g. binaries.executable { freeCompilerArgs += "..." }
|
||||
See more about final binaries: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#building-final-native-binaries.
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSourceJars() = with(Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")) {
|
||||
setupWorkingDir()
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ kotlin {
|
||||
|
||||
executable("test2", [RELEASE]) {
|
||||
compilation = compilations["test"]
|
||||
freeCompilerArgs.add("-tr")
|
||||
freeCompilerArgs += "-tr"
|
||||
linkTask.kotlinOptions {
|
||||
freeCompilerArgs += "-Xtime"
|
||||
}
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ kotlin {
|
||||
|
||||
executable("test2") {
|
||||
compilation = compilations["test"]
|
||||
freeCompilerArgs.add("-tr")
|
||||
freeCompilerArgs += "-tr"
|
||||
linkTask.kotlinOptions {
|
||||
freeCompilerArgs += "-Xtime"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user