From 07177396ac6864cccc6bac05423e9fa56b681865 Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Fri, 28 Feb 2020 16:18:05 +0700 Subject: [PATCH] [cinterop] A bit more robust logic of mode selection --- .../jetbrains/kotlin/native/interop/gen/jvm/main.kt | 13 +++++++++++-- .../org/jetbrains/kotlin/NativeInteropPlugin.groovy | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt index 58c7f966ab1..f4ff3e8ab0f 100644 --- a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt +++ b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt @@ -211,8 +211,17 @@ private fun processCLib(args: Array, additionalArgs: Map = 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) diff --git a/build-tools/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy b/build-tools/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy index 56f7e9f84a7..d7e73fa50ce 100644 --- a/build-tools/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy +++ b/build-tools/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy @@ -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'