1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-27 08:38:13 -07:00

Added kobaltCompilerSeparateProcess flag.

This commit is contained in:
Cedric Beust 2017-01-20 12:35:06 -08:00
parent 998972f022
commit a40b63eec4
3 changed files with 17 additions and 12 deletions

View file

@ -74,12 +74,12 @@ class KotlinCompiler @Inject constructor(
// need to spawn a Kotlin compiler in a separate process. Otherwise, we can just invoke
// the K2JVMCompiler class directly
val actualVersion = kotlinConfig(project)?.version ?: settings.kobaltCompilerVersion
if (actualVersion == Constants.KOTLIN_COMPILER_VERSION) {
return invokeCompilerDirectly(projectName ?: "kobalt-" + Random().nextInt(), outputDir,
classpath, info.sourceFiles, info.friendPaths.toTypedArray())
if (settings.kobaltCompilerSeparateProcess || actualVersion != Constants.KOTLIN_COMPILER_VERSION) {
return invokeCompilerInSeparateProcess(classpath, info, project)
} else {
return invokeCompilerInSeparateProcess(classpath, info, project)
return invokeCompilerDirectly(projectName ?: "kobalt-" + Random().nextInt(), outputDir,
classpath, info.sourceFiles, info.friendPaths.toTypedArray())
}
}
@ -93,7 +93,7 @@ class KotlinCompiler @Inject constructor(
val compilerClasspath = compilerDep.jarFile.get().path + File.pathSeparator +
compilerEmbeddableDependencies(null).map { it.jarFile.get().path }
.joinToString(File.pathSeparator)
val xFlagsString = kotlinConfig(project)?.flags
val xFlagsString = kotlinConfig(project)?.args?.joinToString(" ")
?: settings.kobaltCompilerFlags
?: ""
val xFlagsArray = xFlagsString.split(" ").toTypedArray()

View file

@ -42,7 +42,7 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen
// ICompilerFlagsContributor
override fun compilerFlagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
suffixesBeingCompiled: List<String>) : List<String> {
val args = (configurationFor(project)?.compilerArgs ?: listOf<String>()) + "-no-stdlib"
val args = (configurationFor(project)?.args ?: listOf<String>()) + "-no-stdlib"
val result = maybeCompilerArgs(compiler.sourceSuffixes, suffixesBeingCompiled, args)
return result
}
@ -145,14 +145,11 @@ fun kotlinProject(vararg projects: Project, init: Project.() -> Unit): Project {
}
class KotlinConfig(val project: Project) {
val compilerArgs = arrayListOf<String>()
fun args(vararg options: String) = compilerArgs.addAll(options)
val args = arrayListOf<String>()
fun args(vararg options: String) = args.addAll(options)
/** The version of the Kotlin compiler */
var version: String? = null
/** The flags to pass to the Kotlin compiler */
var flags: String? = null
}
@Directive