Skip to content

Commit

Permalink
feat: create stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
ttypic committed Mar 7, 2022
1 parent da0c229 commit 1b801e4
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 20 deletions.
12 changes: 0 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
buildscript {
repositories {
google()
mavenCentral()
}

dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0")
}
}

allprojects {
repositories {
mavenLocal()
mavenCentral()
google()
}
}

2 changes: 1 addition & 1 deletion plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("java-gradle-plugin")
kotlin("jvm")
kotlin("jvm") version "1.7.22"
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
package com.ttypic.swiftklib.gradle

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


abstract class SwiftKlibEntry @Inject constructor(val name: String) {
var targets: MutableSet<String> = mutableSetOf()
}

abstract val pathProperty: Property<File>
abstract val packageNameProperty: Property<String>

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

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ class SwiftKlibPlugin : Plugin<Project> {
}

targetToTaskName.entries.forEach { (target, taskName) ->
tasks.register(taskName, CompileSwift::class.java, name, target)
tasks.register(
taskName,
CompileSwift::class.java,
name,
target,
entry.path,
entry.packageNameProperty.get(),
)
}

libNameToTargetToTaskName.set(name, targetToTaskName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,56 @@ package com.ttypic.swiftklib.gradle.task
import org.gradle.api.DefaultTask
import com.ttypic.swiftklib.gradle.CompileTarget
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import java.io.File
import javax.inject.Inject

open class CompileSwift @Inject constructor(
open class CompileSwift @Inject constructor(
@Input val cinteropName: String,
@Input val compileTarget: CompileTarget
@Input val compileTarget: CompileTarget,
@Input val path: File,
@Input val packageName: String,
) : DefaultTask() {

@get:Internal
internal val targetDir: File
get() {
return project.buildDir.resolve("swiftklib/$cinteropName/$compileTarget")
}

@get:OutputDirectory
val swiftBuildDir
get() = File(targetDir, "swiftBuild")

@get:OutputFile
val defFile
get() = File(targetDir, "$cinteropName.def")

@TaskAction
fun produce() {
println("\n\n\n\n\n\n\n$compileTarget\n\n$cinteropName\n\n\n\n")
swiftBuildDir.mkdirs()
createPackageSwift()
val (libPath, headerPath) = buildSwift()
createDefFile(libPath, headerPath)
}

private fun createPackageSwift() {
TODO("Not yet implemented")
}
}

private fun buildSwift(): SwiftBuildResult {
TODO("Not yet implemented")
}

private fun createDefFile(libPath: File, headerPath: File) {
TODO("Not yet implemented")
}
}

private data class SwiftBuildResult(
val libPath: File,
val headerPath: File,
)

0 comments on commit 1b801e4

Please sign in to comment.