|
| 1 | +/* |
| 2 | + * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors. |
| 3 | + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. |
| 4 | + */ |
| 5 | + |
| 6 | +package org.jetbrains.kotlin.cli.common.arguments |
| 7 | + |
| 8 | +import org.jetbrains.kotlin.config.* |
| 9 | + |
| 10 | +class K2JKlibCompilerArguments : CommonCompilerArguments() { |
| 11 | + companion object { |
| 12 | + @JvmStatic private val serialVersionUID = 0L |
| 13 | + } |
| 14 | + |
| 15 | + @Argument(value = "-d", valueDescription = "<klib>", description = "Destination for generated files.") |
| 16 | + var destination: String? = null |
| 17 | + set(value) { |
| 18 | + checkFrozen() |
| 19 | + field = if (value.isNullOrEmpty()) null else value |
| 20 | + } |
| 21 | + |
| 22 | + @Argument(value = "-p", valueDescription = "<library|ir>", description = "") |
| 23 | + var produce: String? = null |
| 24 | + set(value) { |
| 25 | + checkFrozen() |
| 26 | + field = if (value.isNullOrEmpty()) null else value |
| 27 | + } |
| 28 | + |
| 29 | + @Argument( |
| 30 | + value = "-classpath", |
| 31 | + shortName = "-cp", |
| 32 | + valueDescription = "<path>", |
| 33 | + description = "List of directories and JAR/ZIP archives to search for user .kotlin_metadata files." |
| 34 | + ) |
| 35 | + var classpath: String? = null |
| 36 | + set(value) { |
| 37 | + checkFrozen() |
| 38 | + field = if (value.isNullOrEmpty()) null else value |
| 39 | + } |
| 40 | + |
| 41 | + @Argument(value = "-module-name", valueDescription = "<name>", description = "Name of the generated .kotlin_module file.") |
| 42 | + var moduleName: String? = null |
| 43 | + set(value) { |
| 44 | + checkFrozen() |
| 45 | + field = if (value.isNullOrEmpty()) null else value |
| 46 | + } |
| 47 | + |
| 48 | + @Argument( |
| 49 | + value = "-Xfriend-paths", |
| 50 | + valueDescription = "<path>", |
| 51 | + description = "Paths to output directories for friend modules (modules whose internals should be visible)." |
| 52 | + ) |
| 53 | + var friendPaths: Array<String>? = null |
| 54 | + set(value) { |
| 55 | + checkFrozen() |
| 56 | + field = value |
| 57 | + } |
| 58 | + |
| 59 | + @Argument( |
| 60 | + value = "-Xklib", |
| 61 | + valueDescription = "<path>", |
| 62 | + description = "Paths to cross-platform libraries in the .klib format." |
| 63 | + ) |
| 64 | + var klibLibraries: String? = null |
| 65 | + set(value) { |
| 66 | + checkFrozen() |
| 67 | + field = if (value.isNullOrEmpty()) null else value |
| 68 | + } |
| 69 | + |
| 70 | + @Argument( |
| 71 | + value = "-no-stdlib", |
| 72 | + description = "Don't automatically include the Kotlin/JVM stdlib and Kotlin reflection dependencies in the classpath." |
| 73 | + ) |
| 74 | + var noStdlib = false |
| 75 | + set(value) { |
| 76 | + checkFrozen() |
| 77 | + field = value |
| 78 | + } |
| 79 | + |
| 80 | + @Argument( |
| 81 | + value = "-Xcompile-builtins-as-part-of-stdlib", |
| 82 | + description = "Enable behaviour needed to compile builtins as part of JVM stdlib" |
| 83 | + ) |
| 84 | + var expectBuiltinsAsPartOfStdlib = false |
| 85 | + set(value) { |
| 86 | + checkFrozen() |
| 87 | + field = value |
| 88 | + } |
| 89 | + |
| 90 | + |
| 91 | + @Argument(value = "-no-jdk", description = "Don't automatically include the Java runtime in the classpath.") |
| 92 | + var noJdk = false |
| 93 | + set(value) { |
| 94 | + checkFrozen() |
| 95 | + field = value |
| 96 | + } |
| 97 | + |
| 98 | + |
| 99 | + @Argument(value = "-no-reflect", description = "Don't automatically include the Kotlin reflection dependency in the classpath.") |
| 100 | + var noReflect = false |
| 101 | + set(value) { |
| 102 | + checkFrozen() |
| 103 | + field = value |
| 104 | + } |
| 105 | + @Argument( |
| 106 | + value = "-Xtype-enhancement-improvements-strict-mode", |
| 107 | + description = """Enable strict mode for improvements to type enhancement for loaded Java types based on nullability annotations, |
| 108 | +including the ability to read type-use annotations from class files. |
| 109 | +See KT-45671 for more details.""" |
| 110 | + ) |
| 111 | + var typeEnhancementImprovementsInStrictMode = false |
| 112 | + set(value) { |
| 113 | + checkFrozen() |
| 114 | + field = value |
| 115 | + } |
| 116 | + |
| 117 | + @Argument( |
| 118 | + value = "-Xenhance-type-parameter-types-to-def-not-null", |
| 119 | + description = "Enhance not-null-annotated type parameter types to definitely-non-nullable types ('@NotNull T' => 'T & Any')." |
| 120 | + ) |
| 121 | + var enhanceTypeParameterTypesToDefNotNull = false |
| 122 | + set(value) { |
| 123 | + checkFrozen() |
| 124 | + field = value |
| 125 | + } |
| 126 | + |
| 127 | + @Argument( |
| 128 | + value = "-Xjvm-default", |
| 129 | + valueDescription = "{all|all-compatibility|disable}", |
| 130 | + description = """Emit JVM default methods for interface declarations with bodies. The default is 'disable'. |
| 131 | +-Xjvm-default=all Generate JVM default methods for all interface declarations with bodies in the module. |
| 132 | + Do not generate 'DefaultImpls' stubs for interface declarations with bodies. If an interface inherits a method with a |
| 133 | + body from an interface compiled in 'disable' mode and doesn't override it, then a 'DefaultImpls' stub will be |
| 134 | + generated for it. |
| 135 | + This BREAKS BINARY COMPATIBILITY if some client code relies on the presence of 'DefaultImpls' classes. |
| 136 | + Note that if interface delegation is used, all interface methods are delegated. |
| 137 | +-Xjvm-default=all-compatibility Like 'all', but additionally generate compatibility stubs in the 'DefaultImpls' classes. |
| 138 | + Compatibility stubs can help library and runtime authors maintain backward binary compatibility |
| 139 | + for existing clients compiled against previous library versions. |
| 140 | + 'all' and 'all-compatibility' modes change the library ABI surface that will be used by clients after |
| 141 | + the recompilation of the library. Because of this, clients might be incompatible with previous library |
| 142 | + versions. This usually means that proper library versioning is required, for example with major version increases in SemVer. |
| 143 | + In subtypes of Kotlin interfaces compiled in 'all' or 'all-compatibility' mode, 'DefaultImpls' |
| 144 | + compatibility stubs will invoke the default method of the interface with standard JVM runtime resolution semantics. |
| 145 | + Perform additional compatibility checks for classes inheriting generic interfaces where in some cases an |
| 146 | + additional implicit method with specialized signatures was generated in 'disable' mode. |
| 147 | + Unlike in 'disable' mode, the compiler will report an error if such a method is not overridden explicitly |
| 148 | + and the class is not annotated with '@JvmDefaultWithoutCompatibility' (see KT-39603 for more details). |
| 149 | +-Xjvm-default=disable Default behavior. Do not generate JVM default methods.""" |
| 150 | + ) |
| 151 | + var jvmDefault: String = JvmDefaultMode.DISABLE.description |
| 152 | + set(value) { |
| 153 | + checkFrozen() |
| 154 | + field = value |
| 155 | + } |
| 156 | + |
| 157 | + @Argument( |
| 158 | + value = "-Xvalue-classes", |
| 159 | + description = "Enable experimental value classes." |
| 160 | + ) |
| 161 | + var valueClasses = false |
| 162 | + set(value) { |
| 163 | + checkFrozen() |
| 164 | + field = value |
| 165 | + } |
| 166 | + |
| 167 | + @Argument( |
| 168 | + value = "-Xjsr305", |
| 169 | + deprecatedName = "-Xjsr305-annotations", |
| 170 | + valueDescription = |
| 171 | + "{ignore/strict/warn}" + |
| 172 | + "|under-migration:{ignore/strict/warn}" + |
| 173 | + "|@<fq.name>:{ignore/strict/warn}", |
| 174 | + description = |
| 175 | + """Specify the behavior of 'JSR-305' nullability annotations: |
| 176 | +-Xjsr305={ignore/strict/warn} global (all non-@UnderMigration annotations) |
| 177 | +-Xjsr305=under-migration:{ignore/strict/warn} all @UnderMigration annotations |
| 178 | +-Xjsr305=@<fq.name>:{ignore/strict/warn} annotation with the given fully qualified class name |
| 179 | +Modes: |
| 180 | +* ignore |
| 181 | +* strict (experimental; treat like other supported nullability annotations) |
| 182 | +* warn (report a warning)""", |
| 183 | + ) |
| 184 | + var jsr305: Array<String>? = null |
| 185 | + set(value) { |
| 186 | + checkFrozen() |
| 187 | + field = value |
| 188 | + } |
| 189 | + |
| 190 | + @Argument( |
| 191 | + value = "-Xsupport-compatqual-checker-framework-annotations", |
| 192 | + valueDescription = "enable|disable", |
| 193 | + description = |
| 194 | + """Specify the behavior for Checker Framework 'compatqual' annotations ('NullableDecl'/'NonNullDecl'). |
| 195 | +The default value is 'enable'.""", |
| 196 | + ) |
| 197 | + var supportCompatqualCheckerFrameworkAnnotations: String? = null |
| 198 | + set(value) { |
| 199 | + checkFrozen() |
| 200 | + field = if (value.isNullOrEmpty()) null else value |
| 201 | + } |
| 202 | + |
| 203 | + @Argument( |
| 204 | + value = "-Xjspecify-annotations", |
| 205 | + valueDescription = "ignore|strict|warn", |
| 206 | + description = |
| 207 | + """Specify the behavior of 'jspecify' annotations. |
| 208 | +The default value is 'warn'.""", |
| 209 | + ) |
| 210 | + var jspecifyAnnotations: String? = null |
| 211 | + set(value) { |
| 212 | + checkFrozen() |
| 213 | + field = value |
| 214 | + } |
| 215 | + |
| 216 | + @Argument( |
| 217 | + value = "Xmultifile-parts-inherit", |
| 218 | + description = "Compile multifile classes as a hierarchy of parts and a facade." |
| 219 | + ) |
| 220 | + var inheritMultifileParts: Boolean = false |
| 221 | + set(value) { |
| 222 | + checkFrozen() |
| 223 | + field = value |
| 224 | + } |
| 225 | + |
| 226 | + @Argument( |
| 227 | + value = "-Xoutput-builtins-metadata", |
| 228 | + description = "Output builtins metadata as .kotlin_builtins files", |
| 229 | + ) |
| 230 | + var outputBuiltinsMetadata: Boolean = false |
| 231 | + set(value) { |
| 232 | + checkFrozen() |
| 233 | + field = value |
| 234 | + } |
| 235 | + |
| 236 | + @Argument( |
| 237 | + value = "-Xnullability-annotations", |
| 238 | + valueDescription = "@<fq.name>:{ignore/strict/warn}", |
| 239 | + description = |
| 240 | + """Specify the behavior for specific Java nullability annotations (provided with fully qualified package name). |
| 241 | +Modes: |
| 242 | +* ignore |
| 243 | +* strict |
| 244 | +* warn (report a warning)""", |
| 245 | + ) |
| 246 | + var nullabilityAnnotations: Array<String>? = null |
| 247 | + set(value) { |
| 248 | + checkFrozen() |
| 249 | + field = value |
| 250 | + } |
| 251 | + |
| 252 | + override fun copyOf(): Freezable = TODO() // copyK2JKlibCompilerArguments(this, K2JKlibCompilerArguments()) |
| 253 | + |
| 254 | + override val configurator: CommonCompilerArgumentsConfigurator = K2JKlibCompilerArgumentsConfigurator() |
| 255 | + |
| 256 | +} |
0 commit comments