Fix the build
This commit is contained in:
+4
-4
@@ -23,10 +23,10 @@ import java.lang.reflect.Modifier
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
fun <A : CommonCompilerArguments> parseArguments(args: Array<String>, arguments: A) {
|
fun <A : CommonCompilerArguments> parseArguments(args: Array<String>, arguments: A) {
|
||||||
val unparsedArgs = Args.parse(arguments, args, false).partition { it.startsWith("-X") }
|
val unparsedArgs = Args.parse(arguments, args, false)
|
||||||
|
val (unknownExtraArgs, unknownArgs) = unparsedArgs.partition { it.startsWith("-X") }
|
||||||
arguments.unknownExtraFlags = unparsedArgs.first
|
arguments.unknownExtraFlags = unknownExtraArgs
|
||||||
arguments.freeArgs = unparsedArgs.second
|
arguments.freeArgs = unknownArgs
|
||||||
|
|
||||||
for (argument in arguments.freeArgs) {
|
for (argument in arguments.freeArgs) {
|
||||||
if (argument.startsWith("-")) {
|
if (argument.startsWith("-")) {
|
||||||
|
|||||||
+1
-1
@@ -132,7 +132,7 @@ interface CompileService : Remote {
|
|||||||
@Throws(RemoteException::class)
|
@Throws(RemoteException::class)
|
||||||
fun compile(
|
fun compile(
|
||||||
sessionId: Int,
|
sessionId: Int,
|
||||||
compilerArguments: CommonCompilerArguments,
|
compilerArguments: Array<String>,
|
||||||
compilationOptions: CompilationOptions,
|
compilationOptions: CompilationOptions,
|
||||||
servicesFacade: CompilerServicesFacadeBase,
|
servicesFacade: CompilerServicesFacadeBase,
|
||||||
compilationResultsSink: CompilationResultsSink?
|
compilationResultsSink: CompilationResultsSink?
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ import com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem
|
|||||||
import org.jetbrains.kotlin.cli.common.CLICompiler
|
import org.jetbrains.kotlin.cli.common.CLICompiler
|
||||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||||
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
|
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.*
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
|
||||||
import org.jetbrains.kotlin.cli.common.messages.*
|
import org.jetbrains.kotlin.cli.common.messages.*
|
||||||
import org.jetbrains.kotlin.cli.common.modules.ModuleXmlParser
|
import org.jetbrains.kotlin.cli.common.modules.ModuleXmlParser
|
||||||
import org.jetbrains.kotlin.cli.common.repl.ReplCheckResult
|
import org.jetbrains.kotlin.cli.common.repl.ReplCheckResult
|
||||||
@@ -46,10 +43,8 @@ import org.jetbrains.kotlin.incremental.*
|
|||||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
|
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
|
||||||
import org.jetbrains.kotlin.progress.CompilationCanceledStatus
|
import org.jetbrains.kotlin.progress.CompilationCanceledStatus
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||||
import java.io.BufferedOutputStream
|
import org.jetbrains.kotlin.utils.stackTraceStr
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.*
|
||||||
import java.io.File
|
|
||||||
import java.io.PrintStream
|
|
||||||
import java.rmi.NoSuchObjectException
|
import java.rmi.NoSuchObjectException
|
||||||
import java.rmi.registry.Registry
|
import java.rmi.registry.Registry
|
||||||
import java.rmi.server.UnicastRemoteObject
|
import java.rmi.server.UnicastRemoteObject
|
||||||
@@ -321,7 +316,7 @@ class CompileServiceImpl(
|
|||||||
|
|
||||||
override fun compile(
|
override fun compile(
|
||||||
sessionId: Int,
|
sessionId: Int,
|
||||||
compilerArguments: CommonCompilerArguments,
|
compilerArguments: Array<String>,
|
||||||
compilationOptions: CompilationOptions,
|
compilationOptions: CompilationOptions,
|
||||||
servicesFacade: CompilerServicesFacadeBase,
|
servicesFacade: CompilerServicesFacadeBase,
|
||||||
compilationResultsSink: CompilationResultsSink?
|
compilationResultsSink: CompilationResultsSink?
|
||||||
@@ -330,6 +325,17 @@ class CompileServiceImpl(
|
|||||||
val daemonReporter = DaemonMessageReporter(servicesFacade, compilationOptions)
|
val daemonReporter = DaemonMessageReporter(servicesFacade, compilationOptions)
|
||||||
val compilerMode = compilationOptions.compilerMode
|
val compilerMode = compilationOptions.compilerMode
|
||||||
val targetPlatform = compilationOptions.targetPlatform
|
val targetPlatform = compilationOptions.targetPlatform
|
||||||
|
val k2PlatformArgs = try {
|
||||||
|
when (targetPlatform) {
|
||||||
|
CompileService.TargetPlatform.JVM -> K2JVMCompilerArguments().apply { K2JVMCompiler().parseArguments(compilerArguments, this) }
|
||||||
|
CompileService.TargetPlatform.JS -> K2JSCompilerArguments().apply { K2JSCompiler().parseArguments(compilerArguments, this) }
|
||||||
|
CompileService.TargetPlatform.METADATA -> K2MetadataCompilerArguments().apply { K2MetadataCompiler().parseArguments(compilerArguments, this) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e: IllegalArgumentException) {
|
||||||
|
messageCollector.report(CompilerMessageSeverity.EXCEPTION, e.stackTraceStr, CompilerMessageLocation.NO_LOCATION)
|
||||||
|
return CompileService.CallResult.Error("Could not deserialize compiler arguments")
|
||||||
|
}
|
||||||
|
|
||||||
return when (compilerMode) {
|
return when (compilerMode) {
|
||||||
CompilerMode.JPS_COMPILER -> {
|
CompilerMode.JPS_COMPILER -> {
|
||||||
@@ -337,12 +343,12 @@ class CompileServiceImpl(
|
|||||||
|
|
||||||
doCompile(sessionId, daemonReporter, tracer = null) { eventManger, profiler ->
|
doCompile(sessionId, daemonReporter, tracer = null) { eventManger, profiler ->
|
||||||
val services = createCompileServices(jpsServicesFacade, eventManger, profiler)
|
val services = createCompileServices(jpsServicesFacade, eventManger, profiler)
|
||||||
execCompiler(compilationOptions.targetPlatform, services, compilerArguments, messageCollector)
|
execCompiler(compilationOptions.targetPlatform, services, k2PlatformArgs, messageCollector)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CompilerMode.NON_INCREMENTAL_COMPILER -> {
|
CompilerMode.NON_INCREMENTAL_COMPILER -> {
|
||||||
doCompile(sessionId, daemonReporter, tracer = null) { eventManger, profiler ->
|
doCompile(sessionId, daemonReporter, tracer = null) { eventManger, profiler ->
|
||||||
execCompiler(targetPlatform, Services.EMPTY, compilerArguments, messageCollector)
|
execCompiler(targetPlatform, Services.EMPTY, k2PlatformArgs, messageCollector)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CompilerMode.INCREMENTAL_COMPILER -> {
|
CompilerMode.INCREMENTAL_COMPILER -> {
|
||||||
@@ -350,7 +356,7 @@ class CompileServiceImpl(
|
|||||||
throw IllegalStateException("Incremental compilation is not supported for target platform: $targetPlatform")
|
throw IllegalStateException("Incremental compilation is not supported for target platform: $targetPlatform")
|
||||||
}
|
}
|
||||||
|
|
||||||
val k2jvmArgs = compilerArguments as K2JVMCompilerArguments
|
val k2jvmArgs = k2PlatformArgs as K2JVMCompilerArguments
|
||||||
val gradleIncrementalArgs = compilationOptions as IncrementalCompilationOptions
|
val gradleIncrementalArgs = compilationOptions as IncrementalCompilationOptions
|
||||||
val gradleIncrementalServicesFacade = servicesFacade as IncrementalCompilerServicesFacade
|
val gradleIncrementalServicesFacade = servicesFacade as IncrementalCompilerServicesFacade
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.utils
|
||||||
|
|
||||||
|
import java.io.PrintWriter
|
||||||
|
import java.io.StringWriter
|
||||||
|
|
||||||
|
val Exception.stackTraceStr: String
|
||||||
|
get() {
|
||||||
|
val sw = StringWriter()
|
||||||
|
PrintWriter(sw).use { printStackTrace(it) }
|
||||||
|
return sw.toString()
|
||||||
|
}
|
||||||
@@ -21,5 +21,6 @@
|
|||||||
<orderEntry type="module" module-name="daemon-common" />
|
<orderEntry type="module" module-name="daemon-common" />
|
||||||
<orderEntry type="library" scope="TEST" name="kotlin-test" level="project" />
|
<orderEntry type="library" scope="TEST" name="kotlin-test" level="project" />
|
||||||
<orderEntry type="module" module-name="daemon" />
|
<orderEntry type="module" module-name="daemon" />
|
||||||
|
<orderEntry type="library" name="cli-parser" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
@@ -33,7 +33,20 @@ import java.rmi.server.UnicastRemoteObject
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
||||||
override val log: KotlinLogger = JpsKotlinLogger(KotlinBuilder.LOG)
|
override val log: KotlinLogger = JpsKotlinLogger(KotlinBuilder.LOG)
|
||||||
|
|
||||||
|
private var compilerSettings: CompilerSettings? = null
|
||||||
|
|
||||||
|
private inline fun withCompilerSettings(settings: CompilerSettings, fn: ()->Unit) {
|
||||||
|
val old = compilerSettings
|
||||||
|
try {
|
||||||
|
compilerSettings = settings
|
||||||
|
fn()
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
compilerSettings = old
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private @Volatile var jpsDaemonConnection: DaemonConnection? = null
|
private @Volatile var jpsDaemonConnection: DaemonConnection? = null
|
||||||
@@ -48,10 +61,9 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
|||||||
) {
|
) {
|
||||||
val arguments = mergeBeans(commonArguments, k2jvmArguments)
|
val arguments = mergeBeans(commonArguments, k2jvmArguments)
|
||||||
setupK2JvmArguments(moduleFile, arguments)
|
setupK2JvmArguments(moduleFile, arguments)
|
||||||
val additionalArguments = compilerSettings.additionalArguments.split(" ").toTypedArray()
|
withCompilerSettings(compilerSettings) {
|
||||||
parseArguments(additionalArguments, arguments)
|
runCompiler(K2JVM_COMPILER, arguments, environment)
|
||||||
|
}
|
||||||
runCompiler(K2JVM_COMPILER, arguments, environment)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun runK2JsCompiler(
|
fun runK2JsCompiler(
|
||||||
@@ -65,10 +77,9 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
|||||||
) {
|
) {
|
||||||
val arguments = mergeBeans(commonArguments, k2jsArguments)
|
val arguments = mergeBeans(commonArguments, k2jsArguments)
|
||||||
setupK2JsArguments(outputFile, sourceFiles, libraryFiles, arguments)
|
setupK2JsArguments(outputFile, sourceFiles, libraryFiles, arguments)
|
||||||
val additionalArguments = compilerSettings.additionalArguments.split(" ").toTypedArray()
|
withCompilerSettings(compilerSettings) {
|
||||||
parseArguments(additionalArguments, arguments)
|
runCompiler(K2JS_COMPILER, arguments, environment)
|
||||||
|
}
|
||||||
runCompiler(K2JS_COMPILER, arguments, environment)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun compileWithDaemonOrFallback(
|
override fun compileWithDaemonOrFallback(
|
||||||
@@ -104,7 +115,9 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
|||||||
val compilerMode = CompilerMode.JPS_COMPILER
|
val compilerMode = CompilerMode.JPS_COMPILER
|
||||||
val verbose = compilerArgs.verbose
|
val verbose = compilerArgs.verbose
|
||||||
val options = CompilationOptions(compilerMode, targetPlatform, reportCategories(verbose), reportSeverity(verbose), requestedCompilationResults = emptyArray())
|
val options = CompilationOptions(compilerMode, targetPlatform, reportCategories(verbose), reportSeverity(verbose), requestedCompilationResults = emptyArray())
|
||||||
daemon.compile(sessionId, compilerArgs, options, JpsCompilerServicesFacadeImpl(environment), null)
|
val allArgs = ArgumentUtils.convertArgumentsToStringList(compilerArgs) +
|
||||||
|
(compilerSettings?.additionalArguments?.split(" ") ?: emptyList())
|
||||||
|
daemon.compile(sessionId, allArgs.toTypedArray(), options, JpsCompilerServicesFacadeImpl(environment), null)
|
||||||
}
|
}
|
||||||
|
|
||||||
return res?.get()?.let { exitCodeFromProcessExitCode(it) }
|
return res?.get()?.let { exitCodeFromProcessExitCode(it) }
|
||||||
|
|||||||
+4
-2
@@ -172,7 +172,8 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
|||||||
val servicesFacade = GradleCompilerServicesFacadeImpl(project, environment.messageCollector)
|
val servicesFacade = GradleCompilerServicesFacadeImpl(project, environment.messageCollector)
|
||||||
|
|
||||||
val res = withDaemon(environment, retryOnConnectionError = true) { daemon, sessionId ->
|
val res = withDaemon(environment, retryOnConnectionError = true) { daemon, sessionId ->
|
||||||
daemon.compile(sessionId, environment.compilerArgs, compilationOptions, servicesFacade, compilationResultsSink = null)
|
val argsArray = ArgumentUtils.convertArgumentsToStringList(environment.compilerArgs).toTypedArray()
|
||||||
|
daemon.compile(sessionId, argsArray, compilationOptions, servicesFacade, compilationResultsSink = null)
|
||||||
}
|
}
|
||||||
|
|
||||||
val exitCode = res?.get()?.let { exitCodeFromProcessExitCode(it) }
|
val exitCode = res?.get()?.let { exitCodeFromProcessExitCode(it) }
|
||||||
@@ -203,7 +204,8 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
|||||||
val servicesFacade = GradleIncrementalCompilerServicesFacadeImpl(project, environment)
|
val servicesFacade = GradleIncrementalCompilerServicesFacadeImpl(project, environment)
|
||||||
|
|
||||||
val res = withDaemon(environment, retryOnConnectionError = true) { daemon, sessionId ->
|
val res = withDaemon(environment, retryOnConnectionError = true) { daemon, sessionId ->
|
||||||
daemon.compile(sessionId, environment.compilerArgs, compilationOptions, servicesFacade, GradleCompilationResultsSink(project))
|
val argsArray = ArgumentUtils.convertArgumentsToStringList(environment.compilerArgs).toTypedArray()
|
||||||
|
daemon.compile(sessionId, argsArray, compilationOptions, servicesFacade, GradleCompilationResultsSink(project))
|
||||||
}
|
}
|
||||||
|
|
||||||
val exitCode = res?.get()?.let { exitCodeFromProcessExitCode(it) }
|
val exitCode = res?.get()?.let { exitCodeFromProcessExitCode(it) }
|
||||||
|
|||||||
Reference in New Issue
Block a user