From 94ff4d69be2dd6e7ee22a5fd926788dc283840b8 Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Tue, 25 Apr 2017 15:41:03 +0300 Subject: [PATCH] Fix def file substitutions Properly handle the case when platform-specific property is specified but the base one isn't. --- .../kotlin/native/interop/gen/jvm/main.kt | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 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 e326038a1e5..146a8ad7f69 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 @@ -84,19 +84,16 @@ private fun String.targetSuffix(): String = // foo = ${foo} ${foo.${arch}} ${foo.${os}} private fun substitute(properties: Properties, substitutions: Map) { for (key in properties.stringPropertyNames()) { - if (key.contains('.')) { - continue - } - var value = "" - for (substitution in substitutions.keys) { - val property = properties.getProperty(key + "." + substitutions[substitution]) - if (property != null) { - value += " " + property + for (substitution in substitutions.values) { + val suffix = ".$substitution" + if (key.endsWith(suffix)) { + val baseKey = key.removeSuffix(suffix) + val oldValue = properties.getProperty(baseKey, "") + val appendedValue = properties.getProperty(key, "") + val newValue = if (oldValue != "") "$oldValue $appendedValue" else appendedValue + properties.setProperty(baseKey, newValue) } } - if (value != "") { - properties.setProperty(key, properties.getProperty(key, "") + " " + value) - } } }