From 8b8028e10ddd2a084b4fb313a1649e6a7f6d9043 Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Thu, 21 Mar 2019 11:54:26 +0700 Subject: [PATCH] Fat frameworks: Run PlistBuddy only once for all commands Previously we executed the PlistBuddy utility for each command separately. This patch gathers all commands and run PlistBuddy for all of them at once. --- .../kotlin/gradle/tasks/FatFrameworkTask.kt | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/FatFrameworkTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/FatFrameworkTask.kt index ad5e90f9e4d..b3d2a56c4c9 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/FatFrameworkTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/FatFrameworkTask.kt @@ -171,17 +171,26 @@ open class FatFrameworkTask: DefaultTask() { // Runs the PlistBuddy utility with the given commands to configure the given plist file. private fun processPlist(plist: File, commands: PlistBuddyRunner.() -> Unit) = - PlistBuddyRunner(plist).commands() + PlistBuddyRunner(plist).apply { + commands() + }.run() + private inner class PlistBuddyRunner(val plist: File) { - fun run(command: String) = project.exec { - it.executable = "/usr/libexec/PlistBuddy" - it.args("-c", command, plist.absolutePath) + + val commands = mutableListOf() + + fun run() = project.exec { exec -> + exec.executable = "/usr/libexec/PlistBuddy" + commands.forEach { + exec.args("-c", it) + } + exec.args(plist.absolutePath) } - fun add(entry: String, value: String) = run("Add \"$entry\" string \"$value\"") - fun set(entry: String, value: String) = run("Set \"$entry\" \"$value\"") - fun delete(entry: String) = run("Delete \"$entry\"") + fun add(entry: String, value: String) = commands.add("Add \"$entry\" string \"$value\"") + fun set(entry: String, value: String) = commands.add("Set \"$entry\" \"$value\"") + fun delete(entry: String) = commands.add("Delete \"$entry\"") } private fun runLipo(inputFiles: Map, outputFile: File) = @@ -267,7 +276,7 @@ open class FatFrameworkTask: DefaultTask() { // Copy dSYM's Info.plist. // It doesn't contain target-specific info or framework names except the bundle id so there is no need to edit it. - // TODO: handle bunde id. + // TODO: handle bundle id. project.copy { it.from(dsymInputs.values.first().infoPlist) it.into(fatDsym.infoPlist) @@ -283,5 +292,6 @@ open class FatFrameworkTask: DefaultTask() { mergeHeaders(fatFramework.header) createModuleFile(fatFramework.moduleFile, frameworkName) mergePlists(fatFramework.infoPlist, frameworkName) + mergeDSYM() } }