Gradle plugin: remove old native binary APIs
This patch removes APIs for native binary configuring introduced in 1.3.0 and deprecated in 1.3.30. Issue #KT-31229 Fixed
This commit is contained in:
-27
@@ -205,33 +205,6 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
build("clean", "assemble", "--rerun-tasks") {
|
build("clean", "assemble", "--rerun-tasks") {
|
||||||
checkAppBuild()
|
checkAppBuild()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that binary getters initially introduced in 1.3 work.
|
|
||||||
build("checkBinaryGetters") {
|
|
||||||
assertTrue(output.contains("Wasm binary file: main.wasm"))
|
|
||||||
assertTrue(output.contains("Wasm link task: linkMainReleaseExecutableWasm32"))
|
|
||||||
assertTrue(output.contains("Wasm link task name: linkMainReleaseExecutableWasm32"))
|
|
||||||
|
|
||||||
val testFiles = listOf(
|
|
||||||
"MacOS" to "test.kexe",
|
|
||||||
"Windows" to "test.exe",
|
|
||||||
"Linux" to "test.kexe"
|
|
||||||
)
|
|
||||||
|
|
||||||
val testLinkTasks = listOf(
|
|
||||||
"MacOS" to "linkTestDebugExecutableMacos64",
|
|
||||||
"Windows" to "linkTestDebugExecutableMingw64",
|
|
||||||
"Linux" to "linkTestDebugExecutableLinux64"
|
|
||||||
)
|
|
||||||
|
|
||||||
testFiles.forEach { (platform, file) ->
|
|
||||||
assertTrue(output.contains("$platform test file: $file"), "Cannot get test binary for platform $platform")
|
|
||||||
}
|
|
||||||
|
|
||||||
testLinkTasks.forEach { (platform, task) ->
|
|
||||||
assertTrue(output.contains("$platform test link task: $task"), "Cannot get test link task for platform $platform")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
with(oldStyleAppProject) {
|
with(oldStyleAppProject) {
|
||||||
|
|||||||
+6
-22
@@ -24,13 +24,14 @@ kotlin {
|
|||||||
val macos64 = macosX64("macos64")
|
val macos64 = macosX64("macos64")
|
||||||
|
|
||||||
configure(listOf(wasm32, linux64, mingw64, macos64)) {
|
configure(listOf(wasm32, linux64, mingw64, macos64)) {
|
||||||
compilations.getByName("main") {
|
binaries.executable("main") {
|
||||||
outputKinds.add(EXECUTABLE)
|
entryPoint = "com.example.app.native.main"
|
||||||
entryPoint = "com.example.app.native.main"
|
}
|
||||||
|
|
||||||
|
binaries.all {
|
||||||
// Check that linker options are correctly passed to the compiler.
|
// Check that linker options are correctly passed to the compiler.
|
||||||
linkerOpts = mutableListOf("-L.")
|
linkerOpts = mutableListOf("-L.")
|
||||||
}
|
}
|
||||||
compilations["test"].linkerOpts = mutableListOf("-L.")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -60,23 +61,6 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.create("checkBinaryGetters") {
|
|
||||||
doLast {
|
|
||||||
println("Wasm binary file: ${wasm32.compilations.getByName("main").getBinary("EXECUTABLE", "RELEASE").name}")
|
|
||||||
println("Wasm link task: ${wasm32.compilations.getByName("main").getLinkTask("EXECUTABLE", "RELEASE").name}")
|
|
||||||
println("Wasm link task name: ${wasm32.compilations.getByName("main").linkTaskName("EXECUTABLE", "RELEASE")}")
|
|
||||||
|
|
||||||
println("Windows test file: ${mingw64.compilations.getByName("test").getBinary("EXECUTABLE", "DEBUG").name}")
|
|
||||||
println("Windows test link task: ${mingw64.compilations.getByName("test").getLinkTask("EXECUTABLE", "DEBUG").name}")
|
|
||||||
|
|
||||||
println("MacOS test file: ${macos64.compilations.getByName("test").getBinary("EXECUTABLE", "DEBUG").name}")
|
|
||||||
println("MacOS test link task: ${macos64.compilations.getByName("test").getLinkTask("EXECUTABLE", "DEBUG").name}")
|
|
||||||
|
|
||||||
println("Linux test file: ${linux64.compilations.getByName("test").getBinary("EXECUTABLE", "DEBUG").name}")
|
|
||||||
println("Linux test link task: ${linux64.compilations.getByName("test").getLinkTask("EXECUTABLE", "DEBUG").name}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.create("resolveRuntimeDependencies", DefaultTask::class.java) {
|
tasks.create("resolveRuntimeDependencies", DefaultTask::class.java) {
|
||||||
|
|||||||
+8
-22
@@ -64,11 +64,14 @@ kotlin {
|
|||||||
fromPreset(presets.macosX64, 'macos64')
|
fromPreset(presets.macosX64, 'macos64')
|
||||||
|
|
||||||
configure([wasm32, linux64, mingw64, macos64]) {
|
configure([wasm32, linux64, mingw64, macos64]) {
|
||||||
compilations.main.outputKinds += org.jetbrains.kotlin.gradle.plugin.mpp.NativeOutputKind.EXECUTABLE
|
binaries.executable("main") {
|
||||||
compilations.main.entryPoint = "com.example.app.native.main"
|
entryPoint = "com.example.app.native.main"
|
||||||
// Check that linker options are correctly passed to the compiler.
|
}
|
||||||
compilations.main.linkerOpts = ['-L.']
|
|
||||||
compilations.test.linkerOpts = ['-L.']
|
binaries.all {
|
||||||
|
// Check that linker options are correctly passed to the compiler.
|
||||||
|
linkerOpts = ['-L.']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,20 +83,3 @@ task resolveRuntimeDependencies(type: DefaultTask) {
|
|||||||
configurations[configName].resolve()
|
configurations[configName].resolve()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task checkBinaryGetters {
|
|
||||||
doLast {
|
|
||||||
println("Wasm binary file: ${kotlin.targets.wasm32.compilations.main.getBinary("EXECUTABLE", "RELEASE").name}")
|
|
||||||
println("Wasm link task: ${kotlin.targets.wasm32.compilations.main.getLinkTask("EXECUTABLE", "RELEASE").name}")
|
|
||||||
println("Wasm link task name: ${kotlin.targets.wasm32.compilations.main.linkTaskName("EXECUTABLE", "RELEASE")}")
|
|
||||||
|
|
||||||
println("Windows test file: ${kotlin.targets.mingw64.compilations.test.getBinary("EXECUTABLE", "DEBUG").name}")
|
|
||||||
println("Windows test link task: ${kotlin.targets.mingw64.compilations.test.getLinkTask("EXECUTABLE", "DEBUG").name}")
|
|
||||||
|
|
||||||
println("MacOS test file: ${kotlin.targets.macos64.compilations.test.getBinary("EXECUTABLE", "DEBUG").name}")
|
|
||||||
println("MacOS test link task: ${kotlin.targets.macos64.compilations.test.getLinkTask("EXECUTABLE", "DEBUG").name}")
|
|
||||||
|
|
||||||
println("Linux test file: ${kotlin.targets.linux64.compilations.test.getBinary("EXECUTABLE", "DEBUG").name}")
|
|
||||||
println("Linux test link task: ${kotlin.targets.linux64.compilations.test.getLinkTask("EXECUTABLE", "DEBUG").name}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-4
@@ -45,9 +45,5 @@ kotlin {
|
|||||||
fromPreset(presets.mingwX64, 'mingw64')
|
fromPreset(presets.mingwX64, 'mingw64')
|
||||||
// Test building a 32-bit Windows binary.
|
// Test building a 32-bit Windows binary.
|
||||||
fromPreset(presets.mingwX86, 'mingw86')
|
fromPreset(presets.mingwX86, 'mingw86')
|
||||||
|
|
||||||
configure([macos64, linux64, mingw64, mingw86]) {
|
|
||||||
compilations.main.outputKinds ['EXECUTABLE']
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -22,14 +22,17 @@ repositories {
|
|||||||
kotlin {
|
kotlin {
|
||||||
targets {
|
targets {
|
||||||
fromPreset(presets.macosX64, 'macos64') {
|
fromPreset(presets.macosX64, 'macos64') {
|
||||||
compilations.main.outputKinds = [FRAMEWORK]
|
binaries.framework("main")
|
||||||
}
|
}
|
||||||
|
|
||||||
fromPreset(presets.linuxX64, 'linux64')
|
fromPreset(presets.linuxX64, 'linux64')
|
||||||
fromPreset(presets.mingwX64, 'mingw64')
|
fromPreset(presets.mingwX64, 'mingw64')
|
||||||
|
|
||||||
configure([linux64, mingw64, macos64]) {
|
configure([linux64, mingw64, macos64]) {
|
||||||
compilations.main.outputKinds += [DYNAMIC, STATIC]
|
binaries {
|
||||||
|
sharedLib("main")
|
||||||
|
staticLib("main")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-188
@@ -3,7 +3,7 @@
|
|||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:Suppress("PackageDirectoryMismatch", "DEPRECATION") // Old package for compatibility
|
@file:Suppress("PackageDirectoryMismatch") // Old package for compatibility
|
||||||
package org.jetbrains.kotlin.gradle.plugin.mpp
|
package org.jetbrains.kotlin.gradle.plugin.mpp
|
||||||
|
|
||||||
import groovy.lang.Closure
|
import groovy.lang.Closure
|
||||||
@@ -11,48 +11,13 @@ import org.gradle.api.Action
|
|||||||
import org.gradle.api.NamedDomainObjectContainer
|
import org.gradle.api.NamedDomainObjectContainer
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.file.SourceDirectorySet
|
import org.gradle.api.file.SourceDirectorySet
|
||||||
import org.gradle.api.invocation.Gradle
|
|
||||||
import org.gradle.util.ConfigureUtil
|
import org.gradle.util.ConfigureUtil
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinNativeBinaryContainer
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationWithResources
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationWithResources
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink
|
|
||||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||||
import java.io.File
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
private const val OLD_BINARY_API_DEPRECATION =
|
|
||||||
"Use the `binaries` block instead. See: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#building-final-native-binaries"
|
|
||||||
|
|
||||||
private val usedDeprecatedAPIs = WeakHashMap<Project, MutableSet<String>>()
|
|
||||||
|
|
||||||
private fun showDeprecationWarning(gradle: Gradle) {
|
|
||||||
val rootProject = gradle.rootProject
|
|
||||||
val deprecatedAPIs = usedDeprecatedAPIs[rootProject]?.sorted()?.joinToString(separator = "\n") { "| $it" }.orEmpty()
|
|
||||||
if (deprecatedAPIs.isNotEmpty()) {
|
|
||||||
rootProject.logger.warn(
|
|
||||||
"""
|
|
||||||
|
|
|
||||||
|Some native binaries in this build are configured using deprecated DSL elements. Use the `binaries` DSL block instead.
|
|
||||||
|The following deprecated DSL elements are used in this build:
|
|
||||||
$deprecatedAPIs
|
|
||||||
|
|
|
||||||
|See details about the `binaries` block at https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#building-final-native-binaries
|
|
||||||
""".trimMargin()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun KotlinNativeCompilation.registerDeprecatedApi(api: String) = with(target.project.rootProject) {
|
|
||||||
val deprecatedAPIs = usedDeprecatedAPIs.computeIfAbsent(this) {
|
|
||||||
gradle.projectsEvaluated(::showDeprecationWarning)
|
|
||||||
mutableSetOf()
|
|
||||||
}
|
|
||||||
deprecatedAPIs.add(api)
|
|
||||||
}
|
|
||||||
|
|
||||||
class KotlinNativeCompilation(
|
class KotlinNativeCompilation(
|
||||||
override val target: KotlinNativeTarget,
|
override val target: KotlinNativeTarget,
|
||||||
@@ -86,9 +51,6 @@ class KotlinNativeCompilation(
|
|||||||
target.compilations.getByName(it)
|
target.compilations.getByName(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used only to support the old APIs. TODO@binaries: Remove when the old APIs are removed.
|
|
||||||
internal val binaries = mutableMapOf<Pair<NativeOutputKind, NativeBuildType>, NativeBinary>()
|
|
||||||
|
|
||||||
// Native-specific DSL.
|
// Native-specific DSL.
|
||||||
var extraOpts = mutableListOf<String>()
|
var extraOpts = mutableListOf<String>()
|
||||||
|
|
||||||
@@ -97,167 +59,18 @@ class KotlinNativeCompilation(
|
|||||||
extraOpts.addAll(values.map { it.toString() })
|
extraOpts.addAll(values.map { it.toString() })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to access build types from internals of the plugin without printing
|
|
||||||
// the deprecation warning during user's project configuration.
|
|
||||||
// TODO@binaries: Drop when the old API are removed.
|
|
||||||
internal var buildTypesNoWarn = mutableListOf<NativeBuildType>()
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
var buildTypes: MutableList<NativeBuildType>
|
|
||||||
get() = buildTypesNoWarn.also { registerDeprecatedApi("KotlinNativeCompilation.buildTypes") }
|
|
||||||
set(value) {
|
|
||||||
registerDeprecatedApi("KotlinNativeCompilation.buildTypes")
|
|
||||||
buildTypesNoWarn = value
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used to access output kinds from internals of the plugin without printing
|
|
||||||
// the deprecation warning during user's project configuration.
|
|
||||||
// TODO@binaries: Drop when the old API are removed.
|
|
||||||
internal var outputKindsNoWarn = mutableListOf<NativeOutputKind>()
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
var outputKinds: MutableList<NativeOutputKind>
|
|
||||||
get() = outputKindsNoWarn.also { registerDeprecatedApi("KotlinNativeCompilation.outputKinds") }
|
|
||||||
set(value) {
|
|
||||||
registerDeprecatedApi("KotlinNativeCompilation.outputKinds")
|
|
||||||
outputKindsNoWarn = value
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun outputKind(kind: NativeOutputKind) = outputKinds.add(kind).also {
|
|
||||||
registerDeprecatedApi("KotlinNativeCompilation.outputKind(...)")
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun outputKinds(vararg kinds: NativeOutputKind) {
|
|
||||||
registerDeprecatedApi("KotlinNativeCompilation.outputKinds(...)")
|
|
||||||
outputKinds = kinds.toMutableList()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun outputKinds(vararg kinds: String) {
|
|
||||||
registerDeprecatedApi("KotlinNativeCompilation.outputKinds(...)")
|
|
||||||
outputKinds = kinds.map { NativeOutputKind.valueOf(it.toUpperCase()) }.toMutableList()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun outputKinds(kinds: List<Any>) {
|
|
||||||
registerDeprecatedApi("KotlinNativeCompilation.outputKinds(...)")
|
|
||||||
outputKinds = kinds.map {
|
|
||||||
when (it) {
|
|
||||||
is NativeOutputKind -> it
|
|
||||||
is String -> NativeOutputKind.valueOf(it.toUpperCase())
|
|
||||||
else -> error("Cannot use $it as an output kind")
|
|
||||||
}
|
|
||||||
}.toMutableList()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used to access entry point from internals of the plugin without printing
|
|
||||||
// the deprecation warning during user's project configuration.
|
|
||||||
// TODO@binaries: Drop when the old API are removed.
|
|
||||||
internal var entryPointNoWarn: String? = null
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
var entryPoint: String?
|
|
||||||
get() = entryPointNoWarn.also { registerDeprecatedApi("KotlinNativeCompilation.entryPoint") }
|
|
||||||
set(value) {
|
|
||||||
registerDeprecatedApi("KotlinNativeCompilation.entryPoint")
|
|
||||||
entryPointNoWarn = value
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun entryPoint(value: String) {
|
|
||||||
registerDeprecatedApi("KotlinNativeCompilation.entryPoint(...)")
|
|
||||||
entryPoint = value
|
|
||||||
}
|
|
||||||
|
|
||||||
// Interop DSL.
|
// Interop DSL.
|
||||||
val cinterops = project.container(DefaultCInteropSettings::class.java) { cinteropName ->
|
val cinterops = project.container(DefaultCInteropSettings::class.java) { cinteropName ->
|
||||||
DefaultCInteropSettings(project, cinteropName, this)
|
DefaultCInteropSettings(project, cinteropName, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to access linker options from internals of the plugin without printing
|
|
||||||
// the deprecation warning during user's project configuration.
|
|
||||||
// TODO@binaries: Drop when the old API are removed.
|
|
||||||
internal var linkerOptsNoWarn = mutableListOf<String>()
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
var linkerOpts: MutableList<String>
|
|
||||||
get() = linkerOptsNoWarn.also { registerDeprecatedApi("KotlinNativeCompilation.linkerOpts") }
|
|
||||||
set(value) {
|
|
||||||
registerDeprecatedApi("KotlinNativeCompilation.linkerOpts")
|
|
||||||
linkerOptsNoWarn = value
|
|
||||||
}
|
|
||||||
|
|
||||||
fun cinterops(action: Closure<Unit>) = cinterops(ConfigureUtil.configureUsing(action))
|
fun cinterops(action: Closure<Unit>) = cinterops(ConfigureUtil.configureUsing(action))
|
||||||
fun cinterops(action: Action<NamedDomainObjectContainer<DefaultCInteropSettings>>) = action.execute(cinterops)
|
fun cinterops(action: Action<NamedDomainObjectContainer<DefaultCInteropSettings>>) = action.execute(cinterops)
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun linkerOpts(vararg values: String) = linkerOpts(values.toList()).also {
|
|
||||||
registerDeprecatedApi("KotlinNativeCompilation.linkerOpts(...)")
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun linkerOpts(values: List<String>) {
|
|
||||||
registerDeprecatedApi("KotlinNativeCompilation.linkerOpts(...)")
|
|
||||||
linkerOpts.addAll(values)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Task accessors.
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun findLinkTask(kind: NativeOutputKind, buildType: NativeBuildType): KotlinNativeLink? =
|
|
||||||
binaries[kind to buildType]?.linkTask.also { registerDeprecatedApi("KotlinNativeCompilation.findLinkTask(...)") }
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun getLinkTask(kind: NativeOutputKind, buildType: NativeBuildType): KotlinNativeLink =
|
|
||||||
findLinkTask(kind, buildType).also { registerDeprecatedApi("KotlinNativeCompilation.getLinkTask(...)") }
|
|
||||||
?: throw IllegalArgumentException("Cannot find a link task for the binary kind '$kind' and the build type '$buildType'")
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun findLinkTask(kind: String, buildType: String) =
|
|
||||||
findLinkTask(NativeOutputKind.valueOf(kind.toUpperCase()), NativeBuildType.valueOf(buildType.toUpperCase()))
|
|
||||||
.also { registerDeprecatedApi("KotlinNativeCompilation.findLinkTask(...)") }
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun getLinkTask(kind: String, buildType: String) =
|
|
||||||
getLinkTask(NativeOutputKind.valueOf(kind.toUpperCase()), NativeBuildType.valueOf(buildType.toUpperCase()))
|
|
||||||
.also { registerDeprecatedApi("KotlinNativeCompilation.getLinkTask(...)") }
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun findBinary(kind: NativeOutputKind, buildType: NativeBuildType): File? =
|
|
||||||
findLinkTask(kind, buildType)?.outputFile?.get().also { registerDeprecatedApi("KotlinNativeCompilation.findBinary(...)") }
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun getBinary(kind: NativeOutputKind, buildType: NativeBuildType): File =
|
|
||||||
getLinkTask(kind, buildType).outputFile.get().also { registerDeprecatedApi("KotlinNativeCompilation.getBinary(...)") }
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun findBinary(kind: String, buildType: String) =
|
|
||||||
findBinary(NativeOutputKind.valueOf(kind.toUpperCase()), NativeBuildType.valueOf(buildType.toUpperCase()))
|
|
||||||
.also { registerDeprecatedApi("KotlinNativeCompilation.findBinary(...)") }
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun getBinary(kind: String, buildType: String) =
|
|
||||||
getBinary(NativeOutputKind.valueOf(kind.toUpperCase()), NativeBuildType.valueOf(buildType.toUpperCase()))
|
|
||||||
.also { registerDeprecatedApi("KotlinNativeCompilation.getBinary(...)") }
|
|
||||||
|
|
||||||
// Naming
|
// Naming
|
||||||
override val processResourcesTaskName: String
|
override val processResourcesTaskName: String
|
||||||
get() = disambiguateName("processResources")
|
get() = disambiguateName("processResources")
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun linkTaskName(kind: NativeOutputKind, buildType: NativeBuildType): String =
|
|
||||||
lowerCamelCaseName(
|
|
||||||
"link",
|
|
||||||
KotlinNativeBinaryContainer.generateBinaryName(compilationName, buildType, kind.taskNameClassifier),
|
|
||||||
target.targetName
|
|
||||||
).also { registerDeprecatedApi("KotlinNativeCompilation.linkTaskName(...)") }
|
|
||||||
|
|
||||||
@Deprecated(OLD_BINARY_API_DEPRECATION)
|
|
||||||
fun linkTaskName(kind: String, buildType: String) =
|
|
||||||
linkTaskName(NativeOutputKind.valueOf(kind.toUpperCase()), NativeBuildType.valueOf(buildType.toUpperCase()))
|
|
||||||
.also { registerDeprecatedApi("KotlinNativeCompilation.linkTaskName(...)") }
|
|
||||||
|
|
||||||
override val compileDependencyConfigurationName: String
|
override val compileDependencyConfigurationName: String
|
||||||
get() = lowerCamelCaseName(
|
get() = lowerCamelCaseName(
|
||||||
target.disambiguationClassifier,
|
target.disambiguationClassifier,
|
||||||
|
|||||||
-2
@@ -23,7 +23,5 @@ class KotlinNativeCompilationFactory(
|
|||||||
friendCompilationName = KotlinCompilation.MAIN_COMPILATION_NAME
|
friendCompilationName = KotlinCompilation.MAIN_COMPILATION_NAME
|
||||||
isTestCompilation = true
|
isTestCompilation = true
|
||||||
}
|
}
|
||||||
buildTypesNoWarn = mutableListOf(NativeBuildType.DEBUG, NativeBuildType.RELEASE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-37
@@ -251,9 +251,7 @@ open class KotlinNativeTargetConfigurator(
|
|||||||
|
|
||||||
override fun configureTest(target: KotlinNativeTarget) {
|
override fun configureTest(target: KotlinNativeTarget) {
|
||||||
target.binaries.defaultTestExecutable {
|
target.binaries.defaultTestExecutable {
|
||||||
compilation = target.compilations.maybeCreate(KotlinCompilation.TEST_COMPILATION_NAME)
|
compilation = target.compilations.maybeCreate(TEST_COMPILATION_NAME)
|
||||||
// Allow accessing the test binary using the old getters (e.g. compilations.test.getBinary('EXECUTABLE', 'DEBUG'))
|
|
||||||
compilation.binaries[NativeOutputKind.EXECUTABLE to KotlinNativeBinaryContainer.DEFAULT_TEST_BUILD_TYPE] = this
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,40 +301,6 @@ open class KotlinNativeTargetConfigurator(
|
|||||||
project.tasks.getByName(it.compilation.binariesTaskName).dependsOn(it.linkTaskName)
|
project.tasks.getByName(it.compilation.binariesTaskName).dependsOn(it.linkTaskName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create binaries for output kinds declared using the old DSL.
|
|
||||||
project.whenEvaluated {
|
|
||||||
target.compilations.all { compilation ->
|
|
||||||
val binaries = target.binaries
|
|
||||||
val konanTarget = compilation.target.konanTarget
|
|
||||||
val name = compilation.name
|
|
||||||
val buildTypes = compilation.buildTypesNoWarn
|
|
||||||
val availableOutputKinds = compilation.outputKindsNoWarn.filter { it.availableFor(konanTarget) }
|
|
||||||
|
|
||||||
val configure: NativeBinary.() -> Unit = {
|
|
||||||
this.compilation = compilation
|
|
||||||
linkerOpts.addAll(compilation.linkerOptsNoWarn)
|
|
||||||
if (this is Executable) {
|
|
||||||
entryPoint = compilation.entryPointNoWarn
|
|
||||||
}
|
|
||||||
compilation.binaries[outputKind to buildType] = this
|
|
||||||
}
|
|
||||||
|
|
||||||
for (kind in availableOutputKinds) {
|
|
||||||
when (kind) {
|
|
||||||
NativeOutputKind.EXECUTABLE -> binaries.executable(name, buildTypes, configure)
|
|
||||||
NativeOutputKind.DYNAMIC -> binaries.sharedLib(name, buildTypes, configure)
|
|
||||||
NativeOutputKind.STATIC -> binaries.staticLib(name, buildTypes, configure)
|
|
||||||
NativeOutputKind.FRAMEWORK -> binaries.framework(name, buildTypes, configure)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Allow setting linker options for the default test executable using the
|
|
||||||
// corresponding properties of the test compilation.
|
|
||||||
target.binaries.getDefaultTestExecutable().apply {
|
|
||||||
linkerOpts.addAll(target.compilations.getByName(TEST_COMPILATION_NAME).linkerOptsNoWarn)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun configureFrameworkExport(target: KotlinNativeTarget) {
|
fun configureFrameworkExport(target: KotlinNativeTarget) {
|
||||||
|
|||||||
Reference in New Issue
Block a user