Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
sbt: init plugin with ice40 tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed May 10, 2024
1 parent 62d00d1 commit b576511
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
23 changes: 21 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
ThisBuild / scalaVersion := "2.13.12"
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / organization := "ee.hrzn"
ThisBuild / versionScheme := Some("early-semver")
ThisBuild / homepage := Some(url("https://github.com/hrzn-ee/chryse"))

val chiselVersion = "6.3.0"

lazy val root = (project in file("."))
.settings(
name := "chryse",
name := "chryse",
scalaVersion := "2.13.12",
libraryDependencies ++= Seq(
"org.chipsalliance" %% "chisel" % chiselVersion,
"org.scalatest" %% "scalatest" % "3.2.18" % "test",
Expand All @@ -21,3 +22,21 @@ lazy val root = (project in file("."))
"org.chipsalliance" % "chisel-plugin" % chiselVersion cross CrossVersion.full,
),
)

lazy val sbtchryse = (project in file("sbt-chryse"))
.enablePlugins(SbtPlugin)
.settings(
name := "sbt-chryse",
sbtPlugin := true,
pluginCrossBuild / sbtVersion := {
scalaBinaryVersion.value match {
case "2.12" => "1.9.7"
}
},
scalacOptions ++= Seq(
// What do these even do, hey
"-deprecation",
"-feature",
"-Xcheckinit",
),
)
33 changes: 33 additions & 0 deletions sbt-chryse/src/main/scala/ee/hrzn/chryse/SbtChryse.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package ee.hrzn.chryse.sbt

import sbt._
import sbt.Keys._

import scala.sys.process._

object SbtChryse extends AutoPlugin {
override def trigger = AllRequirements

object autoImport {
val chryseIce40 = inputKey[Unit]("Elaborate and synthesise for ice40")

val chryseIce40Prog =
inputKey[Unit]("Elaborate, synthesise for ice40, and program the board")
}
import autoImport._

override lazy val projectSettings = Seq(
chryseIce40 := {
(Compile / run).evaluated
if (("make ice40".!) != 0) {
throw new IllegalStateException("ice40 failed to synthesise")
}
},
chryseIce40Prog := {
chryseIce40.evaluated
if (("make ice40-prog".!) != 0) {
throw new IllegalStateException("ice40 failed to synthesise")
}
},
)
}

0 comments on commit b576511

Please sign in to comment.