Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions compiler/arguments/resources/kotlin-compiler-arguments.json
Original file line number Diff line number Diff line change
Expand Up @@ -3842,6 +3842,37 @@
"deprecatedVersion": null,
"removedVersion": null
}
},
{
"name": "Xheader-mode",
"shortName": null,
"deprecatedName": null,
"description": {
"current": "Enable header compilation mode.\nIn this mode, the compiler produces class files that only contain the 'skeleton' of the classes to be\ncompiled but the method bodies of all the implementations are empty. This is used to speed up parallel compilation\nbuild systems where header libraries can be used to replace downstream dependencies for which we only need to\nsee the type names and method signatures required to compile a given translation unit.",
"valueInVersions": []
},
"delimiter": null,
"valueType": {
"type": "org.jetbrains.kotlin.arguments.dsl.types.BooleanType",
"isNullable": {
"current": false,
"valueInVersions": []
},
"defaultValue": {
"current": false,
"valueInVersions": []
}
},
"valueDescription": {
"current": null,
"valueInVersions": []
},
"releaseVersionsMetadata": {
"introducedVersion": "2.3.0",
"stabilizedVersion": null,
"deprecatedVersion": null,
"removedVersion": null
}
}
],
"nestedLevels": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1183,4 +1183,20 @@ Warning: this flag is not intended for production use. If you want to configure
introducedVersion = KotlinReleaseVersion.v1_0_0
)
}

compilerArgument {
name = "Xheader-mode"
description = """
Enable header compilation mode.
In this mode, the compiler produces class files that only contain the 'skeleton' of the classes to be
compiled but the method bodies of all the implementations are empty. This is used to speed up parallel compilation
build systems where header libraries can be used to replace downstream dependencies for which we only need to
see the type names and method signatures required to compile a given translation unit.
""".trimIndent().asReleaseDependent()
valueType = BooleanType.defaultFalse

lifecycle(
introducedVersion = KotlinReleaseVersion.v2_3_0
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -737,5 +737,19 @@ public interface CommonCompilerArguments : CommonToolArguments {
@ExperimentalCompilerArgument
public val X_NAME_BASED_DESTRUCTURING: CommonCompilerArgument<String?> =
CommonCompilerArgument("X_NAME_BASED_DESTRUCTURING", KotlinKotlinVersion(2, 3, 0))

/**
* Enable header compilation mode.
* In this mode, the compiler produces class files that only contain the 'skeleton' of the classes to be
* compiled but the method bodies of all the implementations are empty. This is used to speed up parallel compilation
* build systems where header libraries can be used to replace downstream dependencies for which we only need to
* see the type names and method signatures required to compile a given translation unit.
*
* WARNING: this option is EXPERIMENTAL and it may be changed in the future without notice or may be removed entirely.
*/
@JvmField
@ExperimentalCompilerArgument
public val X_HEADER_MODE: CommonCompilerArgument<Boolean> =
CommonCompilerArgument("X_HEADER_MODE", KotlinKotlinVersion(2, 3, 0))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgume
import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgumentsImpl.Companion.X_FRAGMENT_FRIEND_DEPENDENCY
import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgumentsImpl.Companion.X_FRAGMENT_REFINES
import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgumentsImpl.Companion.X_FRAGMENT_SOURCES
import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgumentsImpl.Companion.X_HEADER_MODE
import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgumentsImpl.Companion.X_IGNORE_CONST_OPTIMIZATION_ERRORS
import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgumentsImpl.Companion.X_INLINE_CLASSES
import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgumentsImpl.Companion.X_INTELLIJ_PLUGIN_ROOT
Expand Down Expand Up @@ -243,6 +244,7 @@ internal abstract class CommonCompilerArgumentsImpl : CommonToolArgumentsImpl(),
if (X_ALLOW_HOLDSIN_CONTRACT in this) { arguments.allowHoldsinContract = get(X_ALLOW_HOLDSIN_CONTRACT)}
if (X_NAME_BASED_DESTRUCTURING in this) { arguments.nameBasedDestructuring = get(X_NAME_BASED_DESTRUCTURING)}
if (XX_LANGUAGE in this) { arguments.manuallyConfiguredFeatures = get(XX_LANGUAGE)}
if (X_HEADER_MODE in this) { arguments.headerMode = get(X_HEADER_MODE)}
return arguments
}

Expand Down Expand Up @@ -340,6 +342,7 @@ internal abstract class CommonCompilerArgumentsImpl : CommonToolArgumentsImpl(),
try { this[X_ALLOW_HOLDSIN_CONTRACT] = arguments.allowHoldsinContract } catch (_: NoSuchMethodError) { }
try { this[X_NAME_BASED_DESTRUCTURING] = arguments.nameBasedDestructuring } catch (_: NoSuchMethodError) { }
try { this[XX_LANGUAGE] = arguments.manuallyConfiguredFeatures } catch (_: NoSuchMethodError) { }
try { this[X_HEADER_MODE] = arguments.headerMode } catch (_: NoSuchMethodError) { }
internalArguments.addAll(arguments.internalArguments.map { it.stringRepresentation })
}

Expand Down Expand Up @@ -615,5 +618,8 @@ internal abstract class CommonCompilerArgumentsImpl : CommonToolArgumentsImpl(),

public val XX_LANGUAGE: CommonCompilerArgument<Array<String>?> =
CommonCompilerArgument("XX_LANGUAGE")

public val X_HEADER_MODE: CommonCompilerArgument<Boolean> =
CommonCompilerArgument("X_HEADER_MODE")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,20 @@ Warning: this flag is not intended for production use. If you want to configure
field = value
}

@Argument(
value = "-Xheader-mode",
description = """Enable header compilation mode.
In this mode, the compiler produces class files that only contain the 'skeleton' of the classes to be
compiled but the method bodies of all the implementations are empty. This is used to speed up parallel compilation
build systems where header libraries can be used to replace downstream dependencies for which we only need to
see the type names and method signatures required to compile a given translation unit.""",
)
var headerMode: Boolean = false
set(value) {
checkFrozen()
field = value
}

@get:Transient
abstract val configurator: CommonCompilerArgumentsConfigurator

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fun copyCommonCompilerArguments(from: CommonCompilerArguments, to: CommonCompile
to.fragmentRefines = from.fragmentRefines?.copyOf()
to.fragmentSources = from.fragmentSources?.copyOf()
to.fragments = from.fragments?.copyOf()
to.headerMode = from.headerMode
to.ignoreConstOptimizationErrors = from.ignoreConstOptimizationErrors
to.incrementalCompilation = from.incrementalCompilation
to.inlineClasses = from.inlineClasses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fun CompilerConfiguration.setupCommonArguments(
put(CommonConfigurationKeys.INCREMENTAL_COMPILATION, incrementalCompilationIsEnabled(arguments))
put(CommonConfigurationKeys.ALLOW_ANY_SCRIPTS_IN_SOURCE_ROOTS, arguments.allowAnyScriptsInSourceRoots)
put(CommonConfigurationKeys.IGNORE_CONST_OPTIMIZATION_ERRORS, arguments.ignoreConstOptimizationErrors)
put(CommonConfigurationKeys.HEADER_COMPILATION, arguments.headerMode)

val irVerificationMode = arguments.verifyIr?.let { verifyIrString ->
IrVerificationMode.resolveMode(verifyIrString).also {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ object CommonConfigurationKeysContainer : KeysContainer("org.jetbrains.kotlin.co
val ALLOW_ANY_SCRIPTS_IN_SOURCE_ROOTS by key<Boolean>("Allow to compile any scripts along with regular Kotlin sources")
val IGNORE_CONST_OPTIMIZATION_ERRORS by key<Boolean>("Ignore errors from IrConstTransformer")
val EVALUATED_CONST_TRACKER by key<EvaluatedConstTracker>("Keeps track of all evaluated by IrInterpreter constants")
val HEADER_COMPILATION by key<Boolean>("Enable header compilation mode")

val MESSAGE_COLLECTOR_KEY by key<MessageCollector>(
"message collector",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ object CommonConfigurationKeys {
@JvmField
val EVALUATED_CONST_TRACKER = CompilerConfigurationKey.create<EvaluatedConstTracker>("Keeps track of all evaluated by IrInterpreter constants")

@JvmField
val HEADER_COMPILATION = CompilerConfigurationKey.create<Boolean>("Enable header compilation mode")

@JvmField
val MESSAGE_COLLECTOR_KEY = CompilerConfigurationKey.create<MessageCollector>("message collector")

Expand Down Expand Up @@ -230,6 +233,10 @@ var CompilerConfiguration.evaluatedConstTracker: EvaluatedConstTracker?
get() = get(CommonConfigurationKeys.EVALUATED_CONST_TRACKER)
set(value) { put(CommonConfigurationKeys.EVALUATED_CONST_TRACKER, requireNotNull(value) { "nullable values are not allowed" }) }

var CompilerConfiguration.headerCompilation: Boolean
get() = getBoolean(CommonConfigurationKeys.HEADER_COMPILATION)
set(value) { put(CommonConfigurationKeys.HEADER_COMPILATION, value) }

var CompilerConfiguration.messageCollector: MessageCollector
get() = get(CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
set(value) { put(CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY, value) }
Expand Down