rrn/rd/KT-55578 User-provided hints for linker errors

[K/N] KT-55578 Show customized user suggestions on linkage errors

Merge-request: KT-MR-9636
Merged-by: Gleb Lukianets <Gleb.Lukianets@jetbrains.com>
This commit is contained in:
Gleb Lukianets
2023-04-27 14:14:43 +00:00
committed by Space Team
parent 1e0115aef8
commit 242ca73d83
18 changed files with 368 additions and 11 deletions
@@ -34,6 +34,7 @@ const val SHORT_MODULE_NAME = "Xshort-module-name"
const val FOREIGN_EXCEPTION_MODE = "Xforeign-exception-mode"
const val DUMP_BRIDGES = "Xdump-bridges"
const val DISABLE_EXCEPTION_PRETTIFIER = "Xdisable-exception-prettifier"
const val USER_SETUP_HINT = "Xuser-setup-hint"
// TODO: unify camel and snake cases.
// Possible solution is to accept both cases
@@ -138,6 +139,9 @@ open class CInteropArguments(argParser: ArgParser =
val disableExceptionPrettifier by argParser.option(ArgType.Boolean, DISABLE_EXCEPTION_PRETTIFIER,
description = "Don't hide exceptions with user-friendly ones").default(false)
val userSetupHint by argParser.option(ArgType.String, USER_SETUP_HINT,
description = "A suggestion that is displayed to the user if produced lib fails to link")
}
class JSInteropArguments(argParser: ArgParser = ArgParser("jsinterop",
@@ -388,6 +388,12 @@ private fun processCLib(
ForeignExceptionMode.byValue(it).value // may throw IllegalArgumentException
}
cinteropArguments.userSetupHint?.let {
def.manifestAddendProperties.put("userSetupHint", it)?.also {
warn("User setup hint provided in .def file will be shadowed by command line argument")
}
}
manifestAddend?.parentFile?.mkdirs()
manifestAddend?.let { def.manifestAddendProperties.storeProperties(it) }