[Gradle] KotlinJsIrLink: Handle KotlinBuildStatsService invocation outside of creating compiler args
KTIJ-24976
This commit is contained in:
committed by
Space Team
parent
fc05d001c6
commit
ca84505376
+15
-15
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
|||||||
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
|
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
|
||||||
import org.jetbrains.kotlin.compilerRunner.ArgumentUtils
|
import org.jetbrains.kotlin.compilerRunner.ArgumentUtils
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompilerOptionsDefault
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompilerOptionsDefault
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.ContributeCompilerArgumentsContext
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.ContributeCompilerArgumentsContext
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||||
@@ -98,20 +97,6 @@ abstract class KotlinJsIrLink @Inject constructor(
|
|||||||
super.contributeAdditionalCompilerArguments(context)
|
super.contributeAdditionalCompilerArguments(context)
|
||||||
|
|
||||||
context.primitive { args ->
|
context.primitive { args ->
|
||||||
// TODO Ilya Goncharov: This should not be part of creating compiler arguments;
|
|
||||||
KotlinBuildStatsService.applyIfInitialised {
|
|
||||||
it.report(BooleanMetrics.JS_IR_INCREMENTAL, this.incrementalJsIr)
|
|
||||||
val newArgs = K2JSCompilerArguments()
|
|
||||||
parseCommandLineArguments(ArgumentUtils.convertArgumentsToStringList(args), newArgs)
|
|
||||||
it.report(
|
|
||||||
StringMetrics.JS_OUTPUT_GRANULARITY,
|
|
||||||
if (newArgs.irPerModule)
|
|
||||||
KotlinJsIrOutputGranularity.PER_MODULE.name.toLowerCaseAsciiOnly()
|
|
||||||
else
|
|
||||||
KotlinJsIrOutputGranularity.WHOLE_PROGRAM.name.toLowerCaseAsciiOnly()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// moduleName can start with @ for group of NPM packages
|
// moduleName can start with @ for group of NPM packages
|
||||||
// but args parsing @ as start of argfile
|
// but args parsing @ as start of argfile
|
||||||
// so WA we provide moduleName as one parameter
|
// so WA we provide moduleName as one parameter
|
||||||
@@ -128,6 +113,21 @@ abstract class KotlinJsIrLink @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun processArgsBeforeCompile(args: K2JSCompilerArguments) {
|
||||||
|
KotlinBuildStatsService.applyIfInitialised {
|
||||||
|
it.report(BooleanMetrics.JS_IR_INCREMENTAL, incrementalJsIr)
|
||||||
|
val newArgs = K2JSCompilerArguments()
|
||||||
|
parseCommandLineArguments(ArgumentUtils.convertArgumentsToStringList(args), newArgs)
|
||||||
|
it.report(
|
||||||
|
StringMetrics.JS_OUTPUT_GRANULARITY,
|
||||||
|
if (newArgs.irPerModule)
|
||||||
|
KotlinJsIrOutputGranularity.PER_MODULE.name.toLowerCaseAsciiOnly()
|
||||||
|
else
|
||||||
|
KotlinJsIrOutputGranularity.WHOLE_PROGRAM.name.toLowerCaseAsciiOnly()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun usingCacheDirectory() =
|
private fun usingCacheDirectory() =
|
||||||
incrementalJsIr && modeProperty.get() == DEVELOPMENT
|
incrementalJsIr && modeProperty.get() == DEVELOPMENT
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -286,6 +286,8 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
|||||||
override val incrementalProps: List<FileCollection>
|
override val incrementalProps: List<FileCollection>
|
||||||
get() = super.incrementalProps + listOf(friendDependencies)
|
get() = super.incrementalProps + listOf(friendDependencies)
|
||||||
|
|
||||||
|
protected open fun processArgsBeforeCompile(args: K2JSCompilerArguments) = Unit
|
||||||
|
|
||||||
protected open fun contributeAdditionalCompilerArguments(context: ContributeCompilerArgumentsContext<K2JSCompilerArguments>) = Unit
|
protected open fun contributeAdditionalCompilerArguments(context: ContributeCompilerArgumentsContext<K2JSCompilerArguments>) = Unit
|
||||||
|
|
||||||
override fun callCompilerAsync(
|
override fun callCompilerAsync(
|
||||||
@@ -339,6 +341,7 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
|||||||
reportingSettings = reportingSettings(),
|
reportingSettings = reportingSettings(),
|
||||||
incrementalCompilationEnvironment = icEnv
|
incrementalCompilationEnvironment = icEnv
|
||||||
)
|
)
|
||||||
|
processArgsBeforeCompile(args)
|
||||||
compilerRunner.runJsCompilerAsync(
|
compilerRunner.runJsCompilerAsync(
|
||||||
args,
|
args,
|
||||||
environment,
|
environment,
|
||||||
|
|||||||
Reference in New Issue
Block a user