[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>",
|
valueDescription = "<path>",
|
||||||
description = "Library search path.\n" +
|
description = "Library search path.\n" +
|
||||||
"Note: This option is deprecated and will be removed in one of the future releases.\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
|
var repositories: Array<String>? = null
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -55,7 +55,9 @@ open class CommonInteropArguments(val argParser: ArgParser) {
|
|||||||
ArgType.String,
|
ArgType.String,
|
||||||
shortName = "r",
|
shortName = "r",
|
||||||
description = "repository to resolve dependencies",
|
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()
|
).multiple()
|
||||||
val nodefaultlibs by argParser.option(ArgType.Boolean, NODEFAULTLIBS,
|
val nodefaultlibs by argParser.option(ArgType.Boolean, NODEFAULTLIBS,
|
||||||
description = "don't link the libraries from dist/klib automatically").default(false)
|
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(INCLUDED_BINARY_FILES, arguments.includeBinaries.toNonNullList())
|
||||||
put(NATIVE_LIBRARY_FILES, arguments.nativeLibraries.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())
|
put(REPOSITORIES, arguments.repositories.toNonNullList())
|
||||||
|
|
||||||
// TODO: Collect all the explicit file names into an object
|
// 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?) {
|
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() {
|
fun info() {
|
||||||
val library = libraryInRepoOrCurrentDir(repository, libraryNameOrPath)
|
val library = libraryInRepoOrCurrentDir(repository, libraryNameOrPath)
|
||||||
val headerAbiVersion = library.versions.abiVersion
|
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("Resolved to: ${library.libraryName.File().absolutePath}")
|
||||||
println("Module name: $moduleName")
|
println("Module name: $moduleName")
|
||||||
println("ABI version: $headerAbiVersion")
|
println("ABI version: $headerAbiVersion")
|
||||||
println("Compiler version: ${headerCompilerVersion}")
|
println("Compiler version: $headerCompilerVersion")
|
||||||
println("Library version: $headerLibraryVersion")
|
println("Library version: $headerLibraryVersion")
|
||||||
println("Metadata version: $headerMetadataVersion")
|
println("Metadata version: $headerMetadataVersion")
|
||||||
|
|
||||||
@@ -198,7 +215,7 @@ class Library(val libraryNameOrPath: String, val requestedRepository: String?) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun install() {
|
fun install() {
|
||||||
logWarning("Local KLIB repositories to be dropped soon. See https://youtrack.jetbrains.com/issue/KT-61098")
|
klibRepoDeprecationWarning.logOnceIfNecessary()
|
||||||
|
|
||||||
if (!repository.exists) {
|
if (!repository.exists) {
|
||||||
logWarning("Repository does not exist: $repository. Creating...")
|
logWarning("Repository does not exist: $repository. Creating...")
|
||||||
@@ -216,7 +233,7 @@ class Library(val libraryNameOrPath: String, val requestedRepository: String?) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun remove(blind: Boolean = false) {
|
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")
|
if (!repository.exists) logError("Repository does not exist: $repository")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user