-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy pathgen.scala
35 lines (30 loc) · 1.01 KB
/
gen.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//> using scala "2.13"
//> using dep "com.thesamet.scalapb::scalapbc:0.11.13"
import scalapb.ScalaPBC
class ProtobufGenerator {
def metadataJson: String =
s"""{
| "name" : "Protobuf generator",
| "version" : "1.0.0",
| "supportedExtensions" : ["proto"],
| "isReferentiallyTransparent" : true
|}""".stripMargin
def generate(inputLocation: String, outputLocation: String): Unit = {
ScalaPBC.main(Array(
s"--scala_out=${outputLocation}",
"-I", "/Users/mgajek/Projects/scala-cli-sandbox/source-generators/",
inputLocation
))
}
}
object Main {
def main(args: Array[String]) = {
val outputDir = args.headOption.getOrElse(throw new Exception("Output dir not specified"))
val sources = args.tail.toList
val generator = new ProtobufGenerator()
sources.foreach { source =>
println(s"Running protobuf generation from [$source] to [$outputDir]")
generator.generate(source, outputDir)
}
}
}