Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skeleton and sbt-chisel-dep #78

Open
escou64 opened this issue Aug 18, 2020 · 2 comments
Open

skeleton and sbt-chisel-dep #78

escou64 opened this issue Aug 18, 2020 · 2 comments

Comments

@escou64
Copy link

escou64 commented Aug 18, 2020

I'm currently trying to use subprojects as described in the skeleton branch and with sbt-chisel-dep.
Here is the hierarchy of my projetc and an example of build.sbt:

  • myproj/
    • build.sbt
    • src/
    • subproj1/
      • build.sbt
      • src/
    • subproj2/
      • build.sbt
      • src/

def scalacOptionsVersion(scalaVersion: String): Seq[String] = {
  Seq() ++ {
    // If we're building with Scala > 2.11, enable the compile option
    //  switch to support our anonymous Bundle definitions:
    //  https://github.com/scala/bug/issues/10047
    CrossVersion.partialVersion(scalaVersion) match {
      case Some((2, scalaMajor: Long)) if scalaMajor < 12 => Seq()
      case _ => Seq("-Xsource:2.11")
    }
  }
}

def javacOptionsVersion(scalaVersion: String): Seq[String] = {
  Seq() ++ {
    // Scala 2.12 requires Java 8. We continue to generate
    //  Java 7 compatible code for Scala 2.11
    //  for compatibility with old clients.
    CrossVersion.partialVersion(scalaVersion) match {
      case Some((2, scalaMajor: Long)) if scalaMajor < 12 =>
        Seq("-source", "1.7", "-target", "1.7")
      case _ =>
        Seq("-source", "1.8", "-target", "1.8")
    }
  }
}

scalacOptions ++= scalacOptionsVersion(scalaVersion.value)

javacOptions ++= javacOptionsVersion(scalaVersion.value)

resolvers ++= Seq(
  Resolver.sonatypeRepo("snapshots"),
  Resolver.sonatypeRepo("releases")
)

addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)

// Provide a managed dependency on X if -DXVersion="" is supplied on the command line.
val defaultVersions = Seq(
  "chisel-iotesters" -> "1.4.1+",
  "chiseltest"  -> "0.2.1+"
  )

val projDeps = chisel.dependencies(Seq(
  ("org.myproj" %% "subproj1" % "0.0.1-SNAPSHOT", "gen/subproj1"),
  ("org.myproj" %% "subproj2" % "0.0.1-SNAPSHOT", "gen/subproj2")
))

libraryDependencies ++= defaultVersions.map { case (dep, ver) =>
  "edu.berkeley.cs" %% dep % sys.props.getOrElse(dep + "Version", ver) }
libraryDependencies ++= projDeps.libraries

val dependentProjects = projDeps.projects

lazy val myproj = (project in file("."))
    .settings(
      version := "0.0.1-SNAPSHOT",
      organization := "org.myproj",
      scalaVersion := "2.12.10",
      publishLocal := {},
      publish := {},
      packagedArtifacts := Map.empty,
      libraryDependencies ++= projDeps.libraries
    )
    .dependsOn(dependentProjects.map(classpathDependency(_)): _*)
    .aggregate(dependentProjects: _*)

In subproj2/src/test/scala, I have a ChiselFlatSpec tester hat I run with the sbt command 'testOnly subproj2.Tester'.
But, when I launch it from the myproj directory, it seems to check all the different subproject before launch it:

[info] Run completed in 25 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[info] No tests to run for Test / testOnly
[info] ScalaTest
[info] Run completed in 10 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[info] [0.015] RAN 8 CYCLES PASSED
[info] Tester:
[info] InitRam
[info] - should test read sequences
[info] - should test write sequences
[info] ScalaTest
[info] Run completed in 6 seconds, 173 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[info] Passed: Total 2, Failed 0, Errors 0, Passed 2

It it is not a major problem at the moment (I only have two sub-projects), it could be penalizing if this number increases.
Do you know what this could be due to? Maybe the management of ChiselFlatSpec is not compatible the subprojects or have I badly configured my build.sbt?

@ucbjrl
Copy link
Contributor

ucbjrl commented Aug 18, 2020

Investigation is currently underway into more official techniques to support switching chisel dependencies between source-based and published-jar-based alternatives. Development of sbt-chisel-dep is suspended pending the outcome of this investigation.

@jackkoenig
Copy link
Contributor

@escou64 I wanted to let you know that a better way of handling this was merged in chipsalliance/chisel#1563 and it has a short description in the README: https://github.com/freechipsproject/chisel3#building-chisel-with-firrtl-in-the-same-sbt-project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants