Adam S
09/21/2024, 9:01 AMtasks.named<Sync>("syncLinkedLibs${konanTargetName}${buildType}")
syncs the libs into directory build/macosx64/debug/
I then need to tell all KotlinNativeTarget
compilation tasks about the relevant libs. I can do that manually...
kotlin.targets.withType<KotlinNativeTarget>().configureEach {
val konanTargetName = konanTarget.presetName.uppercaseFirstChar()
binaries.configureEach {
@OptIn(ExperimentalPathApi::class)
fun TaskProvider<KotlinNativeCompile>.dependOnSyncedLibs(buildType: NativeBuildType): Unit = letConfigure { task ->
val type = when (buildType) {
NativeBuildType.RELEASE -> "Release"
NativeBuildType.DEBUG -> "Debug"
}
val syncLibsTask = tasks.named<Sync>("syncLinkedLibs${konanTargetName}${type}")
val syncLinkedLibs = objects.fileCollection().from(syncLibsTask)
task.inputs.files(syncLinkedLibs).withPathSensitivity(RELATIVE)
val includeBinaryArgs = syncLinkedLibs.elements.map { elements ->
elements
.asSequence()
.flatMap {
val p = it.asFile.toPath()
if (p.isRegularFile()) sequenceOf(p)
else p.walk()
}
.filter { it.isRegularFile() }
.flatMap { listOf("-include-binary", it.absolute().invariantSeparatorsPathString) }
.sorted()
.toList()
}
task.compilerOptions {
this.freeCompilerArgs.addAll(includeBinaryArgs)
}
}
compilation.compileTaskProvider.dependOnSyncedLibs(buildType)
}
}
but I don't like the string-based task selection. I also want to release this as a Gradle plugin, so I want a more ergonomic API.
Is there a ✨pretty✨ way of 'transferring' the files, maybe with Gradle Configurations?hfhbd
09/21/2024, 9:40 AMAdam S
09/21/2024, 10:42 AMAdam S
09/21/2024, 10:43 AM