Source libraries: Codestyle and messages fixes

This commit is contained in:
Ilya Matveev
2019-08-19 21:40:27 +07:00
committed by Ilya Matveev
parent 2297b52596
commit d3ab5b0969
5 changed files with 23 additions and 14 deletions
@@ -190,11 +190,12 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
else -> put(GENERATE_TEST_RUNNER, TestRunnerKind.NONE) else -> put(GENERATE_TEST_RUNNER, TestRunnerKind.NONE)
} }
// We need to download dependencies only if we use them ( = there are files to compile). // We need to download dependencies only if we use them ( = there are files to compile).
put(CHECK_DEPENDENCIES, if (configuration.kotlinSourceRoots.isNotEmpty() || !arguments.sourceLibraries.isNullOrEmpty()) { put(
true CHECK_DEPENDENCIES,
} else { configuration.kotlinSourceRoots.isNotEmpty()
arguments.checkDependencies || !arguments.sourceLibraries.isNullOrEmpty()
}) || arguments.checkDependencies
)
if (arguments.friendModules != null) if (arguments.friendModules != null)
put(FRIEND_MODULES, arguments.friendModules!!.split(File.pathSeparator).filterNot(String::isEmpty)) put(FRIEND_MODULES, arguments.friendModules!!.split(File.pathSeparator).filterNot(String::isEmpty))
@@ -310,8 +311,11 @@ private fun selectSourceLibraries(
val produceBinaryOrBitcode = outputKind.let { it.isNativeBinary || it == CompilerOutputKind.BITCODE } val produceBinaryOrBitcode = outputKind.let { it.isNativeBinary || it == CompilerOutputKind.BITCODE }
return if (sourceLibraries.isNotEmpty() && !produceBinaryOrBitcode) { return if (sourceLibraries.isNotEmpty() && !produceBinaryOrBitcode) {
configuration.report(ERROR, "The $SOURCE_LIBRARY_ARG flag is only supported when producing native binaries or bitcode files, " + configuration.report(
"but the compiler is producing ${outputKind.name.toLowerCase()}") ERROR,
"The $SOURCE_LIBRARY_ARG flag is only supported when producing native binaries or bitcode files, " +
"but the compiler is producing ${outputKind.name.toLowerCase()}"
)
emptyList() emptyList()
} else { } else {
sourceLibraries sourceLibraries
@@ -160,7 +160,7 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
@Argument( @Argument(
value = SOURCE_LIBRARY_ARG, value = SOURCE_LIBRARY_ARG,
valueDescription = "<path>", valueDescription = "<path>",
description = "A library to be processed in the same manner as source files (test processing, ObjC export etc).\n" + description = "A library to be processed in the same manner as source files.\n" +
"Must be one of libraries passed with '-library'" "Must be one of libraries passed with '-library'"
) )
var sourceLibraries: Array<String>? = null var sourceLibraries: Array<String>? = null
@@ -193,7 +193,7 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
@Argument( @Argument(
value = "-Xlibrary-to-cover", value = "-Xlibrary-to-cover",
valueDescription = "<path>", valueDescription = "<path>",
description = "A library that should be covered.\n" + description = "Provide code coverage for the given library.\n" +
"Must be one of libraries passed with '-library'", "Must be one of libraries passed with '-library'",
delimiter = "" delimiter = ""
) )
@@ -80,7 +80,11 @@ private sealed class FeaturedLibrariesReporter {
protected abstract fun notIncludedLibraryMessageTitle(): String protected abstract fun notIncludedLibraryMessageTitle(): String
override fun reportIllegalKind(library: KonanLibrary) { override fun reportIllegalKind(library: KonanLibrary) {
val kind = if (library.isInterop) "Interop" else "Default" val kind = when {
library.isInterop -> "Interop"
library.isDefault -> "Default"
else -> "Unknown kind"
}
configuration.report(CompilerMessageSeverity.STRONG_WARNING, illegalKindMessage(kind, library.libraryName)) configuration.report(CompilerMessageSeverity.STRONG_WARNING, illegalKindMessage(kind, library.libraryName))
} }
@@ -115,10 +119,10 @@ private sealed class FeaturedLibrariesReporter {
private class CoveredLibraryReporter(configuration: CompilerConfiguration): BaseReporter(configuration) { private class CoveredLibraryReporter(configuration: CompilerConfiguration): BaseReporter(configuration) {
override fun illegalKindMessage(kind: String, libraryName: String): String = override fun illegalKindMessage(kind: String, libraryName: String): String =
"$kind library $libraryName can't be covered" "Cannot provide the code coverage for the $kind library $libraryName."
override fun notIncludedLibraryMessageTitle(): String = override fun notIncludedLibraryMessageTitle(): String =
"Following libraries are specified to be covered with -Xlibrary-to-cover, but not included to the build:" "The code coverage is enabled for the following libraries, but they are not included to the build:"
} }
companion object { companion object {
@@ -39,7 +39,8 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
internal val target = targetManager.target internal val target = targetManager.target
internal val phaseConfig = configuration.get(CLIConfigurationKeys.PHASE_CONFIG)!! internal val phaseConfig = configuration.get(CLIConfigurationKeys.PHASE_CONFIG)!!
val infoArgsOnly = configuration.kotlinSourceRoots.isEmpty() && configuration[KonanConfigKeys.SOURCE_LIBRARIES].isNullOrEmpty() val infoArgsOnly = configuration.kotlinSourceRoots.isEmpty()
&& configuration[KonanConfigKeys.SOURCE_LIBRARIES].isNullOrEmpty()
// TODO: debug info generation mode and debug/release variant selection probably requires some refactoring. // TODO: debug info generation mode and debug/release variant selection probably requires some refactoring.
val debug: Boolean get() = configuration.getBoolean(KonanConfigKeys.DEBUG) val debug: Boolean get() = configuration.getBoolean(KonanConfigKeys.DEBUG)
@@ -95,7 +95,7 @@ class KonanConfigKeys {
val RUNTIME_FILE: CompilerConfigurationKey<String?> val RUNTIME_FILE: CompilerConfigurationKey<String?>
= CompilerConfigurationKey.create("override default runtime file path") = CompilerConfigurationKey.create("override default runtime file path")
val SOURCE_LIBRARIES: CompilerConfigurationKey<List<String>> val SOURCE_LIBRARIES: CompilerConfigurationKey<List<String>>
= CompilerConfigurationKey("a klibraries used to produce the final binaries instead of source code") // TODO: Better description. = CompilerConfigurationKey("libraries used to be processed in the same manner as source files")
val SOURCE_MAP: CompilerConfigurationKey<List<String>> val SOURCE_MAP: CompilerConfigurationKey<List<String>>
= CompilerConfigurationKey.create("generate source map") = CompilerConfigurationKey.create("generate source map")
val STATIC_FRAMEWORK: CompilerConfigurationKey<Boolean> val STATIC_FRAMEWORK: CompilerConfigurationKey<Boolean>