proto2typescript working!!!!!!!!!!!!!
This commit is contained in:
parent
6dce641d6b
commit
00b3dc3554
6 changed files with 91 additions and 27 deletions
|
|
@ -16,8 +16,6 @@ plugins {
|
|||
id("dev.adamko.factoriowebmap.archetype.node")
|
||||
}
|
||||
|
||||
|
||||
|
||||
kotlin {
|
||||
js(IR) {
|
||||
binaries.executable()
|
||||
|
|
|
|||
|
|
@ -22,21 +22,23 @@ class KotlinMultiplatformProjectConfiguration : Plugin<Project> {
|
|||
this.name
|
||||
}
|
||||
//
|
||||
// val protoJvm = this.sourceSets.maybeCreate("protoJvm").apply {
|
||||
// kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/java"))
|
||||
// kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/kotlin"))
|
||||
// }
|
||||
//
|
||||
// val protoTypescript = this.sourceSets.maybeCreate("protoJvm").apply {
|
||||
// kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/typescript"))
|
||||
// }
|
||||
val protoJvm = this.sourceSets.maybeCreate("protoJvm").apply {
|
||||
kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/java"))
|
||||
kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/kotlin"))
|
||||
}
|
||||
|
||||
this.sourceSets.named("jvmMain").configure {
|
||||
val protoTypescript = this.sourceSets.maybeCreate("protoJvm").apply {
|
||||
kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/typescript"))
|
||||
}
|
||||
|
||||
this.sourceSets.findByName("jvmMain")?.apply {
|
||||
// protoJvm.dependsOn(this)
|
||||
// dependsOn(protoJvm)
|
||||
kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/java"))
|
||||
kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/kotlin"))
|
||||
}
|
||||
this.sourceSets.named("jsMain").configure {
|
||||
this.sourceSets.findByName("jsMain")?.apply {
|
||||
// protoTypescript.dependsOn(this)
|
||||
// dependsOn(protoTypescript)
|
||||
kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/typescript"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ plugins {
|
|||
base
|
||||
}
|
||||
|
||||
|
||||
// TODO investigate builtBy and sourceDirectorySet?
|
||||
// project.objects.fileCollection().builtBy()
|
||||
// val pbSrcSet = project.objects.sourceDirectorySet("protobuf", "protobuf")
|
||||
|
|
@ -77,19 +76,19 @@ val protobufPrepareLibrariesTask =
|
|||
//// implementation("com.google.protobuf:protobuf-kotlin-lite:3.19.1")
|
||||
//}
|
||||
|
||||
|
||||
/** Convert `.proto` files to Kotlin */
|
||||
val pbCompileTask = project.tasks.register<ProtobufCompileTask>(Constants.PBG_TASK_COMPILE) {
|
||||
project.tasks.withType<ProtobufCompileTask> {
|
||||
dependsOn(protocDep, protobufPrepareLibrariesTask)
|
||||
|
||||
protobufLibraryDirectories.add(protobufPrepareLibrariesTask.flatMap { it.librariesDirectory })
|
||||
|
||||
protocOutputs += KotlinOutput()
|
||||
protocOutputs += JavaOutput()
|
||||
|
||||
val exe = protocDep.singleFile
|
||||
logger.lifecycle("protoc.exe: $exe")
|
||||
protocExecutable.set(exe)
|
||||
}
|
||||
|
||||
/** Convert `.proto` files to Kotlin */
|
||||
val pbCompileTask = project.tasks.register<ProtobufCompileTask>(Constants.PBG_TASK_COMPILE) {
|
||||
protocOutputs += KotlinOutput()
|
||||
protocOutputs += JavaOutput()
|
||||
}
|
||||
|
||||
project.tasks.assemble { dependsOn(pbCompileTask) }
|
||||
|
|
@ -33,6 +33,9 @@ abstract class ProtobufCompileTask : DefaultTask() {
|
|||
abstract val protocOutputs: DomainObjectSet<ProtocOutput>
|
||||
// = project.objects.domainObjectSet(ProtocOutput::class.java)
|
||||
|
||||
@get:Input
|
||||
abstract val cliArgs: ListProperty<String>
|
||||
|
||||
@get:InputFile
|
||||
abstract val protoFile: RegularFileProperty
|
||||
|
||||
|
|
@ -48,7 +51,7 @@ abstract class ProtobufCompileTask : DefaultTask() {
|
|||
fun compile() {
|
||||
|
||||
val workDir = temporaryDir
|
||||
project.delete(workDir)
|
||||
// project.delete(workDir)
|
||||
|
||||
project.exec {
|
||||
executable(protocExecutable.asFile.get())
|
||||
|
|
@ -65,9 +68,11 @@ abstract class ProtobufCompileTask : DefaultTask() {
|
|||
// set args
|
||||
mapOutputsToOutputDir
|
||||
.map { (opt, dir) ->
|
||||
"${opt.cliParam}=${opt.protocOptions}:${dir}"
|
||||
val optionsSuffix = if (opt.protocOptions.isBlank()) "" else ":"
|
||||
"${opt.cliParam}=${opt.protocOptions}$optionsSuffix$dir"
|
||||
}
|
||||
.also { args(it) }
|
||||
args(cliArgs.get())
|
||||
|
||||
val protoPath = cliParamProtoPath.get()
|
||||
val libArgs = protobufLibraryDirectories.get().map { "$protoPath${it.asFile}" }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue