[JS] Get rid of outputFile in compiler args (KT-61116)

^KT-56753 fixed
This commit is contained in:
Ilya Goncharov
2023-11-08 14:30:58 +01:00
committed by Space Team
parent 9fcf6c5f89
commit 2340d59f40
27 changed files with 23 additions and 645 deletions
@@ -73,7 +73,6 @@ internal object CompilerExecutor {
}
CompilerKind.JS -> {
val commands = buildList {
add(K2JSCompilerArguments::metaInfo.cliArgument)
add(K2JSCompilerArguments::moduleName.cliArgument); add(libraryName)
add(K2JSCompilerArguments::outputDir.cliArgument); add(library.parent.absolutePathString())
add(K2JSCompilerArguments::irProduceKlibFile.cliArgument)
@@ -1,4 +1,4 @@
@file:Suppress("unused", "DuplicatedCode")
@file:Suppress("unused", "DuplicatedCode", "DEPRECATION")
// DO NOT EDIT MANUALLY!
// Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt
@@ -1,4 +1,4 @@
@file:Suppress("unused", "DuplicatedCode")
@file:Suppress("unused", "DuplicatedCode", "DEPRECATION")
// DO NOT EDIT MANUALLY!
// Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt
@@ -1,4 +1,4 @@
@file:Suppress("unused", "DuplicatedCode")
@file:Suppress("unused", "DuplicatedCode", "DEPRECATION")
// DO NOT EDIT MANUALLY!
// Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt
@@ -15,7 +15,6 @@ fun copyK2JSCompilerArguments(from: K2JSCompilerArguments, to: K2JSCompilerArgum
to.errorTolerancePolicy = from.errorTolerancePolicy
to.extensionFunctionsInExternals = from.extensionFunctionsInExternals
to.fakeOverrideValidator = from.fakeOverrideValidator
to.forceDeprecatedLegacyCompilerUsage = from.forceDeprecatedLegacyCompilerUsage
to.friendModules = from.friendModules
to.friendModulesDisabled = from.friendModulesDisabled
to.generateDts = from.generateDts
@@ -46,15 +45,11 @@ fun copyK2JSCompilerArguments(from: K2JSCompilerArguments, to: K2JSCompilerArgum
to.libraries = from.libraries
to.main = from.main
to.metaInfo = from.metaInfo
to.metadataOnly = from.metadataOnly
to.moduleKind = from.moduleKind
to.moduleName = from.moduleName
to.noStdlib = from.noStdlib
to.optimizeGeneratedJs = from.optimizeGeneratedJs
to.outputDir = from.outputDir
to.outputFile = from.outputFile
to.outputPostfix = from.outputPostfix
to.outputPrefix = from.outputPrefix
to.partialLinkageLogLevel = from.partialLinkageLogLevel
to.partialLinkageMode = from.partialLinkageMode
to.platformArgumentsProviderJsExpression = from.platformArgumentsProviderJsExpression
@@ -1,4 +1,4 @@
@file:Suppress("unused", "DuplicatedCode")
@file:Suppress("unused", "DuplicatedCode", "DEPRECATION")
// DO NOT EDIT MANUALLY!
// Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt
@@ -1,4 +1,4 @@
@file:Suppress("unused", "DuplicatedCode")
@file:Suppress("unused", "DuplicatedCode", "DEPRECATION")
// DO NOT EDIT MANUALLY!
// Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt
@@ -1,4 +1,4 @@
@file:Suppress("unused", "DuplicatedCode")
@file:Suppress("unused", "DuplicatedCode", "DEPRECATION")
// DO NOT EDIT MANUALLY!
// Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt
@@ -1,4 +1,4 @@
@file:Suppress("unused", "DuplicatedCode")
@file:Suppress("unused", "DuplicatedCode", "DEPRECATION")
// DO NOT EDIT MANUALLY!
// Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt
@@ -16,16 +16,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
@JvmStatic private val serialVersionUID = 0L
}
@GradleOption(
value = DefaultValue.STRING_NULL_DEFAULT,
gradleInputType = GradleInputTypes.INTERNAL, // handled by task 'outputFileProperty'
shouldGenerateDeprecatedKotlinOptions = true,
)
@GradleDeprecatedOption(
message = "Only for legacy backend. For IR backend please use task.destinationDirectory and moduleName",
level = DeprecationLevel.WARNING,
removeAfter = "1.9.0"
)
@Deprecated("It is senseless to use with IR compiler. Only for compatibility.")
@Argument(value = "-output", valueDescription = "<filepath>", description = "Destination *.js file for the compilation result.")
var outputFile: String? = null
set(value) {
@@ -52,18 +43,6 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
field = if (value.isNullOrEmpty()) null else value
}
@GradleOption(
value = DefaultValue.BOOLEAN_TRUE_DEFAULT,
gradleInputType = GradleInputTypes.INPUT,
shouldGenerateDeprecatedKotlinOptions = true,
)
@Argument(value = "-no-stdlib", description = "Don't automatically include the default Kotlin/JS stdlib in compilation dependencies.")
var noStdlib = false
set(value) {
checkFrozen()
field = value
}
@Argument(
value = "-libraries",
valueDescription = "<path>",
@@ -147,11 +126,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
field = if (value.isNullOrEmpty()) null else value
}
@GradleOption(
value = DefaultValue.BOOLEAN_TRUE_DEFAULT,
gradleInputType = GradleInputTypes.INPUT,
shouldGenerateDeprecatedKotlinOptions = true,
)
@Deprecated("It is senseless to use with IR compiler. Only for compatibility.")
@Argument(value = "-meta-info", description = "Generate .meta.js and .kjsm files with metadata. Use this to create a library.")
var metaInfo = false
set(value) {
@@ -214,28 +189,6 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
field = if (value.isNullOrEmpty()) null else value
}
@Argument(
value = "-output-prefix",
valueDescription = "<path>",
description = "Add the content of the specified file to the beginning of the output file."
)
var outputPrefix: String? = null
set(value) {
checkFrozen()
field = if (value.isNullOrEmpty()) null else value
}
@Argument(
value = "-output-postfix",
valueDescription = "<path>",
description = "Add the content of the specified file to the end of the output file."
)
var outputPostfix: String? = null
set(value) {
checkFrozen()
field = if (value.isNullOrEmpty()) null else value
}
// Advanced options
@Argument(
@@ -559,13 +512,6 @@ In combination with '-meta-info', this generates both IR and pre-IR versions of
field = value
}
@Argument(value = "-Xmetadata-only", description = "Generate .meta.js and .kjsm files only.")
var metadataOnly = false
set(value) {
checkFrozen()
field = value
}
@Argument(value = "-Xenable-js-scripting", description = "Enable experimental support for .kts files using K/JS (with '-Xir' only).")
var enableJsScripting = false
set(value) {
@@ -660,16 +606,6 @@ In combination with '-meta-info', this generates both IR and pre-IR versions of
field = value
}
@Argument(
value = "-Xforce-deprecated-legacy-compiler-usage",
description = "This flag is used only for our inner infrastructure. It will soon be removed, so it's no longer safe to use."
)
var forceDeprecatedLegacyCompilerUsage = false
set(value) {
checkFrozen()
field = value
}
@Argument(
value = "-Xoptimize-generated-js",
description = "Perform additional optimizations on the generated JS code."
@@ -739,8 +675,5 @@ In combination with '-meta-info', this generates both IR and pre-IR versions of
override fun copyOf(): Freezable = copyK2JSCompilerArguments(this, K2JSCompilerArguments())
}
fun K2JSCompilerArguments.isPreIrBackendDisabled(): Boolean =
irOnly || irProduceJs || irProduceKlibFile || irBuildCache || useK2
fun K2JSCompilerArguments.isIrBackendEnabled(): Boolean =
irProduceKlibDir || irProduceJs || irProduceKlibFile || wasm || irBuildCache || useK2
@@ -70,9 +70,6 @@ import static org.jetbrains.kotlin.cli.common.UtilsKt.incrementalCompilationIsEn
import static org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*;
public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
private static final Map<String, ModuleKind> moduleKindMap = new HashMap<>();
private static final Map<String, SourceMapSourceEmbedding> sourceMapContentEmbeddingMap = new LinkedHashMap<>();
private K2JsIrCompiler irCompiler = null;
@NotNull
@@ -85,18 +82,6 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
@Override
protected void addPlatformOptions(@NotNull List<String> $self, @NotNull K2JSCompilerArguments arguments) {}
static {
moduleKindMap.put(K2JsArgumentConstants.MODULE_PLAIN, ModuleKind.PLAIN);
moduleKindMap.put(K2JsArgumentConstants.MODULE_COMMONJS, ModuleKind.COMMON_JS);
moduleKindMap.put(K2JsArgumentConstants.MODULE_AMD, ModuleKind.AMD);
moduleKindMap.put(K2JsArgumentConstants.MODULE_UMD, ModuleKind.UMD);
moduleKindMap.put(K2JsArgumentConstants.MODULE_ES, ModuleKind.ES);
sourceMapContentEmbeddingMap.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_ALWAYS, SourceMapSourceEmbedding.ALWAYS);
sourceMapContentEmbeddingMap.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_NEVER, SourceMapSourceEmbedding.NEVER);
sourceMapContentEmbeddingMap.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING, SourceMapSourceEmbedding.INLINING);
}
public static void main(String... args) {
doMain(new K2JSCompiler(), args);
}
@@ -109,61 +94,6 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
return new K2JSCompilerArguments();
}
@NotNull
private static TranslationResult translate(
@NotNull JsConfig.Reporter reporter,
@NotNull List<KtFile> allKotlinFiles,
@NotNull JsAnalysisResult jsAnalysisResult,
@NotNull MainCallParameters mainCallParameters,
@NotNull JsConfig config
) throws TranslationException {
K2JSTranslator translator = new K2JSTranslator(config);
IncrementalDataProvider incrementalDataProvider = config.getConfiguration().get(JSConfigurationKeys.INCREMENTAL_DATA_PROVIDER);
if (incrementalDataProvider != null) {
Map<File, KtFile> nonCompiledSources = new HashMap<>(allKotlinFiles.size());
for (KtFile ktFile : allKotlinFiles) {
nonCompiledSources.put(VfsUtilCore.virtualToIoFile(ktFile.getVirtualFile()), ktFile);
}
Map<File, TranslationResultValue> compiledParts = incrementalDataProvider.getCompiledPackageParts();
File[] allSources = new File[compiledParts.size() + allKotlinFiles.size()];
int i = 0;
for (File file : compiledParts.keySet()) {
allSources[i++] = file;
}
for (File file : nonCompiledSources.keySet()) {
allSources[i++] = file;
}
Arrays.sort(allSources);
Set<FqName> dirtyPackages = nonCompiledSources.values().stream().map(KtFile::getPackageFqName).collect(Collectors.toSet());
Map<FqName, byte[]> packageMetadata = new HashMap<>();
for (Map.Entry<String, byte[]> e : incrementalDataProvider.getPackageMetadata().entrySet()) {
FqName name = new FqName(e.getKey());
if (!dirtyPackages.contains(name)) {
packageMetadata.put(name, e.getValue());
}
}
List<TranslationUnit> translationUnits = new ArrayList<>();
for (i = 0; i < allSources.length; i++) {
KtFile nonCompiled = nonCompiledSources.get(allSources[i]);
if (nonCompiled != null) {
translationUnits.add(new TranslationUnit.SourceFile(nonCompiled));
}
else {
TranslationResultValue translatedValue = compiledParts.get(allSources[i]);
translationUnits.add(new TranslationUnit.BinaryAst(translatedValue.getBinaryAst(), translatedValue.getInlineData()));
}
}
return translator.translateUnits(reporter, translationUnits, mainCallParameters, jsAnalysisResult, packageMetadata);
}
CollectionsKt.sortBy(allKotlinFiles, ktFile -> VfsUtilCore.virtualToIoFile(ktFile.getVirtualFile()));
return translator.translate(reporter, allKotlinFiles, mainCallParameters, jsAnalysisResult);
}
@NotNull
@Override
protected ExitCode doExecute(
@@ -174,228 +104,13 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
) {
MessageCollector messageCollector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY);
ExitCode exitCode = OK;
boolean useFir = Boolean.TRUE.equals(configuration.get(CommonConfigurationKeys.USE_FIR));
if (K2JSCompilerArgumentsKt.isIrBackendEnabled(arguments) || useFir) {
exitCode = getIrCompiler().doExecute(arguments, configuration.copy(), rootDisposable, paths);
}
if (K2JSCompilerArgumentsKt.isPreIrBackendDisabled(arguments) || useFir) {
return exitCode;
return getIrCompiler().doExecute(arguments, configuration.copy(), rootDisposable, paths);
}
LanguageVersionSettings languageVersionSettings = CommonConfigurationKeysKt.getLanguageVersionSettings(configuration);
if (!arguments.getForceDeprecatedLegacyCompilerUsage() && languageVersionSettings.getLanguageVersion().compareTo(LanguageVersion.KOTLIN_1_9) >= 0) {
messageCollector.report(ERROR, "Old Kotlin/JS compiler is no longer supported. Please migrate to the new JS IR backend", null);
return COMPILATION_ERROR;
}
if (arguments.getFreeArgs().isEmpty() && (!incrementalCompilationIsEnabledForJs(arguments))) {
if (arguments.getVersion()) {
return OK;
}
messageCollector.report(ERROR, "Specify at least one source file or directory", null);
return COMPILATION_ERROR;
}
ExitCode pluginLoadResult = loadPlugins(paths, arguments, configuration);
if (pluginLoadResult != ExitCode.OK) return pluginLoadResult;
configuration.put(JSConfigurationKeys.LIBRARIES, configureLibraries(arguments, paths, messageCollector));
String[] commonSourcesArray = arguments.getCommonSources();
Set<String> commonSources = commonSourcesArray == null ? Collections.emptySet() : SetsKt.setOf(commonSourcesArray);
for (String arg : arguments.getFreeArgs()) {
ContentRootsKt.addKotlinSourceRoot(configuration, arg, commonSources.contains(arg));
}
KotlinCoreEnvironment environmentForJS =
KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.JS_CONFIG_FILES);
Project project = environmentForJS.getProject();
List<KtFile> sourcesFiles = environmentForJS.getSourceFiles();
environmentForJS.getConfiguration().put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.getAllowKotlinPackage());
environmentForJS.getConfiguration().put(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME, arguments.getRenderInternalDiagnosticNames());
if (!HelpersKt.checkKotlinPackageUsageForPsi(environmentForJS.getConfiguration(), sourcesFiles)) return ExitCode.COMPILATION_ERROR;
if (arguments.getOutputFile() == null) {
messageCollector.report(ERROR, "Specify output file via -output", null);
return ExitCode.COMPILATION_ERROR;
}
if (messageCollector.hasErrors()) {
return ExitCode.COMPILATION_ERROR;
}
if (sourcesFiles.isEmpty() && !incrementalCompilationIsEnabledForJs(arguments)) {
messageCollector.report(ERROR, "No source files", null);
return COMPILATION_ERROR;
}
if (arguments.getVerbose()) {
reportCompiledSourcesList(messageCollector, sourcesFiles);
}
File outputFile = new File(arguments.getOutputFile());
configuration.put(CommonConfigurationKeys.MODULE_NAME, FileUtil.getNameWithoutExtension(outputFile));
JsConfig config = new JsConfig(project, configuration, CompilerEnvironment.INSTANCE);
JsConfig.Reporter reporter = new JsConfig.Reporter() {
@Override
public void error(@NotNull String message) {
messageCollector.report(ERROR, message, null);
}
@Override
public void warning(@NotNull String message) {
messageCollector.report(STRONG_WARNING, message, null);
}
};
if (config.checkLibFilesAndReportErrors(reporter)) {
return COMPILATION_ERROR;
}
AnalysisResult analysisResult;
do {
AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(
messageCollector,
CommonConfigurationKeysKt.getLanguageVersionSettings(configuration),
configuration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME)
);
List<KtFile> sources = environmentForJS.getSourceFiles();
analyzerWithCompilerReport.analyzeAndReport(sourcesFiles, () -> TopDownAnalyzerFacadeForJS.analyzeFiles(sources, config));
if (analyzerWithCompilerReport.hasErrors()) {
return COMPILATION_ERROR;
}
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled();
analysisResult = analyzerWithCompilerReport.getAnalysisResult();
if (analysisResult instanceof JsAnalysisResult.RetryWithAdditionalRoots) {
environmentForJS.addKotlinSourceRoots(((JsAnalysisResult.RetryWithAdditionalRoots) analysisResult).getAdditionalKotlinRoots());
}
} while(analysisResult instanceof JsAnalysisResult.RetryWithAdditionalRoots);
if (!analysisResult.getShouldGenerateCode())
return OK;
assert analysisResult instanceof JsAnalysisResult : "analysisResult should be instance of JsAnalysisResult, but " + analysisResult;
JsAnalysisResult jsAnalysisResult = (JsAnalysisResult) analysisResult;
File outputPrefixFile = null;
if (arguments.getOutputPrefix() != null) {
outputPrefixFile = new File(arguments.getOutputPrefix());
if (!outputPrefixFile.exists()) {
messageCollector.report(ERROR, "Output prefix file '" + arguments.getOutputPrefix() + "' not found", null);
return ExitCode.COMPILATION_ERROR;
}
}
File outputPostfixFile = null;
if (arguments.getOutputPostfix() != null) {
outputPostfixFile = new File(arguments.getOutputPostfix());
if (!outputPostfixFile.exists()) {
messageCollector.report(ERROR, "Output postfix file '" + arguments.getOutputPostfix() + "' not found", null);
return ExitCode.COMPILATION_ERROR;
}
}
File outputDir = outputFile.getParentFile();
if (outputDir == null) {
outputDir = outputFile.getAbsoluteFile().getParentFile();
}
try {
config.getConfiguration().put(JSConfigurationKeys.OUTPUT_DIR, outputDir.getCanonicalFile());
}
catch (IOException e) {
messageCollector.report(ERROR, "Could not resolve output directory", null);
return ExitCode.COMPILATION_ERROR;
}
if (config.getConfiguration().getBoolean(JSConfigurationKeys.SOURCE_MAP)) {
checkDuplicateSourceFileNames(messageCollector, sourcesFiles, config);
}
MainCallParameters mainCallParameters = createMainCallParameters(arguments.getMain());
TranslationResult translationResult;
try {
translationResult = translate(reporter, sourcesFiles, jsAnalysisResult, mainCallParameters, config);
}
catch (Exception e) {
throw ExceptionUtilsKt.rethrow(e);
}
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled();
AnalyzerWithCompilerReport.Companion.reportDiagnostics(translationResult.getDiagnostics(), messageCollector, configuration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME));
if (translationResult instanceof TranslationResult.Fail) return ExitCode.COMPILATION_ERROR;
TranslationResult.SuccessBase successResult = (TranslationResult.SuccessBase) translationResult;
OutputFileCollection outputFiles = successResult.getOutputFiles(outputFile, outputPrefixFile, outputPostfixFile);
if (outputFile.isDirectory()) {
messageCollector.report(ERROR, "Cannot open output file '" + outputFile.getPath() + "': is a directory", null);
return ExitCode.COMPILATION_ERROR;
}
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled();
OutputUtilsKt.writeAll(outputFiles, outputDir, messageCollector,
configuration.getBoolean(CommonConfigurationKeys.REPORT_OUTPUT_FILES));
return OK;
}
private static void checkDuplicateSourceFileNames(
@NotNull MessageCollector log,
@NotNull List<KtFile> sourceFiles,
@NotNull JsConfig config
) {
if (config.getSourceMapRoots().isEmpty()) return;
SourceFilePathResolver pathResolver = SourceFilePathResolver.create(config);
Map<String, String> pathMap = new HashMap<>();
Set<String> duplicatePaths = new HashSet<>();
try {
for (KtFile sourceFile : sourceFiles) {
String path = sourceFile.getVirtualFile().getPath();
String relativePath = pathResolver.getPathRelativeToSourceRoots(new File(sourceFile.getVirtualFile().getPath()));
String existingPath = pathMap.get(relativePath);
if (existingPath != null) {
if (duplicatePaths.add(relativePath)) {
log.report(WARNING, "There are files with same path '" + relativePath + "', relative to source roots: " +
"'" + path + "' and '" + existingPath + "'. " +
"This will likely cause problems with debugger", null);
}
}
else {
pathMap.put(relativePath, path);
}
}
}
catch (IOException e) {
log.report(ERROR, "IO error occurred validating source path:\n" + ExceptionUtil.getThrowableText(e), null);
}
}
private static void reportCompiledSourcesList(@NotNull MessageCollector messageCollector, @NotNull List<KtFile> sourceFiles) {
Iterable<String> fileNames = CollectionsKt.map(sourceFiles, file -> {
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile != null) {
return MessageUtil.virtualFileToPath(virtualFile);
}
return file.getName() + " (no virtual file)";
});
messageCollector.report(LOGGING, "Compiling source files: " + StringsKt.join(fileNames, ", "), null);
messageCollector.report(ERROR, "Old Kotlin/JS compiler is no longer supported. Please migrate to the new JS IR backend", null);
return COMPILATION_ERROR;
}
@Override
@@ -406,122 +121,6 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
if (K2JSCompilerArgumentsKt.isIrBackendEnabled(arguments)) {
getIrCompiler().setupPlatformSpecificArgumentsAndServices(configuration, arguments, services);
}
if (K2JSCompilerArgumentsKt.isPreIrBackendDisabled(arguments)) {
return;
}
MessageCollector messageCollector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY);
if (arguments.getTarget() != null) {
assert "v5".equals(arguments.getTarget()) : "Unsupported ECMA version: " + arguments.getTarget();
}
configuration.put(JSConfigurationKeys.TARGET, EcmaVersion.defaultVersion());
if (arguments.getSourceMap()) {
configuration.put(JSConfigurationKeys.SOURCE_MAP, true);
if (arguments.getSourceMapPrefix() != null) {
configuration.put(JSConfigurationKeys.SOURCE_MAP_PREFIX, arguments.getSourceMapPrefix());
}
String sourceMapSourceRoots = arguments.getSourceMapBaseDirs();
if (sourceMapSourceRoots == null && StringUtil.isNotEmpty(arguments.getSourceMapPrefix())) {
sourceMapSourceRoots = calculateSourceMapSourceRoot(messageCollector, arguments);
}
if (sourceMapSourceRoots != null) {
List<String> sourceMapSourceRootList = StringUtil.split(sourceMapSourceRoots, File.pathSeparator);
configuration.put(JSConfigurationKeys.SOURCE_MAP_SOURCE_ROOTS, sourceMapSourceRootList);
}
}
else {
if (arguments.getSourceMapPrefix() != null) {
messageCollector.report(WARNING, "source-map-prefix argument has no effect without source map", null);
}
if (arguments.getSourceMapBaseDirs() != null) {
messageCollector.report(WARNING, "source-map-source-root argument has no effect without source map", null);
}
}
if (arguments.getMetaInfo()) {
configuration.put(JSConfigurationKeys.META_INFO, true);
}
configuration.put(JSConfigurationKeys.TYPED_ARRAYS_ENABLED, arguments.getTypedArrays());
configuration.put(JSConfigurationKeys.FRIEND_PATHS_DISABLED, arguments.getFriendModulesDisabled());
if (!arguments.getFriendModulesDisabled() && arguments.getFriendModules() != null) {
List<String> friendPaths = ArraysKt.filterNot(arguments.getFriendModules().split(File.pathSeparator), String::isEmpty);
configuration.put(JSConfigurationKeys.FRIEND_PATHS, friendPaths);
}
configuration.put(JSConfigurationKeys.METADATA_ONLY, arguments.getMetadataOnly());
String moduleKindName = arguments.getModuleKind();
ModuleKind moduleKind = moduleKindName != null ? moduleKindMap.get(moduleKindName) : ModuleKind.PLAIN;
if (moduleKind == null) {
messageCollector.report(
ERROR, "Unknown module kind: " + moduleKindName + ". Valid values are: plain, amd, commonjs, umd", null
);
moduleKind = ModuleKind.PLAIN;
}
configuration.put(JSConfigurationKeys.MODULE_KIND, moduleKind);
IncrementalDataProvider incrementalDataProvider = services.get(IncrementalDataProvider.class);
if (incrementalDataProvider != null) {
configuration.put(JSConfigurationKeys.INCREMENTAL_DATA_PROVIDER, incrementalDataProvider);
}
IncrementalResultsConsumer incrementalResultsConsumer = services.get(IncrementalResultsConsumer.class);
if (incrementalResultsConsumer != null) {
configuration.put(JSConfigurationKeys.INCREMENTAL_RESULTS_CONSUMER, incrementalResultsConsumer);
}
LookupTracker lookupTracker = services.get(LookupTracker.class);
if (lookupTracker != null) {
configuration.put(CommonConfigurationKeys.LOOKUP_TRACKER, lookupTracker);
}
ExpectActualTracker expectActualTracker = services.get(ExpectActualTracker.class);
if (expectActualTracker != null) {
configuration.put(CommonConfigurationKeys.EXPECT_ACTUAL_TRACKER, expectActualTracker);
}
String sourceMapEmbedContentString = arguments.getSourceMapEmbedSources();
SourceMapSourceEmbedding sourceMapContentEmbedding = sourceMapEmbedContentString != null ?
sourceMapContentEmbeddingMap.get(sourceMapEmbedContentString) :
SourceMapSourceEmbedding.INLINING;
if (sourceMapContentEmbedding == null) {
String message = "Unknown source map source embedding mode: " + sourceMapEmbedContentString + ". Valid values are: " +
StringUtil.join(sourceMapContentEmbeddingMap.keySet(), ", ");
messageCollector.report(ERROR, message, null);
sourceMapContentEmbedding = SourceMapSourceEmbedding.INLINING;
}
configuration.put(JSConfigurationKeys.SOURCE_MAP_EMBED_SOURCES, sourceMapContentEmbedding);
if (!arguments.getSourceMap() && sourceMapEmbedContentString != null) {
messageCollector.report(WARNING, "source-map-embed-sources argument has no effect without source map", null);
}
}
@NotNull
private static List<String> configureLibraries(
@NotNull K2JSCompilerArguments arguments,
@Nullable KotlinPaths paths,
@NotNull MessageCollector messageCollector
) {
List<String> libraries = new SmartList<>();
if (!arguments.getNoStdlib()) {
File stdlibJar = getLibraryFromHome(
paths, KotlinPaths::getJsStdLibKlibPath, PathUtil.JS_LIB_JAR_NAME, messageCollector, "'-no-stdlib'");
if (stdlibJar != null) {
libraries.add(stdlibJar.getAbsolutePath());
}
}
if (arguments.getLibraries() != null) {
libraries.addAll(ArraysKt.filterNot(arguments.getLibraries().split(File.pathSeparator), String::isEmpty));
}
return libraries;
}
@NotNull
@@ -581,15 +180,6 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
return performanceManager;
}
private static MainCallParameters createMainCallParameters(String main) {
if (K2JsArgumentConstants.NO_CALL.equals(main)) {
return MainCallParameters.noCall();
}
else {
return MainCallParameters.mainWithoutArguments();
}
}
@NotNull
@Override
public String executableScriptFileName() {
@@ -711,10 +711,6 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
}
}
if (arguments.metaInfo) {
configuration.put(JSConfigurationKeys.META_INFO, true)
}
configuration.put(JSConfigurationKeys.TYPED_ARRAYS_ENABLED, arguments.typedArrays)
configuration.put(JSConfigurationKeys.FRIEND_PATHS_DISABLED, arguments.friendModulesDisabled)
@@ -108,10 +108,7 @@ class IncrementalJsCompilerRunner(
IncrementalJsCachesManager(icContext, if (!args.isIrBackendEnabled()) JsSerializerProtocol else KlibMetadataSerializerProtocol, cacheDirectory)
override fun destinationDir(args: K2JSCompilerArguments): File {
return if (args.isIrBackendEnabled())
File(args.outputDir!!)
else
File(args.outputFile!!).parentFile
return File(args.outputDir!!)
}
override fun calculateSourcesToCompile(
-3
View File
@@ -6,8 +6,6 @@ where advanced options include:
-Xenable-extension-functions-in-externals
Enable extension function members in external interfaces.
-Xfake-override-validator Enable the IR fake override validator.
-Xforce-deprecated-legacy-compiler-usage
This flag is used only for our inner infrastructure. It will soon be removed, so it's no longer safe to use.
-Xfriend-modules=<path> Paths to friend modules.
-Xfriend-modules-disabled Disable internal declaration export.
-Xgenerate-dts Generate a TypeScript declaration .d.ts file alongside the JS file. This is available only in the IR backend.
@@ -43,7 +41,6 @@ where advanced options include:
-Xir-safe-external-boolean Wrap access to external 'Boolean' properties with an explicit conversion to 'Boolean'.
-Xir-safe-external-boolean-diagnostic={log|exception}
Enable runtime diagnostics when accessing external 'Boolean' properties.
-Xmetadata-only Generate .meta.js and .kjsm files only.
-Xoptimize-generated-js Perform additional optimizations on the generated JS code.
-Xpartial-linkage-loglevel={info|warning|error}
Define the compile-time log level for partial linkage.
-3
View File
@@ -6,11 +6,8 @@ where possible options include:
-module-kind {plain|amd|commonjs|umd|es}
The kind of JS module generated by the compiler.
-ir-output-name Base name of generated files.
-no-stdlib Don't automatically include the default Kotlin/JS stdlib in compilation dependencies.
-ir-output-dir <directory> Destination for generated files.
-output <filepath> Destination *.js file for the compilation result.
-output-postfix <path> Add the content of the specified file to the end of the output file.
-output-prefix <path> Add the content of the specified file to the beginning of the output file.
-source-map Generate a source map.
-source-map-base-dirs <path> Base directories for calculating relative paths to source files in the source map.
-source-map-embed-sources {always|never|inlining}
@@ -52,7 +52,7 @@ private fun generateRec(
withPrinterToFile(destDir.resolve(klassName + "CopyGenerated.kt")) {
println(
"""
@file:Suppress("unused", "DuplicatedCode")
@file:Suppress("unused", "DuplicatedCode", "DEPRECATION")
// DO NOT EDIT MANUALLY!
// Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt
@@ -1,4 +1,4 @@
@file:Suppress("unused", "DuplicatedCode")
@file:Suppress("unused", "DuplicatedCode", "DEPRECATION")
// DO NOT EDIT MANUALLY!
// Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt
@@ -1,4 +1,4 @@
@file:Suppress("unused", "DuplicatedCode")
@file:Suppress("unused", "DuplicatedCode", "DEPRECATION")
// DO NOT EDIT MANUALLY!
// Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt
@@ -3,6 +3,8 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("DEPRECATION")
package org.jetbrains.kotlin.config
import com.intellij.openapi.util.io.FileUtilRt
@@ -210,9 +210,7 @@ class CompilerArgumentsContentProspectorTest {
K2MetadataCompilerArguments::refinesPaths
)
private val k2JSCompilerArgumentsFlagProperties = commonCompilerArgumentsFlagProperties + listOf(
K2JSCompilerArguments::noStdlib,
K2JSCompilerArguments::sourceMap,
K2JSCompilerArguments::metaInfo,
K2JSCompilerArguments::irProduceKlibDir,
K2JSCompilerArguments::irProduceKlibFile,
K2JSCompilerArguments::irProduceJs,
@@ -225,7 +223,6 @@ class CompilerArgumentsContentProspectorTest {
K2JSCompilerArguments::useEsClasses,
K2JSCompilerArguments::typedArrays,
K2JSCompilerArguments::friendModulesDisabled,
K2JSCompilerArguments::metadataOnly,
K2JSCompilerArguments::fakeOverrideValidator,
K2JSCompilerArguments::wasm
)
@@ -239,8 +236,6 @@ class CompilerArgumentsContentProspectorTest {
K2JSCompilerArguments::target,
K2JSCompilerArguments::moduleKind,
K2JSCompilerArguments::main,
K2JSCompilerArguments::outputPrefix,
K2JSCompilerArguments::outputPostfix,
K2JSCompilerArguments::irModuleName,
K2JSCompilerArguments::includes,
K2JSCompilerArguments::friendModules,
@@ -280,11 +280,8 @@ public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinHierarchyD
public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptions : org/jetbrains/kotlin/gradle/dsl/KotlinCommonCompilerOptions {
public abstract fun getFriendModulesDisabled ()Lorg/gradle/api/provider/Property;
public abstract fun getMain ()Lorg/gradle/api/provider/Property;
public abstract fun getMetaInfo ()Lorg/gradle/api/provider/Property;
public abstract fun getModuleKind ()Lorg/gradle/api/provider/Property;
public abstract fun getModuleName ()Lorg/gradle/api/provider/Property;
public abstract fun getNoStdlib ()Lorg/gradle/api/provider/Property;
public abstract fun getOutputFile ()Lorg/gradle/api/provider/Property;
public abstract fun getSourceMap ()Lorg/gradle/api/provider/Property;
public abstract fun getSourceMapEmbedSources ()Lorg/gradle/api/provider/Property;
public abstract fun getSourceMapNamesPolicy ()Lorg/gradle/api/provider/Property;
@@ -325,12 +322,9 @@ public final class org/jetbrains/kotlin/gradle/dsl/KotlinJsDceOptions$DefaultImp
public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinJsOptions : org/jetbrains/kotlin/gradle/dsl/KotlinCommonOptions {
public abstract fun getFriendModulesDisabled ()Z
public abstract fun getMain ()Ljava/lang/String;
public abstract fun getMetaInfo ()Z
public abstract fun getModuleKind ()Ljava/lang/String;
public abstract fun getModuleName ()Ljava/lang/String;
public abstract fun getNoStdlib ()Z
public abstract fun getOptions ()Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptions;
public abstract fun getOutputFile ()Ljava/lang/String;
public abstract fun getSourceMap ()Z
public abstract fun getSourceMapEmbedSources ()Ljava/lang/String;
public abstract fun getSourceMapNamesPolicy ()Ljava/lang/String;
@@ -340,11 +334,8 @@ public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinJsOptions
public abstract fun getUseEsClasses ()Z
public abstract fun setFriendModulesDisabled (Z)V
public abstract fun setMain (Ljava/lang/String;)V
public abstract fun setMetaInfo (Z)V
public abstract fun setModuleKind (Ljava/lang/String;)V
public abstract fun setModuleName (Ljava/lang/String;)V
public abstract fun setNoStdlib (Z)V
public abstract fun setOutputFile (Ljava/lang/String;)V
public abstract fun setSourceMap (Z)V
public abstract fun setSourceMapEmbedSources (Ljava/lang/String;)V
public abstract fun setSourceMapNamesPolicy (Ljava/lang/String;)V
@@ -361,11 +352,8 @@ public final class org/jetbrains/kotlin/gradle/dsl/KotlinJsOptions$DefaultImpls
public static fun getFriendModulesDisabled (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Z
public static fun getLanguageVersion (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Ljava/lang/String;
public static fun getMain (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Ljava/lang/String;
public static fun getMetaInfo (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Z
public static fun getModuleKind (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Ljava/lang/String;
public static fun getModuleName (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Ljava/lang/String;
public static fun getNoStdlib (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Z
public static fun getOutputFile (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Ljava/lang/String;
public static fun getSourceMap (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Z
public static fun getSourceMapEmbedSources (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Ljava/lang/String;
public static fun getSourceMapNamesPolicy (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Ljava/lang/String;
@@ -382,11 +370,8 @@ public final class org/jetbrains/kotlin/gradle/dsl/KotlinJsOptions$DefaultImpls
public static fun setFriendModulesDisabled (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Z)V
public static fun setLanguageVersion (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Ljava/lang/String;)V
public static fun setMain (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Ljava/lang/String;)V
public static fun setMetaInfo (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Z)V
public static fun setModuleKind (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Ljava/lang/String;)V
public static fun setModuleName (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Ljava/lang/String;)V
public static fun setNoStdlib (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Z)V
public static fun setOutputFile (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Ljava/lang/String;)V
public static fun setSourceMap (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Z)V
public static fun setSourceMapEmbedSources (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Ljava/lang/String;)V
public static fun setSourceMapNamesPolicy (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Ljava/lang/String;)V
@@ -28,14 +28,6 @@ interface KotlinJsCompilerOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommon
@get:org.gradle.api.tasks.Input
val main: org.gradle.api.provider.Property<org.jetbrains.kotlin.gradle.dsl.JsMainFunctionExecutionMode>
/**
* Generate .meta.js and .kjsm files with metadata. Use this to create a library.
*
* Default value: true
*/
@get:org.gradle.api.tasks.Input
val metaInfo: org.gradle.api.provider.Property<kotlin.Boolean>
/**
* The kind of JS module generated by the compiler.
*
@@ -55,23 +47,6 @@ interface KotlinJsCompilerOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommon
@get:org.gradle.api.tasks.Input
val moduleName: org.gradle.api.provider.Property<kotlin.String>
/**
* Don't automatically include the default Kotlin/JS stdlib in compilation dependencies.
*
* Default value: true
*/
@get:org.gradle.api.tasks.Input
val noStdlib: org.gradle.api.provider.Property<kotlin.Boolean>
/**
* Destination *.js file for the compilation result.
*
* Default value: null
*/
@Deprecated(message = "Only for legacy backend. For IR backend please use task.destinationDirectory and moduleName", level = DeprecationLevel.WARNING)
@get:org.gradle.api.tasks.Internal
val outputFile: org.gradle.api.provider.Property<kotlin.String>
/**
* Generate a source map.
*
@@ -38,15 +38,6 @@ interface KotlinJsOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
get() = options.main.get().mainKotlinOption
set(value) = options.main.set(value.mainCompilerOption)
/**
* Generate .meta.js and .kjsm files with metadata. Use this to create a library.
*
* Default value: true
*/
var metaInfo: kotlin.Boolean
get() = options.metaInfo.get()
set(value) = options.metaInfo.set(value)
private val kotlin.String.moduleKindCompilerOption get() = org.jetbrains.kotlin.gradle.dsl.JsModuleKind.fromKind(this)
private val org.jetbrains.kotlin.gradle.dsl.JsModuleKind.moduleKindKotlinOption get() = this.kind
@@ -71,25 +62,6 @@ interface KotlinJsOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
get() = options.moduleName.orNull
set(value) = options.moduleName.set(value)
/**
* Don't automatically include the default Kotlin/JS stdlib in compilation dependencies.
*
* Default value: true
*/
var noStdlib: kotlin.Boolean
get() = options.noStdlib.get()
set(value) = options.noStdlib.set(value)
/**
* Destination *.js file for the compilation result.
*
* Default value: null
*/
@Deprecated(message = "Only for legacy backend. For IR backend please use task.destinationDirectory and moduleName", level = DeprecationLevel.WARNING)
var outputFile: kotlin.String?
get() = options.outputFile.orNull
set(value) = options.outputFile.set(value)
/**
* Generate a source map.
*
@@ -15,22 +15,12 @@ internal abstract class KotlinJsCompilerOptionsDefault @javax.inject.Inject cons
override val main: org.gradle.api.provider.Property<org.jetbrains.kotlin.gradle.dsl.JsMainFunctionExecutionMode> =
objectFactory.property(org.jetbrains.kotlin.gradle.dsl.JsMainFunctionExecutionMode::class.java).convention(org.jetbrains.kotlin.gradle.dsl.JsMainFunctionExecutionMode.CALL)
override val metaInfo: org.gradle.api.provider.Property<kotlin.Boolean> =
objectFactory.property(kotlin.Boolean::class.java).convention(true)
override val moduleKind: org.gradle.api.provider.Property<org.jetbrains.kotlin.gradle.dsl.JsModuleKind> =
objectFactory.property(org.jetbrains.kotlin.gradle.dsl.JsModuleKind::class.java).convention(org.jetbrains.kotlin.gradle.dsl.JsModuleKind.MODULE_PLAIN)
override val moduleName: org.gradle.api.provider.Property<kotlin.String> =
objectFactory.property(kotlin.String::class.java)
override val noStdlib: org.gradle.api.provider.Property<kotlin.Boolean> =
objectFactory.property(kotlin.Boolean::class.java).convention(true)
@Deprecated(message = "Only for legacy backend. For IR backend please use task.destinationDirectory and moduleName", level = DeprecationLevel.WARNING)
override val outputFile: org.gradle.api.provider.Property<kotlin.String> =
objectFactory.property(kotlin.String::class.java)
override val sourceMap: org.gradle.api.provider.Property<kotlin.Boolean> =
objectFactory.property(kotlin.Boolean::class.java).convention(false)
@@ -14,11 +14,8 @@ internal object KotlinJsCompilerOptionsHelper {
org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptionsHelper.fillCompilerArguments(from, args)
args.friendModulesDisabled = from.friendModulesDisabled.get()
args.main = from.main.get().mode
args.metaInfo = from.metaInfo.get()
args.moduleKind = from.moduleKind.get().kind
args.moduleName = from.moduleName.orNull
args.noStdlib = from.noStdlib.get()
args.outputFile = from.outputFile.orNull
args.sourceMap = from.sourceMap.get()
args.sourceMapEmbedSources = from.sourceMapEmbedSources.orNull?.mode
args.sourceMapNamesPolicy = from.sourceMapNamesPolicy.orNull?.policy
@@ -35,11 +32,8 @@ internal object KotlinJsCompilerOptionsHelper {
org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptionsHelper.syncOptionsAsConvention(from, into)
into.friendModulesDisabled.convention(from.friendModulesDisabled)
into.main.convention(from.main)
into.metaInfo.convention(from.metaInfo)
into.moduleKind.convention(from.moduleKind)
into.moduleName.convention(from.moduleName)
into.noStdlib.convention(from.noStdlib)
into.outputFile.convention(from.outputFile)
into.sourceMap.convention(from.sourceMap)
into.sourceMapEmbedSources.convention(from.sourceMapEmbedSources)
into.sourceMapNamesPolicy.convention(from.sourceMapNamesPolicy)
@@ -58,23 +58,10 @@ internal abstract class KotlinSourceSetProcessor<T : AbstractKotlinCompile<*>>(
val kotlinSourceDirectorySet = compilationInfo.tcs.compilation.defaultSourceSet.kotlin
kotlinSourceDirectorySet.destinationDirectory.value(defaultKotlinDestinationDir)
task.configure {
if (it is Kotlin2JsCompile) {
it.defaultDestinationDirectory.convention(kotlinSourceDirectorySet.destinationDirectory)
} else {
it.destinationDirectory.convention(kotlinSourceDirectorySet.destinationDirectory)
}
it.destinationDirectory.convention(kotlinSourceDirectorySet.destinationDirectory)
}
compilationInfo.classesDirs.from(kotlinSourceDirectorySet.destinationDirectory).builtBy(task)
if (compilationInfo.tcs.compilation.platformType == KotlinPlatformType.js) {
@Suppress("UNCHECKED_CAST")
kotlinSourceDirectorySet.compiledBy(
task as TaskProvider<Kotlin2JsCompile>,
Kotlin2JsCompile::defaultDestinationDirectory
)
(kotlinSourceDirectorySet.classesDirectory as Property<Directory>).set(task.flatMap { it.destinationDirectory })
} else {
kotlinSourceDirectorySet.compiledBy(task, AbstractKotlinCompile<*>::destinationDirectory)
}
kotlinSourceDirectorySet.compiledBy(task, AbstractKotlinCompile<*>::destinationDirectory)
if (compilationInfo.isMain) {
project.tasks.named(
compilationInfo.tcs.compilation.target.artifactsTaskName,
@@ -133,11 +120,7 @@ internal abstract class KotlinSourceSetProcessor<T : AbstractKotlinCompile<*>>(
protected fun applyStandardTaskConfiguration(taskConfiguration: AbstractKotlinCompileConfig<*>) {
taskConfiguration.configureTask {
it.description = taskDescription
if (it is Kotlin2JsCompile) {
it.defaultDestinationDirectory.convention(defaultKotlinDestinationDir)
} else {
it.destinationDirectory.convention(defaultKotlinDestinationDir)
}
it.destinationDirectory.convention(defaultKotlinDestinationDir)
it.libraries.from({ compilationInfo.compileDependencyFiles })
}
}
@@ -87,10 +87,9 @@ internal object CompilerArgumentMetrics : FusMetrics {
is K2JSCompilerArguments -> {
val args = K2JSCompilerArguments()
parseCommandLineArguments(argsArray.toList(), args)
if (!args.isPreIrBackendDisabled() || args.irProduceJs) {
metricsConsumer.report(BooleanMetrics.JS_SOURCE_MAP, args.sourceMap)
}
if (args.irProduceJs) {
metricsConsumer.report(BooleanMetrics.JS_SOURCE_MAP, args.sourceMap)
metricsConsumer.report(StringMetrics.JS_PROPERTY_LAZY_INITIALIZATION, args.irPropertyLazyInitialization.toString())
}
}
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.gradle.targets.js.ir.*
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
import org.jetbrains.kotlin.gradle.utils.klibModuleName
import org.jetbrains.kotlin.gradle.utils.providerWithLazyConvention
import java.io.File
internal typealias Kotlin2JsCompileConfig = BaseKotlin2JsCompileConfig<Kotlin2JsCompile>
@@ -37,26 +36,6 @@ internal open class BaseKotlin2JsCompileConfig<TASK : Kotlin2JsCompile>(
configureAdditionalFreeCompilerArguments(task, compilation)
task.destinationDirectory
.convention(
project.objects.directoryProperty().fileProvider(
task.defaultDestinationDirectory.map {
val freeArgs = task.enhancedFreeCompilerArgs.get()
@Suppress("DEPRECATION")
if (task.compilerOptions.outputFile.orNull != null) {
if (freeArgs.contains(PRODUCE_UNZIPPED_KLIB)) {
val file = File(task.compilerOptions.outputFile.get())
if (file.extension == "") file else file.parentFile
} else {
File(task.compilerOptions.outputFile.get()).parentFile
}
} else {
it.asFile
}
}
)
)
task.libraryFilterCacheService.value(libraryFilterCachingService).disallowChanges()
task.incrementalModuleInfoProvider.value(incrementalModuleInfoProvider).disallowChanges()
}