mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Add <kobaltCompilerFlagss> in settings.xml.
This commit is contained in:
parent
fb0da19f24
commit
991887e280
2 changed files with 21 additions and 0 deletions
|
@ -34,6 +34,9 @@ class KobaltSettingsXml {
|
|||
|
||||
@XmlElement(name = "kobaltCompilerRepo") @JvmField
|
||||
var kobaltCompilerRepo: String? = null
|
||||
|
||||
@XmlElement(name = "kobaltCompilerFlags") @JvmField
|
||||
var kobaltCompilerFlags: String? = null
|
||||
}
|
||||
|
||||
class ProxiesXml {
|
||||
|
@ -97,6 +100,7 @@ class KobaltSettings @Inject constructor(val xmlFile: KobaltSettingsXml) {
|
|||
|
||||
var kobaltCompilerVersion = xmlFile.kobaltCompilerVersion
|
||||
var kobaltCompilerRepo = xmlFile.kobaltCompilerRepo
|
||||
var kobaltCompilerFlags = xmlFile.kobaltCompilerFlags
|
||||
|
||||
companion object {
|
||||
val SETTINGS_FILE_PATH = KFiles.joinDir(KFiles.HOME_KOBALT_DIR.absolutePath, "settings.xml")
|
||||
|
|
|
@ -85,6 +85,23 @@ class KotlinCompiler @Inject constructor(
|
|||
friendPaths = friends
|
||||
}
|
||||
|
||||
/**
|
||||
* ~/.config/kobalt/settings.xml allows users to specify -Xflags in the
|
||||
* <kobaltCompilerFlags> tag. Map each of these string flags to the boolean
|
||||
* found in the args class
|
||||
*/
|
||||
fun updateArgsWithCompilerFlags(args: K2JVMCompilerArguments, settings: KobaltSettings) {
|
||||
val flags = settings.kobaltCompilerFlags?.split(" ")
|
||||
flags?.forEach {
|
||||
if (it.startsWith("-X")) when(it.substring(2)) {
|
||||
"skip-metadata-version-check" -> args.skipMetadataVersionCheck = true
|
||||
else -> warn("Unknown Kotlin compiler flag found in config.xml: $it")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateArgsWithCompilerFlags(args, settings)
|
||||
|
||||
fun logk(level: Int, message: CharSequence) = kobaltLog.log(projectName ?: "", level, message)
|
||||
|
||||
logk(2, "Invoking K2JVMCompiler with arguments:"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue