Skip to content

Commit

Permalink
Add a method to obtain MPP preset name for KonanTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmat192 committed May 30, 2019
1 parent cca3ad3 commit e2f6cba
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,5 +319,20 @@ open class HostManager(protected val distribution: Distribution = Distribution()
}
}

/**
* Name of a preset used in the 'kotlin-multiplatform' Gradle plugin to represent this target.
*/
val KonanTarget.presetName: String
get() = when (this) {
ANDROID_ARM32 -> "androidNativeArm32"
ANDROID_ARM64 -> "androidNativeArm64"
else -> evaluatePresetName(this.name)
}

private fun evaluatePresetName(targetName: String): String {
val nameParts = targetName.split('_').mapNotNull { it.takeIf(String::isNotEmpty) }
return nameParts.asSequence().drop(1).joinToString("", nameParts.firstOrNull().orEmpty(), transform = String::capitalize)
}

class TargetSupportException (message: String = "", cause: Throwable? = null) : Exception(message, cause)

0 comments on commit e2f6cba

Please sign in to comment.