mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Added kobaltCompilerSeparateProcess flag.
This commit is contained in:
parent
998972f022
commit
a40b63eec4
3 changed files with 17 additions and 12 deletions
|
@ -10,7 +10,6 @@ import com.google.inject.Inject
|
||||||
import com.google.inject.Singleton
|
import com.google.inject.Singleton
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.lang.NumberFormatException
|
|
||||||
import javax.xml.bind.JAXBContext
|
import javax.xml.bind.JAXBContext
|
||||||
import javax.xml.bind.annotation.XmlElement
|
import javax.xml.bind.annotation.XmlElement
|
||||||
import javax.xml.bind.annotation.XmlRootElement
|
import javax.xml.bind.annotation.XmlRootElement
|
||||||
|
@ -40,6 +39,9 @@ class KobaltSettingsXml {
|
||||||
|
|
||||||
@XmlElement(name = "kobaltCompilerFlags") @JvmField
|
@XmlElement(name = "kobaltCompilerFlags") @JvmField
|
||||||
var kobaltCompilerFlags: String? = null
|
var kobaltCompilerFlags: String? = null
|
||||||
|
|
||||||
|
@XmlElement(name = "kobaltCompilerSeparateProcess") @JvmField
|
||||||
|
var kobaltCompilerSeparateProcess: Boolean = false
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProxiesXml {
|
class ProxiesXml {
|
||||||
|
@ -83,6 +85,12 @@ class KobaltSettings @Inject constructor(val xmlFile: KobaltSettingsXml) {
|
||||||
*/
|
*/
|
||||||
val localMavenRepo = KFiles.makeDir(xmlFile.localMavenRepo)
|
val localMavenRepo = KFiles.makeDir(xmlFile.localMavenRepo)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true, the Kotlin compiler will always be launched in a separate JVM, even if the requested
|
||||||
|
* version is the same as the internal version.
|
||||||
|
*/
|
||||||
|
val kobaltCompilerSeparateProcess = xmlFile.kobaltCompilerSeparateProcess
|
||||||
|
|
||||||
val defaultRepos = xmlFile.defaultRepos?.repo
|
val defaultRepos = xmlFile.defaultRepos?.repo
|
||||||
|
|
||||||
val proxyConfigs = with(xmlFile.proxies?.proxy) {
|
val proxyConfigs = with(xmlFile.proxies?.proxy) {
|
||||||
|
|
|
@ -74,12 +74,12 @@ class KotlinCompiler @Inject constructor(
|
||||||
// need to spawn a Kotlin compiler in a separate process. Otherwise, we can just invoke
|
// need to spawn a Kotlin compiler in a separate process. Otherwise, we can just invoke
|
||||||
// the K2JVMCompiler class directly
|
// the K2JVMCompiler class directly
|
||||||
val actualVersion = kotlinConfig(project)?.version ?: settings.kobaltCompilerVersion
|
val actualVersion = kotlinConfig(project)?.version ?: settings.kobaltCompilerVersion
|
||||||
if (actualVersion == Constants.KOTLIN_COMPILER_VERSION) {
|
if (settings.kobaltCompilerSeparateProcess || actualVersion != Constants.KOTLIN_COMPILER_VERSION) {
|
||||||
return invokeCompilerDirectly(projectName ?: "kobalt-" + Random().nextInt(), outputDir,
|
return invokeCompilerInSeparateProcess(classpath, info, project)
|
||||||
classpath, info.sourceFiles, info.friendPaths.toTypedArray())
|
|
||||||
|
|
||||||
} else {
|
} 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 +
|
val compilerClasspath = compilerDep.jarFile.get().path + File.pathSeparator +
|
||||||
compilerEmbeddableDependencies(null).map { it.jarFile.get().path }
|
compilerEmbeddableDependencies(null).map { it.jarFile.get().path }
|
||||||
.joinToString(File.pathSeparator)
|
.joinToString(File.pathSeparator)
|
||||||
val xFlagsString = kotlinConfig(project)?.flags
|
val xFlagsString = kotlinConfig(project)?.args?.joinToString(" ")
|
||||||
?: settings.kobaltCompilerFlags
|
?: settings.kobaltCompilerFlags
|
||||||
?: ""
|
?: ""
|
||||||
val xFlagsArray = xFlagsString.split(" ").toTypedArray()
|
val xFlagsArray = xFlagsString.split(" ").toTypedArray()
|
||||||
|
|
|
@ -42,7 +42,7 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen
|
||||||
// ICompilerFlagsContributor
|
// ICompilerFlagsContributor
|
||||||
override fun compilerFlagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
override fun compilerFlagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
||||||
suffixesBeingCompiled: List<String>) : 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)
|
val result = maybeCompilerArgs(compiler.sourceSuffixes, suffixesBeingCompiled, args)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
@ -145,14 +145,11 @@ fun kotlinProject(vararg projects: Project, init: Project.() -> Unit): Project {
|
||||||
}
|
}
|
||||||
|
|
||||||
class KotlinConfig(val project: Project) {
|
class KotlinConfig(val project: Project) {
|
||||||
val compilerArgs = arrayListOf<String>()
|
val args = arrayListOf<String>()
|
||||||
fun args(vararg options: String) = compilerArgs.addAll(options)
|
fun args(vararg options: String) = args.addAll(options)
|
||||||
|
|
||||||
/** The version of the Kotlin compiler */
|
/** The version of the Kotlin compiler */
|
||||||
var version: String? = null
|
var version: String? = null
|
||||||
|
|
||||||
/** The flags to pass to the Kotlin compiler */
|
|
||||||
var flags: String? = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue