mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Compiler flag fixes.
This commit is contained in:
parent
6d61747fd5
commit
83282342ae
10 changed files with 26 additions and 19 deletions
|
@ -149,7 +149,7 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null,
|
|||
// that directory will be added when trying to find recursively all the sources in it
|
||||
generatedSourceDirectory = File(result.relativeTo(File(project.directory)).absolutePath)
|
||||
val outputGeneratedSourceDirectory = File(result, pkg.replace('.', File.separatorChar))
|
||||
val outputDir = File(outputGeneratedSourceDirectory, "BuildConfig" + contributor.buildConfigSuffix)
|
||||
val outputDir = File(outputGeneratedSourceDirectory, "BuildConfig." + contributor.buildConfigSuffix)
|
||||
KFiles.saveFile(outputDir, code)
|
||||
log(2, "Generated ${outputDir.path}")
|
||||
return result
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.io.File
|
|||
data class CompilerActionInfo(val directory: String?,
|
||||
val dependencies: List<IClasspathDependency>,
|
||||
val sourceFiles: List<String>,
|
||||
val suffixesBeingCompiled: List<String>,
|
||||
val outputDir: File,
|
||||
val compilerArgs: List<String>)
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@ package com.beust.kobalt.api
|
|||
* Plugins that add compiler flags.
|
||||
*/
|
||||
interface ICompilerFlagContributor : IContributor {
|
||||
fun flagsFor(project: Project, context: KobaltContext, currentFlags: List<String>): List<String>
|
||||
fun flagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
||||
suffixesBeingCompiled: List<String>): List<String>
|
||||
val flagPriority: Int
|
||||
get() = DEFAULT_FLAG_PRIORITY
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.beust.kobalt.internal
|
|||
|
||||
import com.beust.kobalt.api.ConfigPlugin
|
||||
import com.beust.kobalt.api.ICompilerFlagContributor
|
||||
import com.beust.kobalt.api.Project
|
||||
|
||||
/**
|
||||
* Base class for JVM language plug-ins.
|
||||
|
@ -13,8 +12,9 @@ abstract class BaseJvmPlugin<T> : ConfigPlugin<T>(), ICompilerFlagContributor {
|
|||
val FLAG_CONTRIBUTOR_PRIORITY = ICompilerFlagContributor.DEFAULT_FLAG_PRIORITY - 10
|
||||
}
|
||||
|
||||
protected fun maybeCompilerArgs(project: Project, args: List<String>)
|
||||
= if (accept(project)) args else emptyList()
|
||||
protected fun maybeCompilerArgs(sourceSuffixes: List<String>, suffixesBeingCompiled: List<String>,
|
||||
args: List<String>)
|
||||
= if (sourceSuffixes.any { suffixesBeingCompiled.contains(it) }) args else emptyList()
|
||||
|
||||
override val flagPriority = FLAG_CONTRIBUTOR_PRIORITY
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class JvmCompiler @Inject constructor(val dependencyManager: DependencyManager)
|
|||
val contributors = context.pluginInfo.compilerFlagContributors
|
||||
contributors.sortBy { it.flagPriority }
|
||||
context.pluginInfo.compilerFlagContributors.forEach {
|
||||
currentFlags.addAll(it.flagsFor(project, context, currentFlags))
|
||||
currentFlags.addAll(it.flagsFor(project, context, currentFlags, info.suffixesBeingCompiled))
|
||||
}
|
||||
currentFlags
|
||||
} else {
|
||||
|
|
|
@ -293,7 +293,7 @@ open class JvmCompilerPlugin @Inject constructor(
|
|||
|
||||
// Finally, alter the info with the compiler interceptors before returning it
|
||||
val initialActionInfo = CompilerActionInfo(projectDirectory.path, classpath, sourceFiles + extraSourceFiles,
|
||||
buildDirectory, emptyList() /* the flags will be provided by flag contributors */)
|
||||
sourceSuffixes, buildDirectory, emptyList() /* the flags will be provided by flag contributors */)
|
||||
val result = context.pluginInfo.compilerInterceptors.fold(initialActionInfo, { ai, interceptor ->
|
||||
interceptor.intercept(project, context, ai)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue