Fix def file substitutions

Properly handle the case when platform-specific property is specified
but the base one isn't.
This commit is contained in:
Svyatoslav Scherbina
2017-04-25 15:41:03 +03:00
committed by SvyatoslavScherbina
parent 9926b281dd
commit 94ff4d69be
@@ -84,19 +84,16 @@ private fun String.targetSuffix(): String =
// foo = ${foo} ${foo.${arch}} ${foo.${os}} // foo = ${foo} ${foo.${arch}} ${foo.${os}}
private fun substitute(properties: Properties, substitutions: Map<String, String>) { private fun substitute(properties: Properties, substitutions: Map<String, String>) {
for (key in properties.stringPropertyNames()) { for (key in properties.stringPropertyNames()) {
if (key.contains('.')) { for (substitution in substitutions.values) {
continue val suffix = ".$substitution"
} if (key.endsWith(suffix)) {
var value = "" val baseKey = key.removeSuffix(suffix)
for (substitution in substitutions.keys) { val oldValue = properties.getProperty(baseKey, "")
val property = properties.getProperty(key + "." + substitutions[substitution]) val appendedValue = properties.getProperty(key, "")
if (property != null) { val newValue = if (oldValue != "") "$oldValue $appendedValue" else appendedValue
value += " " + property properties.setProperty(baseKey, newValue)
} }
} }
if (value != "") {
properties.setProperty(key, properties.getProperty(key, "") + " " + value)
}
} }
} }