[K/N][build] Don't use srcRoot in compdb tasks
The CompileToBitcode task has two options to specify sources: srcDirs and srcRoot. Thus there may be a situation when sources are specified using srcDirs only and srcRoot doesn't exists (e.g. compilation of googletest and googlemock, see RuntimeTestingPlugin.kt). In this case a generated compilation database will contain a path to a directory which doesn't exist causing error messages during CLion import. This patch fixes this by getting rid of using srcRoot in combdb tasks.
This commit is contained in:
+1
-7
@@ -54,7 +54,6 @@ internal data class Entry(
|
||||
}
|
||||
|
||||
open class GenerateCompilationDatabase @Inject constructor(@Input val target: String,
|
||||
@Internal val srcRoot: File,
|
||||
@Internal val files: Iterable<File>,
|
||||
@Input val executable: String,
|
||||
@Input val compilerFlags: List<String>,
|
||||
@@ -68,10 +67,6 @@ open class GenerateCompilationDatabase @Inject constructor(@Input val target: St
|
||||
val outputDirPath: String
|
||||
get() = outputDir.absolutePath
|
||||
|
||||
@get:Input
|
||||
val srcRootPath: String
|
||||
get() = srcRoot.absolutePath
|
||||
|
||||
@get:Input
|
||||
val pathsToFiles: Iterable<String>
|
||||
get() = files.map { it.absolutePath }
|
||||
@@ -81,7 +76,7 @@ open class GenerateCompilationDatabase @Inject constructor(@Input val target: St
|
||||
val plugin = project.extensions.getByType<ExecClang>()
|
||||
val executable = plugin.resolveExecutable(executable)
|
||||
val args = listOf(executable) + compilerFlags + plugin.clangArgsForCppRuntime(target)
|
||||
val entries: List<Entry> = files.map { Entry.create(srcRoot, it, args, outputDir) }
|
||||
val entries: List<Entry> = files.map { Entry.create(it.parentFile, it, args, outputDir) }
|
||||
Entry.writeListTo(outputFile, entries)
|
||||
}
|
||||
}
|
||||
@@ -128,7 +123,6 @@ fun createCompilationDatabasesFromCompileToBitcodeTasks(project: Project, name:
|
||||
project.tasks.create("${task.name}_CompilationDatabase",
|
||||
GenerateCompilationDatabase::class.java,
|
||||
task.target,
|
||||
task.srcRoot,
|
||||
task.inputFiles,
|
||||
task.executable,
|
||||
task.compilerFlags,
|
||||
|
||||
+1
@@ -62,6 +62,7 @@ abstract class CompileToBitcodeJob : WorkAction<CompileToBitcodeParameters> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Get rid of storing srcRoot in the task.
|
||||
abstract class CompileToBitcode @Inject constructor(
|
||||
@Internal val srcRoot: File,
|
||||
@Input val folderName: String,
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) {
|
||||
|
||||
fun create(
|
||||
name: String,
|
||||
srcDir: File = project.file("src/$name"),
|
||||
srcRoot: File = project.file("src/$name"),
|
||||
outputGroup: String = "main",
|
||||
configurationBlock: CompileToBitcode.() -> Unit = {}
|
||||
) {
|
||||
@@ -55,7 +55,7 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) {
|
||||
project.tasks.register(
|
||||
"${targetName}${name.snakeCaseToCamelCase().capitalize()}${suffixForSanitizer(sanitizer)}",
|
||||
CompileToBitcode::class.java,
|
||||
srcDir, name, targetName, outputGroup
|
||||
srcRoot, name, targetName, outputGroup
|
||||
).configure {
|
||||
this.sanitizer = sanitizer
|
||||
group = BasePlugin.BUILD_GROUP
|
||||
|
||||
Reference in New Issue
Block a user