[Gradle, K/N] Move NativeBinaryTypes from kotlin-gradle-plugin to kotlin-gradle-plugin-api

This commit is contained in:
Alexander Likhachev
2021-02-02 13:29:21 +03:00
parent a6cdfeafed
commit cbeb031099
5 changed files with 22 additions and 18 deletions
@@ -11,7 +11,8 @@ publish()
standardPublicJars()
dependencies {
compile(kotlinStdlib())
implementation(kotlinStdlib())
implementation(project(":native:kotlin-native-utils"))
compileOnly(gradleApi())
compileOnly("com.android.tools.build:gradle:0.4.2")
@@ -0,0 +1,89 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* 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") // Old package for compatibility
package org.jetbrains.kotlin.gradle.plugin.mpp
import org.gradle.api.Named
import org.jetbrains.kotlin.konan.target.Architecture.ARM32
import org.jetbrains.kotlin.konan.target.Architecture.ARM64
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
import org.jetbrains.kotlin.konan.target.Family.*
import org.jetbrains.kotlin.konan.target.KonanTarget
enum class NativeBuildType(
val optimized: Boolean,
val debuggable: Boolean,
private val embedBitcodeForAppleDevices: BitcodeEmbeddingMode
) : Named {
RELEASE(true, false, BitcodeEmbeddingMode.BITCODE),
DEBUG(false, true, BitcodeEmbeddingMode.MARKER);
override fun getName(): String = name.toLowerCase()
fun embedBitcode(target: KonanTarget) = with(target) {
if (family in listOf(IOS, WATCHOS, TVOS) && architecture in listOf(ARM32, ARM64)) {
embedBitcodeForAppleDevices
} else {
BitcodeEmbeddingMode.DISABLE
}
}
companion object {
val DEFAULT_BUILD_TYPES = setOf(DEBUG, RELEASE)
}
}
enum class NativeOutputKind(
val compilerOutputKind: CompilerOutputKind,
val taskNameClassifier: String,
val description: String = taskNameClassifier
) {
EXECUTABLE(
CompilerOutputKind.PROGRAM,
"executable",
description = "an executable"
),
TEST(
CompilerOutputKind.PROGRAM,
"test",
description = "a test executable"
),
DYNAMIC(
CompilerOutputKind.DYNAMIC,
"shared",
description = "a dynamic library"
) {
override fun availableFor(target: KonanTarget) = target != KonanTarget.WASM32
},
STATIC(
CompilerOutputKind.STATIC,
"static",
description = "a static library"
) {
override fun availableFor(target: KonanTarget) = target != KonanTarget.WASM32
},
FRAMEWORK(
CompilerOutputKind.FRAMEWORK,
"framework",
description = "a framework"
) {
override fun availableFor(target: KonanTarget) =
target.family.isAppleFamily
};
open fun availableFor(target: KonanTarget) = true
}
enum class BitcodeEmbeddingMode {
/** Don't embed LLVM IR bitcode. */
DISABLE,
/** Embed LLVM IR bitcode as data. */
BITCODE,
/** Embed placeholder LLVM IR data as a marker. */
MARKER,
}