[Gradle] Support Configuration Cache for FatFramework task
^KT-54362 ^KT-54339 Verification Pending
This commit is contained in:
committed by
Space Team
parent
a7f33819fa
commit
13dcb9388c
+1
-1
@@ -90,7 +90,7 @@ open class PodInstallTask : CocoapodsTask() {
|
|||||||
val podInstallCommand = listOf("pod", "install")
|
val podInstallCommand = listOf("pod", "install")
|
||||||
|
|
||||||
runCommand(podInstallCommand,
|
runCommand(podInstallCommand,
|
||||||
project.logger,
|
logger,
|
||||||
errorHandler = { returnCode, output, _ ->
|
errorHandler = { returnCode, output, _ ->
|
||||||
CocoapodsErrorHandlingUtil.handlePodInstallError(
|
CocoapodsErrorHandlingUtil.handlePodInstallError(
|
||||||
podInstallCommand.joinToString(" "),
|
podInstallCommand.joinToString(" "),
|
||||||
|
|||||||
+18
-8
@@ -7,8 +7,11 @@
|
|||||||
package org.jetbrains.kotlin.gradle.tasks
|
package org.jetbrains.kotlin.gradle.tasks
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.file.FileSystemOperations
|
||||||
import org.gradle.api.file.FileTree
|
import org.gradle.api.file.FileTree
|
||||||
|
import org.gradle.api.model.ObjectFactory
|
||||||
import org.gradle.api.tasks.*
|
import org.gradle.api.tasks.*
|
||||||
|
import org.gradle.process.ExecOperations
|
||||||
import org.jetbrains.kotlin.gradle.plugin.cocoapods.asValidFrameworkName
|
import org.jetbrains.kotlin.gradle.plugin.cocoapods.asValidFrameworkName
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
|
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||||
@@ -23,6 +26,7 @@ import org.jetbrains.kotlin.konan.util.visibleName
|
|||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class FrameworkDsymLayout(val rootDir: File) {
|
class FrameworkDsymLayout(val rootDir: File) {
|
||||||
init {
|
init {
|
||||||
@@ -110,7 +114,13 @@ class FrameworkDescriptor(
|
|||||||
/**
|
/**
|
||||||
* Task running lipo to create a fat framework from several simple frameworks. It also merges headers, plists and module files.
|
* Task running lipo to create a fat framework from several simple frameworks. It also merges headers, plists and module files.
|
||||||
*/
|
*/
|
||||||
open class FatFrameworkTask : DefaultTask() {
|
open class FatFrameworkTask
|
||||||
|
@Inject
|
||||||
|
internal constructor(
|
||||||
|
private val execOperations: ExecOperations,
|
||||||
|
private val fileOperations: FileSystemOperations,
|
||||||
|
private val objectFactory: ObjectFactory,
|
||||||
|
) : DefaultTask() {
|
||||||
init {
|
init {
|
||||||
onlyIf { HostManager.hostIsMac }
|
onlyIf { HostManager.hostIsMac }
|
||||||
}
|
}
|
||||||
@@ -150,7 +160,7 @@ open class FatFrameworkTask : DefaultTask() {
|
|||||||
@get:InputFiles
|
@get:InputFiles
|
||||||
@get:SkipWhenEmpty
|
@get:SkipWhenEmpty
|
||||||
protected val inputFrameworkFiles: Iterable<FileTree>
|
protected val inputFrameworkFiles: Iterable<FileTree>
|
||||||
get() = frameworks.map { project.fileTree(it.file) }
|
get() = frameworks.map { objectFactory.fileTree().from(it.file) }
|
||||||
|
|
||||||
@get:PathSensitive(PathSensitivity.ABSOLUTE)
|
@get:PathSensitive(PathSensitivity.ABSOLUTE)
|
||||||
@get:IgnoreEmptyDirectories
|
@get:IgnoreEmptyDirectories
|
||||||
@@ -160,7 +170,7 @@ open class FatFrameworkTask : DefaultTask() {
|
|||||||
framework.files.dSYM.takeIf {
|
framework.files.dSYM.takeIf {
|
||||||
it.exists()
|
it.exists()
|
||||||
}?.rootDir?.let {
|
}?.rootDir?.let {
|
||||||
project.fileTree(it)
|
objectFactory.fileTree().from(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +276,7 @@ open class FatFrameworkTask : DefaultTask() {
|
|||||||
val commands = mutableListOf<String>()
|
val commands = mutableListOf<String>()
|
||||||
var ignoreExitValue = false
|
var ignoreExitValue = false
|
||||||
|
|
||||||
fun run() = project.exec { exec ->
|
fun run() = execOperations.exec { exec ->
|
||||||
exec.executable = "/usr/libexec/PlistBuddy"
|
exec.executable = "/usr/libexec/PlistBuddy"
|
||||||
commands.forEach {
|
commands.forEach {
|
||||||
exec.args("-c", it)
|
exec.args("-c", it)
|
||||||
@@ -285,7 +295,7 @@ open class FatFrameworkTask : DefaultTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun runLipo(inputFiles: Collection<File>, outputFile: File) =
|
private fun runLipo(inputFiles: Collection<File>, outputFile: File) =
|
||||||
project.exec { exec ->
|
execOperations.exec { exec ->
|
||||||
exec.executable = "/usr/bin/lipo"
|
exec.executable = "/usr/bin/lipo"
|
||||||
exec.args = listOf(
|
exec.args = listOf(
|
||||||
"-create",
|
"-create",
|
||||||
@@ -295,7 +305,7 @@ open class FatFrameworkTask : DefaultTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun runInstallNameTool(file: File, frameworkName: String) {
|
private fun runInstallNameTool(file: File, frameworkName: String) {
|
||||||
project.exec { exec ->
|
execOperations.exec { exec ->
|
||||||
exec.executable = "install_name_tool"
|
exec.executable = "install_name_tool"
|
||||||
exec.args = listOf(
|
exec.args = listOf(
|
||||||
"-id",
|
"-id",
|
||||||
@@ -362,7 +372,7 @@ open class FatFrameworkTask : DefaultTask() {
|
|||||||
|
|
||||||
// Use Info.plist of one of the frameworks to get basic data.
|
// Use Info.plist of one of the frameworks to get basic data.
|
||||||
val baseInfo = frameworks.first().files.infoPlist
|
val baseInfo = frameworks.first().files.infoPlist
|
||||||
project.copy {
|
fileOperations.copy {
|
||||||
it.from(baseInfo)
|
it.from(baseInfo)
|
||||||
it.into(outputFile.parentFile)
|
it.into(outputFile.parentFile)
|
||||||
}
|
}
|
||||||
@@ -413,7 +423,7 @@ open class FatFrameworkTask : DefaultTask() {
|
|||||||
// Copy dSYM's Info.plist.
|
// 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.
|
// It doesn't contain target-specific info or framework names except the bundle id so there is no need to edit it.
|
||||||
// TODO: handle bundle id.
|
// TODO: handle bundle id.
|
||||||
project.copy {
|
fileOperations.copy {
|
||||||
it.from(dsymInputs.values.first().infoPlist)
|
it.from(dsymInputs.values.first().infoPlist)
|
||||||
it.into(fatDsym.infoPlist.parentFile)
|
it.into(fatDsym.infoPlist.parentFile)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user