Commit 9db79f78 authored by Jens Korinth's avatar Jens Korinth
Browse files

Squashed 'packaging/' changes from d2df30ff..99804e52

99804e52 Add build.sbt to define artifact
401df026 Add support for post-build actions

git-subtree-dir: packaging
git-subtree-split: 99804e52
parent 524cfa5f
......@@ -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) !
......
name := "chisel-packaging"
organization := "esa.cs.tu-darmstadt.de"
version := "0.2-SNAPSHOT"
scalaVersion := "2.11.0"
crossScalaVersions := Seq("2.10.3", "2.10.4", "2.11.0")
libraryDependencies ++= Seq(
"edu.berkeley.cs" %% "chisel" % "latest.release",
"com.typesafe.play" %% "play-json" % "2.4.8"
)
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