[Native] Warn on any usage of -repo CLI option
^KT-61098
This commit is contained in:
committed by
Space Team
parent
0b253dc815
commit
b1c9791404
+1
-1
@@ -128,7 +128,7 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
|
||||
valueDescription = "<path>",
|
||||
description = "Library search path.\n" +
|
||||
"Note: This option is deprecated and will be removed in one of the future releases.\n" +
|
||||
"Please use library paths instead of library names in all compiler options such as '-library'."
|
||||
"Please use library paths instead of library names in all compiler options such as '-library' ('-l')."
|
||||
)
|
||||
var repositories: Array<String>? = null
|
||||
|
||||
|
||||
+3
-1
@@ -55,7 +55,9 @@ open class CommonInteropArguments(val argParser: ArgParser) {
|
||||
ArgType.String,
|
||||
shortName = "r",
|
||||
description = "repository to resolve dependencies",
|
||||
deprecatedWarning = "This option is deprecated and will be removed in one of the future releases. Please use library paths instead of library names in all options such as '-library'"
|
||||
// Use the name of the option directly in the deprecation message. This message is automatically printed to the console
|
||||
// if the option has been specified. Without option name in the message it would be unclear which exactly option is deprecated.
|
||||
deprecatedWarning = "'-repo' ('-r') option is deprecated and will be removed in one of the future releases. Please use library paths instead of library names in all options such as '-library' ('-l')."
|
||||
).multiple()
|
||||
val nodefaultlibs by argParser.option(ArgType.Boolean, NODEFAULTLIBS,
|
||||
description = "don't link the libraries from dist/klib automatically").default(false)
|
||||
|
||||
+9
@@ -46,6 +46,15 @@ fun CompilerConfiguration.setupFromArguments(arguments: K2NativeCompilerArgument
|
||||
|
||||
put(INCLUDED_BINARY_FILES, arguments.includeBinaries.toNonNullList())
|
||||
put(NATIVE_LIBRARY_FILES, arguments.nativeLibraries.toNonNullList())
|
||||
|
||||
if (arguments.repositories != null) {
|
||||
// Show the warning also if `-repo` was really specified.
|
||||
report(
|
||||
WARNING,
|
||||
"'-repo' ('-r') compiler option is deprecated and will be removed in one of the future releases. " +
|
||||
"Please use library paths instead of library names in all compiler options such as '-library' ('-l')."
|
||||
)
|
||||
}
|
||||
put(REPOSITORIES, arguments.repositories.toNonNullList())
|
||||
|
||||
// TODO: Collect all the explicit file names into an object
|
||||
|
||||
@@ -172,9 +172,26 @@ open class ModuleDeserializer(val library: ByteArray) {
|
||||
|
||||
}
|
||||
|
||||
private class KlibRepoDeprecationWarning {
|
||||
private var alreadyLogged = false
|
||||
|
||||
fun logOnceIfNecessary() {
|
||||
if (!alreadyLogged) {
|
||||
alreadyLogged = true
|
||||
logWarning("Local KLIB repositories to be dropped soon. See https://youtrack.jetbrains.com/issue/KT-61098")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Library(val libraryNameOrPath: String, val requestedRepository: String?) {
|
||||
|
||||
val repository = requestedRepository?.File() ?: defaultRepository
|
||||
private val klibRepoDeprecationWarning = KlibRepoDeprecationWarning()
|
||||
|
||||
val repository = requestedRepository?.let {
|
||||
klibRepoDeprecationWarning.logOnceIfNecessary() // Due to use of "-repository" option.
|
||||
File(it)
|
||||
} ?: defaultRepository
|
||||
|
||||
fun info() {
|
||||
val library = libraryInRepoOrCurrentDir(repository, libraryNameOrPath)
|
||||
val headerAbiVersion = library.versions.abiVersion
|
||||
@@ -187,7 +204,7 @@ class Library(val libraryNameOrPath: String, val requestedRepository: String?) {
|
||||
println("Resolved to: ${library.libraryName.File().absolutePath}")
|
||||
println("Module name: $moduleName")
|
||||
println("ABI version: $headerAbiVersion")
|
||||
println("Compiler version: ${headerCompilerVersion}")
|
||||
println("Compiler version: $headerCompilerVersion")
|
||||
println("Library version: $headerLibraryVersion")
|
||||
println("Metadata version: $headerMetadataVersion")
|
||||
|
||||
@@ -198,7 +215,7 @@ class Library(val libraryNameOrPath: String, val requestedRepository: String?) {
|
||||
}
|
||||
|
||||
fun install() {
|
||||
logWarning("Local KLIB repositories to be dropped soon. See https://youtrack.jetbrains.com/issue/KT-61098")
|
||||
klibRepoDeprecationWarning.logOnceIfNecessary()
|
||||
|
||||
if (!repository.exists) {
|
||||
logWarning("Repository does not exist: $repository. Creating...")
|
||||
@@ -216,7 +233,7 @@ class Library(val libraryNameOrPath: String, val requestedRepository: String?) {
|
||||
}
|
||||
|
||||
fun remove(blind: Boolean = false) {
|
||||
logWarning("Local KLIB repositories to be dropped soon. See https://youtrack.jetbrains.com/issue/KT-61098")
|
||||
klibRepoDeprecationWarning.logOnceIfNecessary()
|
||||
|
||||
if (!repository.exists) logError("Repository does not exist: $repository")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user