ea21662bed
In 1.3.0 only basic settings for final native binaries (e.g.
executables or frameworks) are available. They allow a user to
specify what kinds of binaries should be produced from one or another
compilation but they don't allow specifying different options for
different binaries or creating more than 2 (debug and release)
binaries of the same kind (e.g. executable) from the same
compilation. Also link tasks for these binaries are created after
project evaluation thus they are inaccessible for a user outside
of an afterEvaluate block.
This patch adds an extended binary DSL allowing a user to declare
binaries independently from compilations and to specify different
options (e.g. linker arguments) for different binaries. Also
link tasks for binaries declared in this DSL are created at a
configuration time so user can access them outside of an
afterEvaluate block.
Also this patch adds creating run tasks for all executables
declared in the buildscript (KT-28106)
Initial DSL methods for binaries declaration are still supported.
Kotlin DSL example is the following:
kotlin {
macosX64 {
binaries {
// Create debug and release executable with
// a name prefix 'Foo'.
// Two domain objects will be created:
// fooDebugExecutable and fooReleaseExecutable
executable("Foo", listOf(RELEASE, DEBUG)) {
compilation = compilations["foo"]
entryPoint = "foo.main"
linkerOpts.add("-Llib/path")
println(runTask.name)
}
// Name prefix and build types are optional.
// debugFramework and releaseFramework are created here.
framework()
}
}
}
34 lines
1.1 KiB
Kotlin
34 lines
1.1 KiB
Kotlin
import org.gradle.jvm.tasks.Jar
|
|
|
|
plugins {
|
|
kotlin("jvm")
|
|
}
|
|
|
|
dependencies {
|
|
compile(gradleApi())
|
|
compile(project(":kotlin-gradle-plugin-api"))
|
|
compile(project(":kotlin-native:kotlin-native-utils"))
|
|
}
|
|
|
|
val generateMppTargetContainerWithPresets by generator(
|
|
"org.jetbrains.kotlin.generators.gradle.dsl.MppPresetFunctionsCodegenKt",
|
|
sourceSets["main"]
|
|
)
|
|
|
|
val generateAbstractBinaryContainer by generator(
|
|
"org.jetbrains.kotlin.generators.gradle.dsl.MppNativeBinaryDSLCodegenKt",
|
|
sourceSets["main"]
|
|
)
|
|
|
|
listOf(generateMppTargetContainerWithPresets, generateAbstractBinaryContainer).forEach {
|
|
it.systemProperty(
|
|
"org.jetbrains.kotlin.generators.gradle.dsl.outputSourceRoot",
|
|
project(":kotlin-gradle-plugin").projectDir.resolve("src/main/kotlin").absolutePath
|
|
)
|
|
}
|
|
|
|
// Workaround: 'java -jar' refuses to read the original dotted filename on Windows, 'Unable to access jarFile org.jetbrains.kotlin....jar'
|
|
tasks.named<Jar>(generateMppTargetContainerWithPresets.name + "WriteClassPath").configure {
|
|
archiveName = generateMppTargetContainerWithPresets.name
|
|
}
|