Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use clang modules in cinterop instead of headers #32

Merged
9 changes: 9 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@ kotlin = "2.0.0"

gradlePublishPlugin = "1.2.1"

junit-jupiter = "5.8.0"

kotest = "5.9.1"

[libraries]

plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }

test-junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
test-junit-jupiter-launcher = { module = "org.junit.jupiter:junit-jupiter-engine" }
test-kotest-assertions = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }


[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
gradle-publish = { id = "com.gradle.plugin-publish", version.ref = "gradlePublishPlugin" }
9 changes: 9 additions & 0 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ plugins {
dependencies {
implementation(gradleApi())
implementation(libs.plugin.kotlin)

testImplementation(gradleTestKit())
testImplementation(libs.test.junit.jupiter)
testImplementation(libs.test.kotest.assertions)
testRuntimeOnly(libs.test.junit.jupiter.launcher)
}

tasks.named<Test>("test") {
useJUnitPlatform()
}

version = "0.5.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,21 @@
package io.github.ttypic.swiftklib.gradle

import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import java.io.File
import javax.inject.Inject

abstract class SwiftKlibEntry @Inject constructor(val name: String) {
abstract class SwiftKlibEntry @Inject constructor(
val name: String,
objects: ObjectFactory,
) {

abstract val pathProperty: Property<File>
abstract val packageNameProperty: Property<String>
abstract val minIosProperty: Property<Int>
abstract val minMacosProperty: Property<Int>
abstract val minTvosProperty: Property<Int>
abstract val minWatchosProperty: Property<Int>
val path: Property<File> = objects.property(File::class.java)
val packageName: Property<String> = objects.property(String::class.java)
val minIos: Property<Int> = objects.property(Int::class.java)
val minMacos: Property<Int> = objects.property(Int::class.java)
val minTvos: Property<Int> = objects.property(Int::class.java)
val minWatchos: Property<Int> = objects.property(Int::class.java)

var path: File
get() = pathProperty.get()
set(value) {
pathProperty.set(value)
}

fun packageName(name: String) = packageNameProperty.set(name)

var minIos: Int
get() = minIosProperty.get()
set(value) {
minIosProperty.set(value)
}

var minMacos: Int
get() = minMacosProperty.get()
set(value) {
minMacosProperty.set(value)
}

var minTvos: Int
get() = minTvosProperty.get()
set(value) {
minTvosProperty.set(value)
}

var minWatchos: Int
get() = minWatchosProperty.get()
set(value) {
minWatchosProperty.set(value)
}
fun packageName(name: String) = packageName.set(name)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.gradle.tasks.CInteropProcess

const val EXTENSION_NAME = "swiftklib"

@Suppress("unused")
class SwiftKlibPlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
val objects: ObjectFactory = project.objects
Expand All @@ -24,22 +25,24 @@ class SwiftKlibPlugin : Plugin<Project> {
swiftKlibEntries.all { entry ->
val name: String = entry.name

val targetToTaskName = CompileTarget.values().associateWith {
val targetToTaskName = CompileTarget.entries.associateWith {
getTaskName(name, it)
}

val buildDir = project.layout.buildDirectory.asFile.get().absolutePath
targetToTaskName.entries.forEach { (target, taskName) ->
tasks.register(
taskName,
CompileSwiftTask::class.java,
name,
target,
entry.pathProperty,
entry.packageNameProperty,
entry.minIosProperty,
entry.minMacosProperty,
entry.minTvosProperty,
entry.minWatchosProperty,
buildDir,
entry.path,
entry.packageName,
entry.minIos,
entry.minMacos,
entry.minTvos,
entry.minWatchos,
)
}
}
Expand Down
Loading