-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add Scala3 support #27
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -233,12 +233,14 @@ object `llvm-firtool` extends JavaModule with ChipsAlliancePublishModule { | |||||||
// ******************** WARNING ******************** | ||||||||
// This is extremely manual and changing dependencies IN ANY WAY (including bumping version) | ||||||||
// requires carefully checking the packages to shade and dynamic ivy deps in the outer project | ||||||||
object `firtool-resolver` extends Cross[FirtoolResolver]("2.13", "2.12") | ||||||||
trait FirtoolResolver extends CrossScalaModule with ChipsAlliancePublishModule { root => | ||||||||
object `firtool-resolver` extends Cross[FirtoolResolver]("2.13", "2.12", "3.4", "3.3") | ||||||||
trait FirtoolResolver extends CrossSbtModule with ChipsAlliancePublishModule { root => | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than switching this to SBT style, I would rather stick with vanilla Mill style. We only use SBT style in Chisel for historical reasons, we could just override |
||||||||
|
||||||||
override def crossScalaVersion = Map( | ||||||||
"2.13" -> "2.13.11", | ||||||||
"2.12" -> "2.12.18" | ||||||||
"2.12" -> "2.12.18", | ||||||||
"3.4" -> "3.4.2", | ||||||||
"3.3" -> "3.3.3" | ||||||||
Comment on lines
+242
to
+243
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Scala 3 maintains binary compatibility across all minor versions so there is no reason to cross compile for any version but 1 in Scala 3 (unlike Scala 2 where it you do have to compile differently for 2.12 and 2.13. |
||||||||
)(crossValue) | ||||||||
|
||||||||
def scalacOptions = Seq("-deprecation", "-feature", "-release:8") | ||||||||
|
@@ -281,8 +283,7 @@ trait FirtoolResolver extends CrossScalaModule with ChipsAlliancePublishModule { | |||||||
ivy"org.scala-lang.modules::scala-collection-compat:2.11.0" | ||||||||
) | ||||||||
|
||||||||
object core extends ScalaModule { | ||||||||
|
||||||||
object core extends CrossSbtModule with CrossValue { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
def scalaVersion = root.scalaVersion | ||||||||
|
||||||||
def scalacOptions = root.scalacOptions | ||||||||
|
@@ -292,10 +293,14 @@ trait FirtoolResolver extends CrossScalaModule with ChipsAlliancePublishModule { | |||||||
|
||||||||
// We cannot use os-lib because it cannot be shaded without screwing up | ||||||||
// getting System property os.name | ||||||||
def ivyDeps = Agg( | ||||||||
ivy"dev.dirs:directories:26", | ||||||||
ivy"io.get-coursier::coursier:2.1.8", | ||||||||
) | ||||||||
def ivyDeps = if (this.crossScalaVersion.startsWith("3")) { | ||||||||
Agg(ivy"dev.dirs:directories:26") | ||||||||
} else { | ||||||||
Agg( | ||||||||
ivy"dev.dirs:directories:26", | ||||||||
ivy"io.get-coursier::coursier:2.1.8", | ||||||||
) | ||||||||
} | ||||||||
|
||||||||
// Modify the classpath to remove things we want to dynamically link (Scala jars). | ||||||||
override def upstreamAssemblyClasspath: T[Agg[PathRef]] = T { | ||||||||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package firtoolresolver | ||
|
||
import scala.util.{Failure, Success, Try} | ||
import java.net.URLClassLoader | ||
import coursier._ | ||
import coursier.core.Extension | ||
|
||
object FetchArtifact { | ||
def apply(logger: Logger, defaultVersion: String): Either[String, FirtoolBinary] = { | ||
val platform = | ||
determinePlatform(logger) match { | ||
case Left(msg) => | ||
logger.debug(msg) | ||
return Left(msg) | ||
case Right(name) => name | ||
} | ||
// See coursier.parse.DependencyParser to understand how the classifier is added via Publication | ||
val org = Organization(groupId) | ||
val module = Module(org, ModuleName(s"$artId"), Map()) | ||
val dep = | ||
Dependency(module, defaultVersion) | ||
.withPublication("", Type.empty, Extension.empty, Classifier(platform)) | ||
// One would think there'd be a built-in pretty print like this but there isn't | ||
// (coursier.util.Print doesn't include the classifier) | ||
logger.debug(s"Attempting to fetch ${dep.module}:${dep.version},clasifier=${platform}") | ||
|
||
val resolution = Try { | ||
coursier.Fetch() | ||
.addDependencies(dep) | ||
.run() | ||
} | ||
if (resolution.isFailure) { | ||
val msg = resolution.failed.get.toString + "\n" // Coursier's message is already pretty good | ||
logger.debug(msg) | ||
return Left(msg) | ||
} | ||
// Head here is dangerous, without the classifier, multiple jars are fetched | ||
val jar = resolution.get.head | ||
logger.debug(s"Successfully fetched $jar") | ||
|
||
|
||
logger.debug(s"Loading $jar to search its resources") | ||
val classloader = new URLClassLoader(Array(jar.toURI.toURL)) | ||
checkResources(Some(classloader), logger) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.