[cinterop] A bit more robust logic of mode selection

This commit is contained in:
Sergey Bogolepov
2020-02-28 16:18:05 +07:00
committed by Sergey Bogolepov
parent aee9bcfed0
commit 07177396ac
2 changed files with 14 additions and 2 deletions
@@ -211,8 +211,17 @@ private fun processCLib(args: Array<String>, additionalArgs: Map<String, Any> =
val outKtPkg = fqParts.joinToString(".")
val mode = parseGenerationMode(cinteropArguments.mode)
?: error ("Unexpected interop generation mode: ${cinteropArguments.mode}")
val mode = run {
val providedMode = parseGenerationMode(cinteropArguments.mode)
?: error ("Unexpected interop generation mode: ${cinteropArguments.mode}")
if (providedMode == GenerationMode.METADATA && flavor == KotlinPlatform.JVM) {
warn("Metadata mode isn't supported for Kotlin/JVM! Falling back to sourcecode.")
GenerationMode.SOURCE_CODE
} else {
providedMode
}
}
val allLibraryDependencies = when (flavor) {
KotlinPlatform.NATIVE -> resolveDependencies(cinteropArguments, tool.target)
@@ -225,6 +225,9 @@ class NamedNativeInteropConfig implements Named {
args '-natives', nativeLibsDir
args '-Xtemporary-files-dir', temporaryFilesDir
args '-flavor', this.flavor
if (flavor == "jvm") {
args '-mode', 'sourcecode'
}
// Uncomment to debug.
// args '-verbose', 'true'