This tool allows one to run a KMP Gradle build in such a way that the link tasks (aka “the Kotlin/Native second compilation stage”) get additional Gradle flags.
with-link-args <link args> -- <gradlew> <common args>
To use a different compiler in the link tasks:
with-link-args \ -Pkotlin.native.home=/Users/jetbrains/kotlin/kotlin-native/dist -- \ ./gradlew clean check
So the -Pkotlin.native.home
flag affects only the link tasks but not the compile tasks.
Similar functionality is not available in the KGP directly: KT-61104.
To achieve that effect, the script runs the build twice: first without the link tasks, then only link tasks and everything depending on them, with extra arguments.
To disable a stage, it uses a Gradle init script that disables the tasks that do/don't depend on any link tasks.
The result is roughly equivalent to running a single build with passing the extra arguments only to the link tasks.