Mark compiler arguments that should generate deprecated kotlinOptions DSL
This will allow to keep backward compatiblity for deprecated kotlinOptions DSL for already existing compiler arguments, but add a new one only into compilerOptions DSL. ^KT-53108 In Progress
This commit is contained in:
committed by
Space Team
parent
671aa68ad6
commit
43eea47032
+6
-3
@@ -33,7 +33,8 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.LANGUAGE_VERSIONS,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(
|
||||
value = "-language-version",
|
||||
@@ -47,7 +48,8 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.API_VERSIONS,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(
|
||||
value = "-api-version",
|
||||
@@ -298,7 +300,8 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
|
||||
@GradleOption(
|
||||
DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(
|
||||
value = "-Xuse-k2",
|
||||
|
||||
+6
-3
@@ -40,21 +40,24 @@ abstract class CommonToolArguments : Freezable(), Serializable {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INTERNAL
|
||||
gradleInputType = GradleInputTypes.INTERNAL,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "-verbose", description = "Enable verbose logging output")
|
||||
var verbose: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INTERNAL
|
||||
gradleInputType = GradleInputTypes.INTERNAL,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "-nowarn", description = "Generate no warnings")
|
||||
var suppressWarnings: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "-Werror", description = "Report an error if there are any warnings")
|
||||
var allWarningsAsErrors: Boolean by FreezableVar(false)
|
||||
|
||||
+2
-1
@@ -26,7 +26,8 @@ import kotlin.reflect.KVisibility
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class GradleOption(
|
||||
val value: Int,
|
||||
val gradleInputType: String
|
||||
val gradleInputType: String,
|
||||
val shouldGenerateDeprecatedKotlinOptions: Boolean = false
|
||||
)
|
||||
|
||||
// Enum class here is not possible due to bug in K2 compiler:
|
||||
|
||||
+26
-13
@@ -19,7 +19,8 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INTERNAL // handled by task 'outputFileProperty'
|
||||
gradleInputType = GradleInputTypes.INTERNAL, // handled by task 'outputFileProperty'
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@GradleDeprecatedOption(
|
||||
message = "Only for legacy backend. For IR backend please use task.destinationDirectory and moduleName",
|
||||
@@ -34,14 +35,16 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "-ir-output-name", description = "Base name of generated files")
|
||||
var moduleName: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.BOOLEAN_TRUE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "-no-stdlib", description = "Don't automatically include the default Kotlin/JS stdlib into compilation dependencies")
|
||||
var noStdlib: Boolean by FreezableVar(false)
|
||||
@@ -62,14 +65,16 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "-source-map", description = "Generate source map")
|
||||
var sourceMap: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "-source-map-prefix", description = "Add the specified prefix to paths in the source map")
|
||||
var sourceMapPrefix: String? by NullableStringFreezableVar(null)
|
||||
@@ -88,7 +93,8 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
*/
|
||||
@GradleOption(
|
||||
value = DefaultValue.JS_SOURCE_MAP_CONTENT_MODES,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(
|
||||
value = "-source-map-embed-sources",
|
||||
@@ -99,7 +105,8 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.JS_SOURCE_MAP_NAMES_POLICY,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(
|
||||
value = "-source-map-names-policy",
|
||||
@@ -110,14 +117,16 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.BOOLEAN_TRUE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "-meta-info", description = "Generate .meta.js and .kjsm files with metadata. Use to create a library")
|
||||
var metaInfo: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.JS_ECMA_VERSIONS,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "-target", valueDescription = "{ v5 }", description = "Generate JS files for specific ECMA version")
|
||||
var target: String? by NullableStringFreezableVar(null)
|
||||
@@ -131,7 +140,8 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.JS_MODULE_KINDS,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(
|
||||
value = "-module-kind",
|
||||
@@ -142,7 +152,8 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.JS_MAIN,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(
|
||||
value = "-main",
|
||||
@@ -282,14 +293,16 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.BOOLEAN_TRUE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "-Xtyped-arrays", description = "Translate primitive arrays to JS typed arrays")
|
||||
var typedArrays: Boolean by FreezableVar(true)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "-Xfriend-modules-disabled", description = "Disable internal declaration export")
|
||||
var friendModulesDisabled: Boolean by FreezableVar(false)
|
||||
|
||||
+4
-2
@@ -15,7 +15,8 @@ class K2JSDceArguments : CommonToolArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INTERNAL // handled by 'destinationDirectory'
|
||||
gradleInputType = GradleInputTypes.INTERNAL, // handled by 'destinationDirectory'
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@GradleDeprecatedOption(
|
||||
message = "Use task 'destinationDirectory' to configure output directory",
|
||||
@@ -44,7 +45,8 @@ class K2JSDceArguments : CommonToolArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(
|
||||
value = "-dev-mode",
|
||||
|
||||
+8
-4
@@ -38,7 +38,8 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "-no-jdk", description = "Don't automatically include the Java runtime into the classpath")
|
||||
var noJdk: Boolean by FreezableVar(false)
|
||||
@@ -68,14 +69,16 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "-module-name", valueDescription = "<name>", description = "Name of the generated .kotlin_module file")
|
||||
var moduleName: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.JVM_TARGET_VERSIONS,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(
|
||||
value = "-jvm-target",
|
||||
@@ -86,7 +89,8 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "-java-parameters", description = "Generate metadata for Java 1.8 reflection on method parameters")
|
||||
var javaParameters: Boolean by FreezableVar(false)
|
||||
|
||||
+15
-6
@@ -22,7 +22,8 @@ import kotlin.reflect.full.withNullability
|
||||
interface AdditionalGradleProperties {
|
||||
@GradleOption(
|
||||
value = DefaultValue.EMPTY_STRING_LIST_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "", description = "A list of additional compiler arguments")
|
||||
var freeCompilerArgs: List<String>
|
||||
@@ -488,12 +489,17 @@ private fun Printer.generateDeprecatedInterface(
|
||||
val modifier = """
|
||||
interface
|
||||
""".trimIndent()
|
||||
generateDeclaration(modifier, type, afterType = afterType) {
|
||||
val deprecatedProperties = properties.filter { it.generateDeprecatedKotlinOption }
|
||||
// KotlinMultiplatformCommonOptions doesn't have any options, but it is being kept for backward compatibility
|
||||
if (deprecatedProperties.isNotEmpty() || type.asString().endsWith("KotlinMultiplatformCommonOptions")) {
|
||||
generateDeclaration(modifier, type, afterType = afterType) {
|
||||
|
||||
println("${if (parentType != null) "override " else ""}val options: $compilerOptionType")
|
||||
properties.forEach {
|
||||
println()
|
||||
generatePropertyGetterAndSetter(it)
|
||||
println("${if (parentType != null) "override " else ""}val options: $compilerOptionType")
|
||||
deprecatedProperties
|
||||
.forEach {
|
||||
println()
|
||||
generatePropertyGetterAndSetter(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -790,6 +796,9 @@ private val KProperty1<*, *>.gradleLazyReturnTypeInstantiator: String
|
||||
private val KProperty1<*, *>.gradleInputType: String get() =
|
||||
findAnnotation<GradleOption>()!!.gradleInputType
|
||||
|
||||
private val KProperty1<*, *>.generateDeprecatedKotlinOption: Boolean
|
||||
get() = findAnnotation<GradleOption>()!!.shouldGenerateDeprecatedKotlinOptions
|
||||
|
||||
private inline fun <reified T> KAnnotatedElement.findAnnotation(): T? =
|
||||
annotations.filterIsInstance<T>().firstOrNull()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user