Introduce FlexiblePhaseConfig
For dynamic Kotlin/Native driver we need a PhaseConfigurationService that does not force us to provide a list of phases upfront.
This commit is contained in:
committed by
Space Team
parent
cd3dece726
commit
c22cad07ed
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.cli.common;
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig;
|
||||
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfigurationService;
|
||||
import org.jetbrains.kotlin.cli.common.config.ContentRoot;
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.kotlin.config.CompilerConfigurationKey;
|
||||
@@ -56,6 +57,9 @@ public class CLIConfigurationKeys {
|
||||
public static final CompilerConfigurationKey<PhaseConfig> PHASE_CONFIG =
|
||||
CompilerConfigurationKey.create("phase configuration");
|
||||
|
||||
public static final CompilerConfigurationKey<PhaseConfigurationService> FLEXIBLE_PHASE_CONFIG =
|
||||
CompilerConfigurationKey.create("flexible phase configuration");
|
||||
|
||||
public static final CompilerConfigurationKey<Integer> REPEAT_COMPILE_MODULES =
|
||||
CompilerConfigurationKey.create("debug key for profiling, repeats compileModules");
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.cli.common
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.phaser.FlexiblePhaseConfig
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
|
||||
fun createFlexiblePhaseConfig(
|
||||
arguments: CommonCompilerArguments,
|
||||
): FlexiblePhaseConfig {
|
||||
fun Array<String>?.asNonNullSet(): Set<String> = this?.toSet() ?: emptySet()
|
||||
|
||||
val toDumpBoth = arguments.phasesToDump.asNonNullSet()
|
||||
val toValidateBoth = arguments.phasesToValidate.asNonNullSet()
|
||||
|
||||
return FlexiblePhaseConfig(
|
||||
disabled = arguments.disablePhases.asNonNullSet(),
|
||||
verbose = arguments.verbosePhases.asNonNullSet(),
|
||||
toDumpStateBefore = arguments.phasesToDumpBefore.asNonNullSet() + toDumpBoth,
|
||||
toDumpStateAfter = arguments.phasesToDumpAfter.asNonNullSet() + toDumpBoth,
|
||||
toValidateStateBefore = arguments.phasesToValidateBefore.asNonNullSet() + toValidateBoth,
|
||||
toValidateStateAfter = arguments.phasesToValidateAfter.asNonNullSet() + toValidateBoth,
|
||||
dumpOnlyFqName = arguments.dumpOnlyFqName,
|
||||
dumpToDirectory = arguments.dumpDirectory,
|
||||
needProfiling = arguments.profilePhases,
|
||||
checkConditions = arguments.checkPhaseConditions,
|
||||
checkStickyConditions = arguments.checkStickyPhaseConditions,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user