Coverage: Use featured libraries resolution for libraries to cover

This commit is contained in:
Ilya Matveev
2019-08-08 17:23:35 +07:00
committed by Ilya Matveev
parent 843cd0001a
commit 5a5b8ad295
3 changed files with 25 additions and 4 deletions
@@ -53,6 +53,17 @@ internal fun getSourceLibraries(
FeaturedLibrariesReporter.forSourceLibraries(configuration)
)
internal fun getCoveredLibraries(
configuration: CompilerConfiguration,
resolvedLibraries: KonanLibraryResolveResult,
resolver: SearchPathResolver
): List<KonanLibrary> = getFeaturedLibraries(
configuration.getList(KonanConfigKeys.LIBRARIES_TO_COVER),
resolvedLibraries,
resolver,
FeaturedLibrariesReporter.forCoveredLibraries(configuration)
)
private sealed class FeaturedLibrariesReporter {
abstract fun reportIllegalKind(library: KonanLibrary)
@@ -94,7 +105,6 @@ private sealed class FeaturedLibrariesReporter {
"Following libraries are specified to be exported with -Xexport-library, but not included to the build:"
}
// TODO: Reformulate?
private class SourceLibrariesReporter(configuration: CompilerConfiguration) : BaseReporter(configuration) {
override fun illegalKindMessage(kind: String, libraryName: String): String =
"$kind library $libraryName can't be used as a source library"
@@ -103,9 +113,18 @@ private sealed class FeaturedLibrariesReporter {
"Following libraries are declared as source libraries with -Xsource-library, but not included to the build:"
}
private class CoveredLibraryReporter(configuration: CompilerConfiguration): BaseReporter(configuration) {
override fun illegalKindMessage(kind: String, libraryName: String): String =
"$kind library $libraryName can't be covered"
override fun notIncludedLibraryMessageTitle(): String =
"Following libraries are specified to be covered with -Xlibrary-to-cover, but not included to the build:"
}
companion object {
fun forExportedLibraries(configuration: CompilerConfiguration): FeaturedLibrariesReporter = ExportedLibrariesReporter(configuration)
fun forSourceLibraries(configuration: CompilerConfiguration): FeaturedLibrariesReporter = SourceLibrariesReporter(configuration)
fun forCoveredLibraries(configuration: CompilerConfiguration): FeaturedLibrariesReporter = CoveredLibraryReporter(configuration)
}
}
@@ -130,6 +130,10 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
getSourceLibraries(configuration, resolvedLibraries, resolver.searchPathResolver)
}
internal val coveredLibraries by lazy {
getCoveredLibraries(configuration, resolvedLibraries, resolver.searchPathResolver)
}
fun librariesWithDependencies(moduleDescriptor: ModuleDescriptor?): List<KonanLibrary> {
if (moduleDescriptor == null) error("purgeUnneeded() only works correctly after resolve is over, and we have successfully marked package files as needed or not needed.")
@@ -27,9 +27,7 @@ internal class CoverageManager(val context: Context) {
context.config.configuration.getBoolean(KonanConfigKeys.COVERAGE)
private val librariesToCover: Set<String> =
context.config.configuration.getList(KonanConfigKeys.LIBRARIES_TO_COVER)
.map { File(it).absolutePath.removeSuffixIfPresent(".klib") }
.toSet()
context.config.coveredLibraries.map { it.libraryName }.toSet()
private val llvmProfileFilenameGlobal = "__llvm_profile_filename"