mirror of
https://github.com/enso-org/enso.git
synced 2024-11-23 08:08:34 +03:00
30 lines
708 B
Scala
30 lines
708 B
Scala
|
import sbt.Keys._
|
||
|
import sbt._
|
||
|
|
||
|
import scala.sys.process._
|
||
|
|
||
|
object GenerateFlatbuffers {
|
||
|
|
||
|
lazy val task = Def.task {
|
||
|
val flatcCmd = "flatc"
|
||
|
val root = baseDirectory.value
|
||
|
val schemas =
|
||
|
(file(s"$root/src/main/schema") ** "*.fbs").get
|
||
|
.map(_.getAbsolutePath)
|
||
|
.toList
|
||
|
|
||
|
val out = (sourceManaged in Compile).value
|
||
|
|
||
|
schemas foreach { schema =>
|
||
|
val cmd = s"$flatcCmd --java -o ${out.getAbsolutePath} $schema"
|
||
|
println(s"*** Generating Java classes for schema: $schema, cmd: $cmd")
|
||
|
val result = cmd.!!
|
||
|
println(
|
||
|
s"*** Generated Java classes from FlatBuffer schema $schema. Results: $result"
|
||
|
)
|
||
|
}
|
||
|
(out ** "*.java").get
|
||
|
}
|
||
|
|
||
|
}
|