Commit eac01b7a authored by Jens Korinth's avatar Jens Korinth
Browse files

Add support for post-build actions

parent d2df30ff
......@@ -2,11 +2,13 @@ package chisel.packaging
import scala.io.Source
import play.api.libs.json._
import play.api.libs.functional.syntax._
import Chisel.Module
/**
* Basic definition of a core for IP-XACT packaging.
**/
case class CoreDefinition(name: String, vendor: String, library: String, version: String, root: String) {
class CoreDefinition(val name: String, val vendor: String, val library: String, val version: String,
val root: String, val postBuildActions: Seq[Module => Unit] = Seq()) {
import CoreDefinition._
def write(filename: String) : Boolean = try {
val fw = new java.io.FileWriter(filename)
......@@ -21,6 +23,16 @@ case class CoreDefinition(name: String, vendor: String, library: String, version
* Contains methods for reading a core definition from Json.
**/
object CoreDefinition {
def apply(name: String, vendor: String, library: String, version: String, root: String): CoreDefinition =
new CoreDefinition(name, vendor, library, version, root)
def withActions(name: String, vendor: String, library: String, version: String, root: String,
postBuildActions: Seq[Module => Unit]): CoreDefinition =
new CoreDefinition(name, vendor, library, version, root, postBuildActions)
def unapply(cd: CoreDefinition): Option[Tuple5[String, String, String, String, String]] =
Some((cd.name, cd.vendor, cd.library, cd.version, cd.root))
/** Provide automatic IP directory for given name. **/
def root(name: String): String =
java.nio.file.Paths.get(".").toAbsolutePath.resolveSibling("ip").resolve(name).toString
......
......@@ -20,6 +20,7 @@ abstract class ModuleBuilder(packagingDir: String = "packaging") {
assert (fm.length > 0, "no matching cores found for: " + args.mkString(", "))
fm foreach { m =>
chiselMain(chiselArgs ++ Array("--targetDir", m._2.root), m._1)
m._2.postBuildActions map (fn => fn.apply(m._1()))
val json = "%s/%s.json".format(m._2.root, m._2.name)
m._2.write(json)
"%s/package.py %s".format(packagingDir, json) !
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment