forked from icerockdev/moko-kswift
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostProcessLinkTask.kt
More file actions
39 lines (33 loc) · 1.33 KB
/
PostProcessLinkTask.kt
File metadata and controls
39 lines (33 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/
package dev.icerock.moko.kswift.plugin
import org.gradle.api.Action
import org.gradle.api.Task
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink
import java.io.File
internal class PostProcessLinkTask(
private val framework: Framework,
private val processor: KLibProcessor,
private val kSwiftExtension: KSwiftExtension,
) : Action<Task> {
override fun execute(task: Task) {
val linkTask: KotlinNativeLink = task as KotlinNativeLink
val kotlinFrameworkName = framework.baseName
val swiftFrameworkName = "${kotlinFrameworkName}Swift"
val outputDir = File(framework.outputDirectory, swiftFrameworkName)
outputDir.deleteRecursively()
linkTask.inputs.files
.filter { file ->
val name = file.nameWithoutExtension
if (kSwiftExtension.includedLibs.isNotEmpty()) {
if (kSwiftExtension.includedLibs.contains(name).not()) return@filter false
}
kSwiftExtension.excludedLibs.contains(name).not()
}
.forEach { library ->
processor.processFeatureContext(library, outputDir, framework)
}
}
}