Filter duplicated dependency link options

This commit is contained in:
Pavel Punegov
2020-07-08 12:31:45 +03:00
committed by Pavel Punegov
parent d5a6c33b20
commit aa659475f1
2 changed files with 7 additions and 8 deletions
@@ -505,13 +505,14 @@ fun runTest() {
List<TestModule> orderedModules = DFS.INSTANCE.topologicalOrder(modules.values()) { module ->
module.dependencies.collect { modules[it] }.findAll { it != null }
}
def libsFlags = []
Set<String> libs = new HashSet<String>()
orderedModules.reverse().each { module ->
if (!module.isDefaultModule()) {
def klibModulePath = "${executablePath()}.${module.name}.klib"
libsFlags += module.linkDependencies(executablePath())
libs.addAll(module.dependencies)
runCompiler(compileList.findAll { it.module == module }.collect { it.path },
klibModulePath, flags + ["-p", "library"] + libsFlags)
klibModulePath, flags + ["-p", "library"] +
libs.collectMany { ["-l", "${executablePath()}.${it}.klib"] }.toList())
}
}
@@ -519,9 +520,10 @@ fun runTest() {
it.module.isDefaultModule() || it.module == TestModule.support
}
compileMain.forEach { f ->
libsFlags.addAll(f.module.linkDependencies(executablePath()))
libs.addAll(f.module.dependencies)
}
if (!compileMain.empty) runCompiler(compileMain.collect { it.path }, executablePath(), flags + libsFlags)
if (!compileMain.empty) runCompiler(compileMain.collect { it.path }, executablePath(),
flags + libs.collectMany { ["-l", "${executablePath()}.${it}.klib"] }.toList())
}
} catch (Exception ex) {
project.logger.quiet("ERROR: Compilation failed for test suite: $name with exception", ex)
@@ -88,9 +88,6 @@ data class TestModule(
) {
fun isDefaultModule() = this == default || name.endsWith(".main")
fun linkDependencies(outputPath: String): List<String> =
dependencies.flatMap { listOf("-l", "$outputPath.$it.klib") }
companion object {
val default = TestModule("default", emptyList(), emptyList())
val support = TestModule("support", emptyList(), emptyList())