Generate KotlinNativeCompilerOptions Gradle DSL
^KT-53108 In Progress
This commit is contained in:
committed by
Space Team
parent
68841fa031
commit
96316a4016
+10
-1
@@ -59,7 +59,16 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
|
||||
@Argument(value="-memory-model", valueDescription = "<model>", description = "Memory model to use, 'strict' and 'experimental' are currently supported")
|
||||
var memoryModel: String? = null
|
||||
|
||||
@Argument(value="-module-name", deprecatedName = "-module_name", valueDescription = "<name>", description = "Specify a name for the compilation module")
|
||||
@GradleOption(
|
||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(
|
||||
value = "-module-name",
|
||||
deprecatedName = "-module_name",
|
||||
valueDescription = "<name>",
|
||||
description = "Specify a name for the compilation module"
|
||||
)
|
||||
var moduleName: String? = null
|
||||
|
||||
@Argument(
|
||||
|
||||
+56
-1
@@ -32,7 +32,7 @@ interface AdditionalGradleProperties {
|
||||
|
||||
private data class GeneratedOptions(
|
||||
val optionsName: FqName,
|
||||
val deprecatedOptionsName: FqName,
|
||||
val deprecatedOptionsName: FqName?,
|
||||
val properties: List<KProperty1<*, *>>
|
||||
)
|
||||
|
||||
@@ -92,6 +92,19 @@ fun generateKotlinGradleOptions(withPrinterToFile: (targetFile: File, Printer.()
|
||||
withPrinterToFile
|
||||
)
|
||||
|
||||
val nativeOptions = generateKotlinNativeOptions(
|
||||
apiSrcDir,
|
||||
commonCompilerOptions,
|
||||
withPrinterToFile
|
||||
)
|
||||
generateKotlinNativeOptionsImpl(
|
||||
srcDir,
|
||||
nativeOptions.optionsName,
|
||||
commonCompilerOptionsImplFqName,
|
||||
nativeOptions.properties,
|
||||
withPrinterToFile
|
||||
)
|
||||
|
||||
val jsDceOptions = generateJsDceOptions(
|
||||
apiSrcDir,
|
||||
commonToolOptions,
|
||||
@@ -340,6 +353,48 @@ private fun generateKotlinJsOptionsImpl(
|
||||
}
|
||||
}
|
||||
|
||||
private fun generateKotlinNativeOptions(
|
||||
apiSrcDir: File,
|
||||
commonCompilerOptions: GeneratedOptions,
|
||||
withPrinterToFile: (targetFile: File, Printer.() -> Unit) -> Unit
|
||||
): GeneratedOptions {
|
||||
val nativeInterfaceFqName = FqName("$OPTIONS_PACKAGE_PREFIX.KotlinNativeCompilerOptions")
|
||||
val nativeOptions = gradleOptions<K2NativeCompilerArguments>()
|
||||
withPrinterToFile(fileFromFqName(apiSrcDir, nativeInterfaceFqName)) {
|
||||
generateInterface(
|
||||
nativeInterfaceFqName,
|
||||
nativeOptions,
|
||||
parentType = commonCompilerOptions.optionsName,
|
||||
)
|
||||
}
|
||||
|
||||
println("\n### Attributes specific for Native\n")
|
||||
generateMarkdown(nativeOptions)
|
||||
|
||||
return GeneratedOptions(nativeInterfaceFqName, null, nativeOptions)
|
||||
}
|
||||
|
||||
private fun generateKotlinNativeOptionsImpl(
|
||||
srcDir: File,
|
||||
nativeInterfaceFqName: FqName,
|
||||
commonCompilerImpl: FqName,
|
||||
nativeOptions: List<KProperty1<*, *>>,
|
||||
withPrinterToFile: (targetFile: File, Printer.() -> Unit) -> Unit
|
||||
) {
|
||||
val k2NativeCompilerArgumentsFqName = FqName(K2NativeCompilerArguments::class.qualifiedName!!)
|
||||
val nativeImplFqName = FqName("${nativeInterfaceFqName.asString()}$IMPLEMENTATION_SUFFIX")
|
||||
withPrinterToFile(fileFromFqName(srcDir, nativeImplFqName)) {
|
||||
generateImpl(
|
||||
nativeImplFqName,
|
||||
commonCompilerImpl,
|
||||
nativeInterfaceFqName,
|
||||
k2NativeCompilerArgumentsFqName,
|
||||
nativeOptions
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun generateJsDceOptions(
|
||||
apiSrcDir: File,
|
||||
commonToolOptions: GeneratedOptions,
|
||||
|
||||
@@ -464,6 +464,10 @@ public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinNativeArti
|
||||
public abstract interface annotation class org/jetbrains/kotlin/gradle/dsl/KotlinNativeArtifactDSL$ExperimentalArtifactDsl : java/lang/annotation/Annotation {
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinNativeCompilerOptions : org/jetbrains/kotlin/gradle/dsl/KotlinCommonCompilerOptions {
|
||||
public abstract fun getModuleName ()Lorg/gradle/api/provider/Property;
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinNativeFatFramework : org/jetbrains/kotlin/gradle/dsl/KotlinNativeArtifact {
|
||||
public abstract fun getEmbedBitcode ()Lorg/jetbrains/kotlin/gradle/plugin/mpp/BitcodeEmbeddingMode;
|
||||
public abstract fun getTargets ()Ljava/util/Set;
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// DO NOT EDIT MANUALLY!
|
||||
// Generated by org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt
|
||||
// To regenerate run 'generateGradleOptions' task
|
||||
@file:Suppress("RemoveRedundantQualifierName", "Deprecation", "DuplicatedCode")
|
||||
|
||||
package org.jetbrains.kotlin.gradle.dsl
|
||||
|
||||
interface KotlinNativeCompilerOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions {
|
||||
|
||||
/**
|
||||
* Specify a name for the compilation module
|
||||
* Default value: null
|
||||
*/
|
||||
@get:org.gradle.api.tasks.Optional
|
||||
@get:org.gradle.api.tasks.Input
|
||||
val moduleName: org.gradle.api.provider.Property<kotlin.String>
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// DO NOT EDIT MANUALLY!
|
||||
// Generated by org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt
|
||||
// To regenerate run 'generateGradleOptions' task
|
||||
@file:Suppress("RemoveRedundantQualifierName", "Deprecation", "DuplicatedCode")
|
||||
|
||||
package org.jetbrains.kotlin.gradle.dsl
|
||||
|
||||
internal abstract class KotlinNativeCompilerOptionsDefault @javax.inject.Inject constructor(
|
||||
objectFactory: org.gradle.api.model.ObjectFactory
|
||||
) : org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptionsDefault(objectFactory), org.jetbrains.kotlin.gradle.dsl.KotlinNativeCompilerOptions {
|
||||
|
||||
override val moduleName: org.gradle.api.provider.Property<kotlin.String> =
|
||||
objectFactory.property(kotlin.String::class.java)
|
||||
|
||||
internal fun fillCompilerArguments(args: org.jetbrains.kotlin.cli.common.arguments.K2NativeCompilerArguments) {
|
||||
super.fillCompilerArguments(args)
|
||||
args.moduleName = moduleName.orNull
|
||||
}
|
||||
|
||||
internal fun fillDefaultValues(args: org.jetbrains.kotlin.cli.common.arguments.K2NativeCompilerArguments) {
|
||||
super.fillDefaultValues(args)
|
||||
args.moduleName = null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user