[K/N][build] Fix Native plugin: remove archive file before adding
Merge-request: KT-MR-8783 Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
86af01439c
commit
9ea299b0e7
@@ -54,6 +54,7 @@ abstract class ToolExecutionTask : DefaultTask() {
|
|||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun action() {
|
fun action() {
|
||||||
|
if (output.exists()) output.delete()
|
||||||
project.exec {
|
project.exec {
|
||||||
executable(cmd)
|
executable(cmd)
|
||||||
args(*this@ToolExecutionTask.args.toTypedArray())
|
args(*this@ToolExecutionTask.args.toTypedArray())
|
||||||
@@ -79,7 +80,7 @@ class ToolPatternImpl(val extension: NativeToolsExtension, val output:String, va
|
|||||||
override fun env(name: String) = emptyArray<String>()
|
override fun env(name: String) = emptyArray<String>()
|
||||||
|
|
||||||
fun configure(task: ToolExecutionTask, configureDepencies:Boolean) {
|
fun configure(task: ToolExecutionTask, configureDepencies:Boolean) {
|
||||||
extension.cleanupfiles += output
|
extension.cleanupFiles += output
|
||||||
task.input = input.map {
|
task.input = input.map {
|
||||||
extension.project.file(it)
|
extension.project.file(it)
|
||||||
}
|
}
|
||||||
@@ -184,7 +185,7 @@ class ToolConfigurationPatterns(
|
|||||||
open class NativeToolsExtension(val project: Project) {
|
open class NativeToolsExtension(val project: Project) {
|
||||||
val sourceSets = SourceSets(project, this, mutableMapOf<String, SourceSet>())
|
val sourceSets = SourceSets(project, this, mutableMapOf<String, SourceSet>())
|
||||||
val toolPatterns = ToolConfigurationPatterns(this, mutableMapOf<Pair<String, String>, ToolPatternConfiguration>())
|
val toolPatterns = ToolConfigurationPatterns(this, mutableMapOf<Pair<String, String>, ToolPatternConfiguration>())
|
||||||
val cleanupfiles = mutableListOf<String>()
|
val cleanupFiles = mutableListOf<String>()
|
||||||
fun sourceSet(configuration: SourceSets.() -> Unit) {
|
fun sourceSet(configuration: SourceSets.() -> Unit) {
|
||||||
sourceSets.configuration()
|
sourceSets.configuration()
|
||||||
}
|
}
|
||||||
@@ -197,13 +198,13 @@ open class NativeToolsExtension(val project: Project) {
|
|||||||
fun suffixes(configuration: ToolConfigurationPatterns.() -> Unit) = toolPatterns.configuration()
|
fun suffixes(configuration: ToolConfigurationPatterns.() -> Unit) = toolPatterns.configuration()
|
||||||
|
|
||||||
fun target(name: String, vararg objSet: SourceSet, configuration: ToolPatternConfiguration) {
|
fun target(name: String, vararg objSet: SourceSet, configuration: ToolPatternConfiguration) {
|
||||||
project.tasks.withType<Delete>().named(LifecycleBasePlugin.CLEAN_TASK_NAME).configure {
|
project.tasks.named(LifecycleBasePlugin.CLEAN_TASK_NAME, Delete::class.java).configure {
|
||||||
doLast {
|
doLast {
|
||||||
delete(*this@NativeToolsExtension.cleanupfiles.toTypedArray())
|
delete(*this@NativeToolsExtension.cleanupFiles.toTypedArray())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets.project.tasks.create<ToolExecutionTask>(name, ToolExecutionTask::class.java) {
|
sourceSets.project.tasks.create(name, ToolExecutionTask::class.java) {
|
||||||
objSet.forEach {
|
objSet.forEach {
|
||||||
dependsOn(it.implicitTasks())
|
dependsOn(it.implicitTasks())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,6 @@ native {
|
|||||||
val objSet = sourceSets["main"]!!.transform(".cpp" to ".$obj")
|
val objSet = sourceSets["main"]!!.transform(".cpp" to ".$obj")
|
||||||
target(lib("clangext"), objSet) {
|
target(lib("clangext"), objSet) {
|
||||||
tool(*platformManager.hostPlatform.clangForJni.llvmAr("").toTypedArray())
|
tool(*platformManager.hostPlatform.clangForJni.llvmAr("").toTypedArray())
|
||||||
flags("-qv", ruleOut(), *ruleInAll())
|
flags("-qcv", ruleOut(), *ruleInAll())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ native {
|
|||||||
|
|
||||||
target(lib("llvmext"), objSet) {
|
target(lib("llvmext"), objSet) {
|
||||||
tool(*platformManager.hostPlatform.clangForJni.llvmAr("").toTypedArray())
|
tool(*platformManager.hostPlatform.clangForJni.llvmAr("").toTypedArray())
|
||||||
flags("-qv", ruleOut(), *ruleInAll())
|
flags("-qcv", ruleOut(), *ruleInAll())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,6 @@ native {
|
|||||||
|
|
||||||
target(lib("debugInfo"), objSet) {
|
target(lib("debugInfo"), objSet) {
|
||||||
tool(*platformManager.hostPlatform.clangForJni.llvmAr("").toTypedArray())
|
tool(*platformManager.hostPlatform.clangForJni.llvmAr("").toTypedArray())
|
||||||
flags("-qv", ruleOut(), *ruleInAll())
|
flags("-qcv", ruleOut(), *ruleInAll())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user