[JS IR] Support generating both IR and pre-IR libraries
Remove all previous -Xir options Add: -Xir-produce-klib-dir -Xir-produce-klib-file -Xir-produce-js -Xir-only
This commit is contained in:
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys;
|
||||
import org.jetbrains.kotlin.cli.common.CommonCompilerPerformanceManager;
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArgumentsKt;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants;
|
||||
import org.jetbrains.kotlin.cli.common.config.ContentRootsKt;
|
||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport;
|
||||
@@ -186,8 +187,13 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
) {
|
||||
MessageCollector messageCollector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY);
|
||||
|
||||
if (arguments.getIrBackend()) {
|
||||
return getIrCompiler().doExecute(arguments, configuration, rootDisposable, paths);
|
||||
ExitCode exitCode = OK;
|
||||
|
||||
if (K2JSCompilerArgumentsKt.isIrBackendEnabled(arguments)) {
|
||||
exitCode = getIrCompiler().doExecute(arguments, configuration.copy(), rootDisposable, paths);
|
||||
}
|
||||
if (K2JSCompilerArgumentsKt.isPreIrBackendDisabled(arguments)) {
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
if (arguments.getFreeArgs().isEmpty() && !IncrementalCompilation.isEnabledForJs()) {
|
||||
@@ -388,8 +394,10 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
@NotNull CompilerConfiguration configuration, @NotNull K2JSCompilerArguments arguments,
|
||||
@NotNull Services services
|
||||
) {
|
||||
if (arguments.getIrBackend()) {
|
||||
if (K2JSCompilerArgumentsKt.isIrBackendEnabled(arguments)) {
|
||||
getIrCompiler().setupPlatformSpecificArgumentsAndServices(configuration, arguments, services);
|
||||
}
|
||||
if (K2JSCompilerArgumentsKt.isPreIrBackendDisabled(arguments)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,17 +175,12 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
it.libraryFile.absolutePath in friendAbsolutePaths
|
||||
}
|
||||
|
||||
val produceKind = produceMap[arguments.irProduceOnly]
|
||||
if (produceKind == null) {
|
||||
messageCollector.report(ERROR, "Unknown produce kind: ${arguments.irProduceOnly}. Valid values are: js, klib")
|
||||
}
|
||||
|
||||
if (produceKind == ProduceKind.KLIB || (produceKind == ProduceKind.DEFAULT && arguments.metaInfo)) {
|
||||
if (arguments.irProduceKlibDir || arguments.irProduceKlibFile) {
|
||||
val outputKlibPath =
|
||||
if (arguments.irLegacyGradlePluginCompatibility)
|
||||
if (arguments.irProduceKlibDir)
|
||||
File(outputFilePath).parent
|
||||
else
|
||||
"$outputFilePath.klib"
|
||||
outputFilePath
|
||||
|
||||
generateKLib(
|
||||
project = config.project,
|
||||
@@ -194,11 +189,11 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
allDependencies = resolvedLibraries,
|
||||
friendDependencies = friendDependencies,
|
||||
outputKlibPath = outputKlibPath,
|
||||
nopack = arguments.irLegacyGradlePluginCompatibility
|
||||
nopack = arguments.irProduceKlibDir
|
||||
)
|
||||
}
|
||||
|
||||
if (produceKind == ProduceKind.JS || produceKind == ProduceKind.DEFAULT) {
|
||||
if (arguments.irProduceJs) {
|
||||
val phaseConfig = createPhaseConfig(jsPhases, arguments, messageCollector)
|
||||
|
||||
val compiledModule = compile(
|
||||
|
||||
Reference in New Issue
Block a user