Move CompilerMode and TargetPlatform to CompilationOptions
This commit is contained in:
+8
-2
@@ -19,7 +19,11 @@ package org.jetbrains.kotlin.daemon.common
|
||||
import java.io.File
|
||||
import java.io.Serializable
|
||||
|
||||
open class CompilationOptions(val reportingFilters: List<ReportingFilter>) : Serializable {
|
||||
open class CompilationOptions(
|
||||
val compilerMode: CompileService.CompilerMode,
|
||||
val targetPlatform: CompileService.TargetPlatform,
|
||||
val reportingFilters: List<ReportingFilter>
|
||||
) : Serializable {
|
||||
companion object {
|
||||
const val serialVersionUID: Long = 0
|
||||
}
|
||||
@@ -32,8 +36,10 @@ class IncrementalCompilationOptions(
|
||||
val workingDir: File,
|
||||
val customCacheVersionFileName: String,
|
||||
val customCacheVersion: Int,
|
||||
compilerMode: CompileService.CompilerMode,
|
||||
targetPlatform: CompileService.TargetPlatform,
|
||||
reportingFilters: List<ReportingFilter>
|
||||
) : CompilationOptions(reportingFilters) {
|
||||
) : CompilationOptions(compilerMode, targetPlatform, reportingFilters) {
|
||||
companion object {
|
||||
const val serialVersionUID: Long = 0
|
||||
}
|
||||
|
||||
@@ -136,8 +136,6 @@ interface CompileService : Remote {
|
||||
@Throws(RemoteException::class)
|
||||
fun compile(
|
||||
sessionId: Int,
|
||||
compilerMode: CompilerMode,
|
||||
targetPlatform: TargetPlatform,
|
||||
compilerArguments: CommonCompilerArguments,
|
||||
compilationOptions: CompilationOptions,
|
||||
servicesFacade: CompilerServicesFacadeBase
|
||||
|
||||
@@ -323,14 +323,14 @@ class CompileServiceImpl(
|
||||
|
||||
override fun compile(
|
||||
sessionId: Int,
|
||||
compilerMode: CompileService.CompilerMode,
|
||||
targetPlatform: CompileService.TargetPlatform,
|
||||
compilerArguments: CommonCompilerArguments,
|
||||
compilationOptions: CompilationOptions,
|
||||
servicesFacade: CompilerServicesFacadeBase
|
||||
): CompileService.CallResult<Int> {
|
||||
val messageCollector = CompileServicesFacadeMessageCollector(servicesFacade, compilationOptions)
|
||||
val serviceReporter = CompileServiceReporterImpl(servicesFacade, compilationOptions)
|
||||
val compilerMode = compilationOptions.compilerMode
|
||||
val targetPlatform = compilationOptions.targetPlatform
|
||||
|
||||
return when (compilerMode) {
|
||||
CompileService.CompilerMode.JPS_COMPILER -> {
|
||||
@@ -338,7 +338,7 @@ class CompileServiceImpl(
|
||||
|
||||
doCompile(sessionId, serviceReporter, tracer = null) { eventManger, profiler ->
|
||||
val services = createCompileServices(jpsServicesFacade, eventManger, profiler)
|
||||
execCompiler(targetPlatform, services, compilerArguments, messageCollector)
|
||||
execCompiler(compilationOptions.targetPlatform, services, compilerArguments, messageCollector)
|
||||
}
|
||||
}
|
||||
CompileService.CompilerMode.NON_INCREMENTAL_COMPILER -> {
|
||||
|
||||
@@ -99,13 +99,10 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
||||
}
|
||||
|
||||
val res = withDaemon(environment, retryOnConnectionError = true) { daemon, sessionId ->
|
||||
daemon.compile(
|
||||
sessionId,
|
||||
CompileService.CompilerMode.JPS_COMPILER,
|
||||
targetPlatform,
|
||||
compilerArgs,
|
||||
CompilationOptions(reportingFilters = getReportingFilters(compilerArgs.verbose)),
|
||||
JpsCompilerServicesFacadeImpl(environment))
|
||||
val options = CompilationOptions(CompileService.CompilerMode.JPS_COMPILER,
|
||||
targetPlatform,
|
||||
reportingFilters = getReportingFilters(compilerArgs.verbose))
|
||||
daemon.compile(sessionId, compilerArgs, options, JpsCompilerServicesFacadeImpl(environment))
|
||||
}
|
||||
|
||||
return res?.get()?.let { exitCodeFromProcessExitCode(it) }
|
||||
|
||||
+13
-16
@@ -162,15 +162,14 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
||||
K2METADATA_COMPILER -> CompileService.TargetPlatform.METADATA
|
||||
else -> throw IllegalArgumentException("Unknown compiler type $compilerClassName")
|
||||
}
|
||||
val compilationOptions = CompilationOptions(
|
||||
reportingFilters = getNonIncrementalReportingFilters(environment.compilerArgs.verbose),
|
||||
compilerMode = CompileService.CompilerMode.NON_INCREMENTAL_COMPILER,
|
||||
targetPlatform = targetPlatform)
|
||||
val servicesFacade = GradleCompilerServicesFacadeImpl(project, environment.messageCollector)
|
||||
|
||||
val res = withDaemon(environment, retryOnConnectionError = true) { daemon, sessionId ->
|
||||
daemon.compile(
|
||||
sessionId,
|
||||
CompileService.CompilerMode.NON_INCREMENTAL_COMPILER,
|
||||
targetPlatform,
|
||||
environment.compilerArgs,
|
||||
CompilationOptions(reportingFilters = getNonIncrementalReportingFilters(environment.compilerArgs.verbose)),
|
||||
GradleCompilerServicesFacadeImpl(project, environment.messageCollector))
|
||||
daemon.compile(sessionId, environment.compilerArgs, compilationOptions, servicesFacade)
|
||||
}
|
||||
|
||||
val exitCode = res?.get()?.let { exitCodeFromProcessExitCode(it) }
|
||||
@@ -184,7 +183,7 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
||||
private fun incrementalCompilationWithDaemon(environment: GradleIncrementalCompilerEnvironment): ExitCode? {
|
||||
val knownChangedFiles = environment.changedFiles as? ChangedFiles.Known
|
||||
|
||||
val additionalCompilerArguments = IncrementalCompilationOptions(
|
||||
val compilationOptions = IncrementalCompilationOptions(
|
||||
areFileChangesKnown = knownChangedFiles != null,
|
||||
modifiedFiles = knownChangedFiles?.modified,
|
||||
deletedFiles = knownChangedFiles?.removed,
|
||||
@@ -192,16 +191,14 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
||||
customCacheVersion = GRADLE_CACHE_VERSION,
|
||||
customCacheVersionFileName = GRADLE_CACHE_VERSION_FILE_NAME,
|
||||
reportingFilters = getNonIncrementalReportingFilters(environment.compilerArgs.verbose) +
|
||||
getIncrementalReportingFilters(environment.compilerArgs.verbose)
|
||||
getIncrementalReportingFilters(environment.compilerArgs.verbose),
|
||||
compilerMode = CompileService.CompilerMode.INCREMENTAL_COMPILER,
|
||||
targetPlatform = CompileService.TargetPlatform.JVM
|
||||
)
|
||||
val servicesFacade = GradleIncrementalCompilerServicesFacadeImpl(project, environment)
|
||||
|
||||
val res = withDaemon(environment, retryOnConnectionError = true) { daemon, sessionId ->
|
||||
daemon.compile(
|
||||
sessionId,
|
||||
CompileService.CompilerMode.INCREMENTAL_COMPILER,
|
||||
CompileService.TargetPlatform.JVM,
|
||||
environment.compilerArgs,
|
||||
additionalCompilerArguments,
|
||||
GradleIncrementalCompilerServicesFacadeImpl(project, environment))
|
||||
daemon.compile(sessionId, environment.compilerArgs, compilationOptions, servicesFacade)
|
||||
}
|
||||
|
||||
val exitCode = res?.get()?.let { exitCodeFromProcessExitCode(it) }
|
||||
|
||||
Reference in New Issue
Block a user