[gradle-plugin] Support frameworks and extra options in the new plugin (#1800)
This commit is contained in:
+3
-3
@@ -48,9 +48,9 @@ interface KotlinNativeBinary: ComponentWithDependencies, BuildableComponent {
|
|||||||
val kind: CompilerOutputKind
|
val kind: CompilerOutputKind
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additinal command line options passed to the compiler when this binary is compiled.
|
* Additional command line options passed to the compiler when this binary is compiled.
|
||||||
*/
|
*/
|
||||||
val additionalCompilerOptions: MutableCollection<String>
|
val additionalCompilerOptions: Collection<String>
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val KONAN_TARGET_ATTRIBUTE = Attribute.of("org.gradle.native.kotlin.platform", String::class.java)
|
val KONAN_TARGET_ATTRIBUTE = Attribute.of("org.gradle.native.kotlin.platform", String::class.java)
|
||||||
@@ -70,7 +70,7 @@ interface KotlinNativeExecutable : KotlinNativeBinary,
|
|||||||
* A component representing a klibrary.
|
* A component representing a klibrary.
|
||||||
*/
|
*/
|
||||||
// TODO: Consider implementing ComponentWithLinkFile.
|
// TODO: Consider implementing ComponentWithLinkFile.
|
||||||
interface KotlinNativeKLibrary : KotlinNativeBinary,
|
interface KotlinNativeLibrary : KotlinNativeBinary,
|
||||||
ComponentWithOutputs,
|
ComponentWithOutputs,
|
||||||
PublishableComponent,
|
PublishableComponent,
|
||||||
ConfigurableComponentWithLinkUsage
|
ConfigurableComponentWithLinkUsage
|
||||||
|
|||||||
+6
@@ -37,6 +37,12 @@ interface KotlinNativeComponent: ComponentWithBinaries, ComponentWithDependencie
|
|||||||
/** Set native targets for this component. */
|
/** Set native targets for this component. */
|
||||||
fun target(vararg targets: String)
|
fun target(vararg targets: String)
|
||||||
|
|
||||||
|
/** Set additional compiler options for this component. */
|
||||||
|
val extraOpts: Collection<String>
|
||||||
|
|
||||||
|
fun extraOpts(vararg values: Any)
|
||||||
|
fun extraOpts(values: List<Any>)
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -21,6 +21,7 @@ import org.gradle.nativeplatform.OperatingSystemFamily
|
|||||||
import org.gradle.nativeplatform.toolchain.NativeToolChain
|
import org.gradle.nativeplatform.toolchain.NativeToolChain
|
||||||
import org.jetbrains.kotlin.gradle.plugin.experimental.ComponentWithBaseName
|
import org.jetbrains.kotlin.gradle.plugin.experimental.ComponentWithBaseName
|
||||||
import org.jetbrains.kotlin.gradle.plugin.experimental.KotlinNativeBinary
|
import org.jetbrains.kotlin.gradle.plugin.experimental.KotlinNativeBinary
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.experimental.KotlinNativeComponent
|
||||||
import org.jetbrains.kotlin.gradle.plugin.experimental.sourcesets.KotlinNativeSourceSet
|
import org.jetbrains.kotlin.gradle.plugin.experimental.sourcesets.KotlinNativeSourceSet
|
||||||
import org.jetbrains.kotlin.gradle.plugin.experimental.tasks.KotlinNativeCompile
|
import org.jetbrains.kotlin.gradle.plugin.experimental.tasks.KotlinNativeCompile
|
||||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||||
@@ -41,7 +42,7 @@ import org.jetbrains.kotlin.konan.target.KonanTarget
|
|||||||
abstract class AbstractKotlinNativeBinary(
|
abstract class AbstractKotlinNativeBinary(
|
||||||
private val name: String,
|
private val name: String,
|
||||||
private val baseName: Provider<String>,
|
private val baseName: Provider<String>,
|
||||||
val sourceSet: KotlinNativeSourceSet,
|
val component: KotlinNativeComponent,
|
||||||
val identity: KotlinNativeVariantIdentity,
|
val identity: KotlinNativeVariantIdentity,
|
||||||
val projectLayout: ProjectLayout,
|
val projectLayout: ProjectLayout,
|
||||||
override val kind: CompilerOutputKind,
|
override val kind: CompilerOutputKind,
|
||||||
@@ -66,6 +67,9 @@ abstract class AbstractKotlinNativeBinary(
|
|||||||
|
|
||||||
override fun getTargetPlatform(): KotlinNativePlatform = identity.targetPlatform
|
override fun getTargetPlatform(): KotlinNativePlatform = identity.targetPlatform
|
||||||
|
|
||||||
|
val sourceSet: KotlinNativeSourceSet
|
||||||
|
get() = component.sources
|
||||||
|
|
||||||
open val debuggable: Boolean get() = identity.isDebuggable
|
open val debuggable: Boolean get() = identity.isDebuggable
|
||||||
open val optimized: Boolean get() = identity.isOptimized
|
open val optimized: Boolean get() = identity.isOptimized
|
||||||
|
|
||||||
@@ -113,5 +117,6 @@ abstract class AbstractKotlinNativeBinary(
|
|||||||
private val outputs: ConfigurableFileCollection = fileOperations.files()
|
private val outputs: ConfigurableFileCollection = fileOperations.files()
|
||||||
override fun getOutputs() = outputs
|
override fun getOutputs() = outputs
|
||||||
|
|
||||||
override val additionalCompilerOptions = mutableListOf<String>()
|
override val additionalCompilerOptions: Collection<String>
|
||||||
|
get() = component.extraOpts
|
||||||
}
|
}
|
||||||
+7
@@ -59,5 +59,12 @@ abstract class AbstractKotlinNativeComponent @Inject constructor(
|
|||||||
konanTargets.set(targets.map { hostManager.targetByName(it) })
|
konanTargets.set(targets.map { hostManager.targetByName(it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val extraOpts = mutableListOf<String>()
|
||||||
|
|
||||||
|
override fun extraOpts(vararg values: Any) = extraOpts(values.toList())
|
||||||
|
override fun extraOpts(values: List<Any>) {
|
||||||
|
extraOpts.addAll(values.map { it.toString() })
|
||||||
|
}
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
}
|
}
|
||||||
+2
-2
@@ -24,7 +24,7 @@ open class KotlinNativeExecutableImpl @Inject constructor(
|
|||||||
name: String,
|
name: String,
|
||||||
baseName: Provider<String>,
|
baseName: Provider<String>,
|
||||||
componentImplementation: Configuration,
|
componentImplementation: Configuration,
|
||||||
sources: KotlinNativeSourceSet,
|
component: KotlinNativeMainComponent,
|
||||||
identity: KotlinNativeVariantIdentity,
|
identity: KotlinNativeVariantIdentity,
|
||||||
objects: ObjectFactory,
|
objects: ObjectFactory,
|
||||||
projectLayout: ProjectLayout,
|
projectLayout: ProjectLayout,
|
||||||
@@ -32,7 +32,7 @@ open class KotlinNativeExecutableImpl @Inject constructor(
|
|||||||
fileOperations: FileOperations
|
fileOperations: FileOperations
|
||||||
) : AbstractKotlinNativeBinary(name,
|
) : AbstractKotlinNativeBinary(name,
|
||||||
baseName,
|
baseName,
|
||||||
sources,
|
component,
|
||||||
identity,
|
identity,
|
||||||
projectLayout,
|
projectLayout,
|
||||||
CompilerOutputKind.PROGRAM,
|
CompilerOutputKind.PROGRAM,
|
||||||
|
|||||||
+54
-7
@@ -15,32 +15,33 @@ import org.gradle.api.provider.Property
|
|||||||
import org.gradle.api.provider.Provider
|
import org.gradle.api.provider.Provider
|
||||||
import org.gradle.language.cpp.internal.DefaultUsageContext
|
import org.gradle.language.cpp.internal.DefaultUsageContext
|
||||||
import org.gradle.nativeplatform.Linkage
|
import org.gradle.nativeplatform.Linkage
|
||||||
import org.jetbrains.kotlin.gradle.plugin.experimental.KotlinNativeKLibrary
|
import org.jetbrains.kotlin.gradle.plugin.experimental.KotlinNativeLibrary
|
||||||
import org.jetbrains.kotlin.gradle.plugin.experimental.sourcesets.KotlinNativeSourceSet
|
import org.jetbrains.kotlin.gradle.plugin.experimental.sourcesets.KotlinNativeSourceSet
|
||||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
open class KotlinNativeKLibraryImpl @Inject constructor(
|
abstract class AbstractKotlinNativeLibrary(
|
||||||
name: String,
|
name: String,
|
||||||
baseName: Provider<String>,
|
baseName: Provider<String>,
|
||||||
componentImplementation: Configuration,
|
componentImplementation: Configuration,
|
||||||
sources: KotlinNativeSourceSet,
|
component: KotlinNativeMainComponent,
|
||||||
identity: KotlinNativeVariantIdentity,
|
identity: KotlinNativeVariantIdentity,
|
||||||
objects: ObjectFactory,
|
|
||||||
projectLayout: ProjectLayout,
|
projectLayout: ProjectLayout,
|
||||||
|
outputKind: CompilerOutputKind,
|
||||||
|
objects: ObjectFactory,
|
||||||
configurations: ConfigurationContainer,
|
configurations: ConfigurationContainer,
|
||||||
fileOperations: FileOperations
|
fileOperations: FileOperations
|
||||||
) : AbstractKotlinNativeBinary(name,
|
) : AbstractKotlinNativeBinary(name,
|
||||||
baseName,
|
baseName,
|
||||||
sources,
|
component,
|
||||||
identity,
|
identity,
|
||||||
projectLayout,
|
projectLayout,
|
||||||
CompilerOutputKind.LIBRARY,
|
outputKind,
|
||||||
objects,
|
objects,
|
||||||
componentImplementation,
|
componentImplementation,
|
||||||
configurations,
|
configurations,
|
||||||
fileOperations),
|
fileOperations),
|
||||||
KotlinNativeKLibrary,
|
KotlinNativeLibrary,
|
||||||
SoftwareComponentInternal, // TODO: SoftwareComponentInternal will be replaced with ComponentWithVariants by Gradle
|
SoftwareComponentInternal, // TODO: SoftwareComponentInternal will be replaced with ComponentWithVariants by Gradle
|
||||||
PublishableComponent
|
PublishableComponent
|
||||||
{
|
{
|
||||||
@@ -68,3 +69,49 @@ open class KotlinNativeKLibraryImpl @Inject constructor(
|
|||||||
|
|
||||||
override val outputRootName = "lib"
|
override val outputRootName = "lib"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open class KotlinNativeLibraryImpl @Inject constructor(
|
||||||
|
name: String,
|
||||||
|
baseName: Provider<String>,
|
||||||
|
componentImplementation: Configuration,
|
||||||
|
component: KotlinNativeMainComponent,
|
||||||
|
identity: KotlinNativeVariantIdentity,
|
||||||
|
projectLayout: ProjectLayout,
|
||||||
|
objects: ObjectFactory,
|
||||||
|
configurations: ConfigurationContainer,
|
||||||
|
fileOperations: FileOperations
|
||||||
|
) : AbstractKotlinNativeLibrary(
|
||||||
|
name,
|
||||||
|
baseName,
|
||||||
|
componentImplementation,
|
||||||
|
component,
|
||||||
|
identity,
|
||||||
|
projectLayout,
|
||||||
|
CompilerOutputKind.LIBRARY,
|
||||||
|
objects,
|
||||||
|
configurations,
|
||||||
|
fileOperations
|
||||||
|
)
|
||||||
|
|
||||||
|
open class KotlinNativeFrameworkImpl @Inject constructor(
|
||||||
|
name: String,
|
||||||
|
baseName: Provider<String>,
|
||||||
|
componentImplementation: Configuration,
|
||||||
|
component: KotlinNativeMainComponent,
|
||||||
|
identity: KotlinNativeVariantIdentity,
|
||||||
|
projectLayout: ProjectLayout,
|
||||||
|
objects: ObjectFactory,
|
||||||
|
configurations: ConfigurationContainer,
|
||||||
|
fileOperations: FileOperations
|
||||||
|
) : AbstractKotlinNativeLibrary(
|
||||||
|
name,
|
||||||
|
baseName,
|
||||||
|
componentImplementation,
|
||||||
|
component,
|
||||||
|
identity,
|
||||||
|
projectLayout,
|
||||||
|
CompilerOutputKind.FRAMEWORK,
|
||||||
|
objects,
|
||||||
|
configurations,
|
||||||
|
fileOperations
|
||||||
|
)
|
||||||
+6
-3
@@ -47,7 +47,7 @@ open class KotlinNativeMainComponent @Inject constructor(
|
|||||||
"$name${identity.name.capitalize()}",
|
"$name${identity.name.capitalize()}",
|
||||||
baseName,
|
baseName,
|
||||||
getImplementationDependencies(),
|
getImplementationDependencies(),
|
||||||
sources,
|
this,
|
||||||
identity
|
identity
|
||||||
).apply {
|
).apply {
|
||||||
binaries.add(this)
|
binaries.add(this)
|
||||||
@@ -57,11 +57,11 @@ open class KotlinNativeMainComponent @Inject constructor(
|
|||||||
addBinary(T::class.java, identity)
|
addBinary(T::class.java, identity)
|
||||||
|
|
||||||
fun addExecutable(identity: NativeVariantIdentity) = addBinary<KotlinNativeExecutableImpl>(identity)
|
fun addExecutable(identity: NativeVariantIdentity) = addBinary<KotlinNativeExecutableImpl>(identity)
|
||||||
fun addKLibrary(identity: NativeVariantIdentity) = addBinary<KotlinNativeKLibraryImpl>(identity)
|
fun addKLibrary(identity: NativeVariantIdentity) = addBinary<KotlinNativeLibraryImpl>(identity)
|
||||||
|
fun addFramework(identity: NativeVariantIdentity) = addBinary<KotlinNativeFrameworkImpl>(identity)
|
||||||
|
|
||||||
fun addBinary(kind: OutputKind, identity: NativeVariantIdentity) = addBinary(kind.binaryClass, identity)
|
fun addBinary(kind: OutputKind, identity: NativeVariantIdentity) = addBinary(kind.binaryClass, identity)
|
||||||
|
|
||||||
|
|
||||||
// region Kotlin/Native variant
|
// region Kotlin/Native variant
|
||||||
// TODO: SoftwareComponentInternal will be replaced with ComponentWithVariants by Gradle
|
// TODO: SoftwareComponentInternal will be replaced with ComponentWithVariants by Gradle
|
||||||
inner class KotlinNativeVariant: ComponentWithVariants, SoftwareComponentInternal {
|
inner class KotlinNativeVariant: ComponentWithVariants, SoftwareComponentInternal {
|
||||||
@@ -82,5 +82,8 @@ open class KotlinNativeMainComponent @Inject constructor(
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
val KLIBRARY = OutputKind.KLIBRARY
|
val KLIBRARY = OutputKind.KLIBRARY
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
val FRAMEWORK = OutputKind.FRAMEWORK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -9,6 +9,7 @@ import org.gradle.api.internal.file.FileOperations
|
|||||||
import org.gradle.api.model.ObjectFactory
|
import org.gradle.api.model.ObjectFactory
|
||||||
import org.gradle.api.provider.Property
|
import org.gradle.api.provider.Property
|
||||||
import org.gradle.api.provider.Provider
|
import org.gradle.api.provider.Provider
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.experimental.KotlinNativeTestComponent
|
||||||
import org.jetbrains.kotlin.gradle.plugin.experimental.KotlinNativeTestExecutable
|
import org.jetbrains.kotlin.gradle.plugin.experimental.KotlinNativeTestExecutable
|
||||||
import org.jetbrains.kotlin.gradle.plugin.experimental.sourcesets.KotlinNativeSourceSet
|
import org.jetbrains.kotlin.gradle.plugin.experimental.sourcesets.KotlinNativeSourceSet
|
||||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||||
@@ -19,7 +20,7 @@ open class KotlinNativeTestExecutableImpl @Inject constructor(
|
|||||||
name: String,
|
name: String,
|
||||||
baseName: Provider<String>,
|
baseName: Provider<String>,
|
||||||
componentImplementation: Configuration,
|
componentImplementation: Configuration,
|
||||||
testSources: KotlinNativeSourceSet,
|
testComponent: KotlinNativeTestComponent,
|
||||||
val mainSources: KotlinNativeSourceSet,
|
val mainSources: KotlinNativeSourceSet,
|
||||||
identity: KotlinNativeVariantIdentity,
|
identity: KotlinNativeVariantIdentity,
|
||||||
objects: ObjectFactory,
|
objects: ObjectFactory,
|
||||||
@@ -28,7 +29,7 @@ open class KotlinNativeTestExecutableImpl @Inject constructor(
|
|||||||
fileOperations: FileOperations
|
fileOperations: FileOperations
|
||||||
) : AbstractKotlinNativeBinary(name,
|
) : AbstractKotlinNativeBinary(name,
|
||||||
baseName,
|
baseName,
|
||||||
testSources,
|
testComponent,
|
||||||
identity,
|
identity,
|
||||||
projectLayout,
|
projectLayout,
|
||||||
CompilerOutputKind.PROGRAM,
|
CompilerOutputKind.PROGRAM,
|
||||||
@@ -38,15 +39,14 @@ open class KotlinNativeTestExecutableImpl @Inject constructor(
|
|||||||
fileOperations),
|
fileOperations),
|
||||||
KotlinNativeTestExecutable {
|
KotlinNativeTestExecutable {
|
||||||
|
|
||||||
init {
|
|
||||||
additionalCompilerOptions.add("-tr")
|
|
||||||
}
|
|
||||||
|
|
||||||
private val runTaskProperty : Property<Task> = objects.property(Task::class.java)
|
private val runTaskProperty : Property<Task> = objects.property(Task::class.java)
|
||||||
override fun getRunTask() = runTaskProperty
|
override fun getRunTask() = runTaskProperty
|
||||||
|
|
||||||
override val sources: FileCollection
|
override val sources: FileCollection
|
||||||
get() = super.sources + mainSources.getAllSources(konanTarget)
|
get() = super.sources + mainSources.getAllSources(konanTarget)
|
||||||
|
|
||||||
override val outputRootName: String = "exe"
|
override val outputRootName: String = "test-exe"
|
||||||
|
|
||||||
|
override val additionalCompilerOptions: Collection<String>
|
||||||
|
get() = listOf("-tr") + super.additionalCompilerOptions
|
||||||
}
|
}
|
||||||
+1
-1
@@ -38,7 +38,7 @@ open class KotlinNativeTestSuite @Inject constructor(
|
|||||||
"$name${identity.name.capitalize()}",
|
"$name${identity.name.capitalize()}",
|
||||||
getBaseName(),
|
getBaseName(),
|
||||||
getImplementationDependencies(),
|
getImplementationDependencies(),
|
||||||
sources,
|
this,
|
||||||
testedComponent.sources,
|
testedComponent.sources,
|
||||||
identity
|
identity
|
||||||
).apply {
|
).apply {
|
||||||
|
|||||||
+1
@@ -2,4 +2,5 @@ package org.jetbrains.kotlin.gradle.plugin.experimental.internal
|
|||||||
|
|
||||||
object KotlinNativeUsage {
|
object KotlinNativeUsage {
|
||||||
const val KLIB = "kotlin-native-klib"
|
const val KLIB = "kotlin-native-klib"
|
||||||
|
const val FRAMEWORK = "kotlin-native-framework"
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-13
@@ -3,28 +3,46 @@ package org.jetbrains.kotlin.gradle.plugin.experimental.internal
|
|||||||
import org.gradle.api.attributes.Usage
|
import org.gradle.api.attributes.Usage
|
||||||
import org.jetbrains.kotlin.gradle.plugin.experimental.KotlinNativeBinary
|
import org.jetbrains.kotlin.gradle.plugin.experimental.KotlinNativeBinary
|
||||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||||
|
import org.jetbrains.kotlin.konan.target.Family
|
||||||
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
|
|
||||||
enum class OutputKind(
|
enum class OutputKind(
|
||||||
val compilerOutputKind: CompilerOutputKind,
|
val compilerOutputKind: CompilerOutputKind,
|
||||||
val binaryClass: Class<out KotlinNativeBinary>,
|
val binaryClass: Class<out KotlinNativeBinary>,
|
||||||
private val developmentBinaryPriority: Int,
|
private val developmentBinaryPriority: Int,
|
||||||
val runtimeUsageName: String? = null,
|
val runtimeUsageName: String? = null,
|
||||||
val linkUsageName: String? = null
|
val linkUsageName: String? = null,
|
||||||
|
val publishable: Boolean = true
|
||||||
) {
|
) {
|
||||||
EXECUTABLE(CompilerOutputKind.PROGRAM,
|
EXECUTABLE(
|
||||||
KotlinNativeExecutableImpl::class.java,
|
CompilerOutputKind.PROGRAM,
|
||||||
1,
|
KotlinNativeExecutableImpl::class.java,
|
||||||
Usage.NATIVE_RUNTIME,
|
0,
|
||||||
null
|
Usage.NATIVE_RUNTIME,
|
||||||
|
null
|
||||||
),
|
),
|
||||||
KLIBRARY(CompilerOutputKind.LIBRARY,
|
KLIBRARY(
|
||||||
KotlinNativeKLibraryImpl::class.java,
|
CompilerOutputKind.LIBRARY,
|
||||||
0,
|
KotlinNativeLibraryImpl::class.java,
|
||||||
null,
|
1,
|
||||||
KotlinNativeUsage.KLIB
|
null,
|
||||||
);
|
KotlinNativeUsage.KLIB
|
||||||
|
),
|
||||||
|
FRAMEWORK(
|
||||||
|
CompilerOutputKind.FRAMEWORK,
|
||||||
|
KotlinNativeFrameworkImpl::class.java,
|
||||||
|
2,
|
||||||
|
null,
|
||||||
|
KotlinNativeUsage.FRAMEWORK,
|
||||||
|
false
|
||||||
|
) {
|
||||||
|
override fun availableFor(target: KonanTarget) =
|
||||||
|
target.family == Family.OSX || target.family == Family.IOS
|
||||||
|
};
|
||||||
|
|
||||||
|
open fun availableFor(target: KonanTarget) = true
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
internal fun Collection<OutputKind>.getDevelopmentKind() = maxBy { it.developmentBinaryPriority }
|
internal fun Collection<OutputKind>.getDevelopmentKind() = minBy { it.developmentBinaryPriority }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-5
@@ -14,10 +14,7 @@ import org.gradle.language.plugins.NativeBasePlugin
|
|||||||
import org.gradle.nativeplatform.test.tasks.RunTestExecutable
|
import org.gradle.nativeplatform.test.tasks.RunTestExecutable
|
||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KonanPlugin
|
import org.jetbrains.kotlin.gradle.plugin.KonanPlugin
|
||||||
import org.jetbrains.kotlin.gradle.plugin.experimental.internal.AbstractKotlinNativeBinary
|
import org.jetbrains.kotlin.gradle.plugin.experimental.internal.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.experimental.internal.KotlinNativeExecutableImpl
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.experimental.internal.KotlinNativeKLibraryImpl
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.experimental.internal.KotlinNativeTestExecutableImpl
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.experimental.tasks.KotlinNativeCompile
|
import org.jetbrains.kotlin.gradle.plugin.experimental.tasks.KotlinNativeCompile
|
||||||
import org.jetbrains.kotlin.gradle.plugin.hasProperty
|
import org.jetbrains.kotlin.gradle.plugin.hasProperty
|
||||||
import org.jetbrains.kotlin.gradle.plugin.konanCompilerDownloadDir
|
import org.jetbrains.kotlin.gradle.plugin.konanCompilerDownloadDir
|
||||||
@@ -94,7 +91,7 @@ class KotlinNativeBasePlugin: Plugin<ProjectInternal> {
|
|||||||
|
|
||||||
when(binary) {
|
when(binary) {
|
||||||
is KotlinNativeExecutableImpl -> binary.runtimeFile.set(compileTask.outputFile)
|
is KotlinNativeExecutableImpl -> binary.runtimeFile.set(compileTask.outputFile)
|
||||||
is KotlinNativeKLibraryImpl -> binary.linkFile.set(compileTask.outputFile)
|
is AbstractKotlinNativeLibrary -> binary.linkFile.set(compileTask.outputFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binary is KotlinNativeTestExecutableImpl) {
|
if (binary is KotlinNativeTestExecutableImpl) {
|
||||||
|
|||||||
+9
-7
@@ -83,7 +83,7 @@ class KotlinNativePlugin @Inject constructor(val attributesFactory: ImmutableAtt
|
|||||||
|
|
||||||
for (kind in outputKinds) {
|
for (kind in outputKinds) {
|
||||||
for (buildType in KotlinNativeBuildType.DEFAULT_BUILD_TYPES) {
|
for (buildType in KotlinNativeBuildType.DEFAULT_BUILD_TYPES) {
|
||||||
for (target in targets) {
|
for (target in targets.filter { kind.availableFor(it) }) {
|
||||||
|
|
||||||
val buildTypeSuffix = buildType.name
|
val buildTypeSuffix = buildType.name
|
||||||
val outputKindSuffix = createDimensionSuffix(kind.name, outputKinds)
|
val outputKindSuffix = createDimensionSuffix(kind.name, outputKinds)
|
||||||
@@ -112,12 +112,14 @@ class KotlinNativePlugin @Inject constructor(val attributesFactory: ImmutableAtt
|
|||||||
|
|
||||||
val binary = component.addBinary(kind, variantIdentity)
|
val binary = component.addBinary(kind, variantIdentity)
|
||||||
|
|
||||||
if (hostManager.isEnabled(target)) {
|
if (kind.publishable) {
|
||||||
component.mainPublication.variants.add(binary)
|
if (hostManager.isEnabled(target)) {
|
||||||
} else {
|
component.mainPublication.variants.add(binary)
|
||||||
// Known but not buildable.
|
} else {
|
||||||
// It allows us to publish different parts of a multitarget library from differnt hosts.
|
// Known but not buildable.
|
||||||
component.mainPublication.variants.add(variantIdentity)
|
// It allows us to publish different parts of a multitarget library from differnt hosts.
|
||||||
|
component.mainPublication.variants.add(variantIdentity)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kind == developmentKind &&
|
if (kind == developmentKind &&
|
||||||
|
|||||||
+3
-1
@@ -39,6 +39,8 @@ open class KotlinNativeCompile: DefaultTask() {
|
|||||||
|
|
||||||
val target: String @Input get() = binary.konanTarget.name
|
val target: String @Input get() = binary.konanTarget.name
|
||||||
|
|
||||||
|
val additionalCompilerOptions: Collection<String> @Input get() = binary.additionalCompilerOptions
|
||||||
|
|
||||||
@OutputFile
|
@OutputFile
|
||||||
val outputFile: RegularFileProperty = newOutputFile()
|
val outputFile: RegularFileProperty = newOutputFile()
|
||||||
|
|
||||||
@@ -60,7 +62,7 @@ open class KotlinNativeCompile: DefaultTask() {
|
|||||||
|
|
||||||
add("-Xmulti-platform")
|
add("-Xmulti-platform")
|
||||||
|
|
||||||
addAll(binary.additionalCompilerOptions)
|
addAll(additionalCompilerOptions)
|
||||||
|
|
||||||
libraries.files.forEach {library ->
|
libraries.files.forEach {library ->
|
||||||
library.parent?.let { addArg("-r", it) }
|
library.parent?.let { addArg("-r", it) }
|
||||||
|
|||||||
Reference in New Issue
Block a user