First toolflow version
This commit is contained in:
10
toolflow/src/main/scala/com/minres/tgc/hammer/Global.scala
Normal file
10
toolflow/src/main/scala/com/minres/tgc/hammer/Global.scala
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.minres.tgc.hammer
|
||||
|
||||
import os.Path
|
||||
|
||||
object Global {
|
||||
def pathFromEnv(env: String): Option[Path] = sys.env.get("string").map { rawPath => Path(rawPath, os.pwd) }
|
||||
lazy val HAMMER: Path = pathFromEnv("TGC_HAMMER_HOME").get
|
||||
lazy val WORKDIR: Path = pathFromEnv("TGC_HAMMER_WORKDIR").get
|
||||
lazy val TREENAIL: Path = HAMMER / "deps" / "treenail"
|
||||
}
|
17
toolflow/src/main/scala/com/minres/tgc/hammer/Main.scala
Normal file
17
toolflow/src/main/scala/com/minres/tgc/hammer/Main.scala
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.minres.tgc.hammer
|
||||
|
||||
import com.minres.tgc.hammer.cli.{HammerConf, MySubcommand}
|
||||
|
||||
object Main {
|
||||
def main(args: Array[String]): Unit = {
|
||||
val conf = new HammerConf(args.toIndexedSeq)
|
||||
|
||||
conf.subcommand match {
|
||||
case Some(c: MySubcommand) =>
|
||||
val tasks = c.getRequiredTasks
|
||||
tasks.foreach(_.validate())
|
||||
tasks.foreach(_.execute())
|
||||
case _ =>
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package com.minres.tgc.hammer.cli
|
||||
|
||||
import org.rogach.scallop.ScallopConf
|
||||
|
||||
class HammerConf(arguments: Seq[String]) extends ScallopConf(arguments) {
|
||||
addSubcommand(new TreenailCommand)
|
||||
|
||||
verify()
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.minres.tgc.hammer.cli
|
||||
|
||||
import com.minres.tgc.hammer.tasks.Task
|
||||
import org.rogach.scallop.Subcommand
|
||||
|
||||
abstract class MySubcommand(name: String) extends Subcommand(name) {
|
||||
def getRequiredTasks: Seq[Task]
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.minres.tgc.hammer.cli
|
||||
|
||||
import com.minres.tgc.hammer.tasks.{Task, TreenailTask}
|
||||
import org.rogach.scallop.*
|
||||
|
||||
import java.io.File
|
||||
import os.Path
|
||||
|
||||
class TreenailCommand extends MySubcommand("parseCoreDSL") {
|
||||
val coreDSL: ScallopOption[File] = trailArg[File]("coreDSL")
|
||||
val output: ScallopOption[File] = opt[File](short = 'o', default = Some(new File("isax.mlir")))
|
||||
|
||||
validateFileExists(coreDSL)
|
||||
validateFileIsFile(coreDSL)
|
||||
|
||||
override def getRequiredTasks: Seq[Task] = Seq(
|
||||
new TreenailTask(Path(coreDSL(), os.pwd), Path(output(), os.pwd))
|
||||
)
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package com.minres.tgc.hammer.tasks
|
||||
|
||||
import os.{Path, Shellable}
|
||||
|
||||
trait Task {
|
||||
def validate(): Unit
|
||||
def execute(): Unit
|
||||
|
||||
def runExecutable(execPath: Path, args: Shellable*): os.CommandResult = {
|
||||
os.proc(execPath, args).call()
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.minres.tgc.hammer.tasks
|
||||
|
||||
import com.minres.tgc.hammer.Global
|
||||
|
||||
import os.*
|
||||
|
||||
class TreenailTask(coreDSLInput: Path, output: Path) extends Task {
|
||||
private val EXECUTABLE = Global.TREENAIL / "app" / "build" / "install" / "app" / "bin" / "app"
|
||||
|
||||
override def validate(): Unit = {
|
||||
assert(isFile(EXECUTABLE), "Treenail Executable is missing, build Treenail")
|
||||
}
|
||||
override def execute(): Unit = {
|
||||
runExecutable(EXECUTABLE, "-o", output, coreDSLInput)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user