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

[Scala3] Add cross build support to Mill #4492

Merged
merged 12 commits into from
Nov 12, 2024

Conversation

adkian-sifive
Copy link
Contributor

@adkian-sifive adkian-sifive commented Nov 1, 2024

The way the compilation units in the Mill build files were set up meant that differentiated module dependencies and compilation options between Scala versions could not be supported. Specifically, having these options in traits like HasChiselPlugin meant that they could not be optionally included in the build unit based on the cross version.

However, this is a requirement for adding Scala3 cross compilation support, since there are compilation options (-Ymacro-annotations) and module dependencies (pluginModule) that are Scala2-specific. This PR includes a refactor of the build files and adds initial support for adding module dependencies and compilation options specific to Scala versions.

Contributor Checklist

  • Did you add Scaladoc to every public function/method?
  • Did you add at least one test demonstrating the PR?
  • Did you delete any extraneous printlns/debugging code?
  • Did you specify the type of improvement?
  • Did you add appropriate documentation in docs/src?
  • Did you request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • Feature (or new API)
  • Internal or build-related (includes code refactoring/cleanup)

Desired Merge Strategy

  • Squash: The PR will be squashed and merged (choose this if you have no preference).

Release Notes

Mill build files were refactored to support differentiated module dependencies and compilation options between Scala versions

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels? (Select the most appropriate one based on the "Type of Improvement")
  • Did you mark the proper milestone (Bug fix: 3.6.x, 5.x, or 6.x depending on impact, API modification or big change: 7.0)?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you do one of the following when ready to merge:
    • Squash: You/ the contributor Enable auto-merge (squash), clean up the commit message, and label with Please Merge.
    • Merge: Ensure that contributor has cleaned up their commit history, then merge with Create a merge commit.

@adkian-sifive adkian-sifive added Internal Internal change, does not affect users, will be included in release notes Scala 3 Changes related to upgrading to Scala 3 labels Nov 1, 2024
build.sc Show resolved Hide resolved
@adkian-sifive adkian-sifive changed the title [Scala3] Add cross build support to Mill build [Scala3] Add cross build support to Mill Nov 1, 2024
Copy link
Contributor

@jackkoenig jackkoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, see comments.

One comment that is confusing me

However, this is a requirement for adding Scala3 cross compilation support, since there are compilation options (-Ymacro-annotations) and module dependencies (pluginModule) that are Scala2-specific.

I guess the plugin module is Scala 2 specific for now, but only because we haven't implemented it for Scala 3--we do need the plugin for Scala 3. It's fine to treat it this way for now but we're gonna need it soon.

build.sc Outdated Show resolved Hide resolved
build.sc Outdated Show resolved Hide resolved
build.sc Show resolved Hide resolved
build.sc Outdated Show resolved Hide resolved
build.sc Outdated Show resolved Hide resolved
build.sc Outdated Show resolved Hide resolved
@adkian-sifive
Copy link
Contributor Author

Thanks for the review @jackkoenig! Re: the plugin, the comment was meant to say that we'll need it in scala3 at some point but this update makes it so that building Scala3 is not blocked on the build units requiring the plugin..

@adkian-sifive
Copy link
Contributor Author

@jackkoenig any ideas on why the integration tests are failing to get the plugin in their build unit?

build.sc Outdated Show resolved Hide resolved
@sequencer
Copy link
Member

I'll take a look now, sry for the delay

Copy link
Member

@sequencer sequencer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some nitpick, but basically LGTM. I saw it removed the common.sc, I used to design it to separate the definition and implementation of the build system. I do think we can remove it after making mill as the only build system support.
I think panama-related library can also migrate to Scala3 simply, we can do it in the future.

Comment on lines +227 to +252
trait LitModule extends Module {
def scalaVersion: T[String]
def runClasspath: T[Seq[os.Path]]
def pluginJars: T[Seq[os.Path]]
def javaLibraryPath: T[Seq[os.Path]]
def javaHome: T[os.Path]
def chiselLitDir: T[os.Path]
def litConfigIn: T[PathRef]
def litConfig: T[PathRef] = T {
os.write(
T.dest / "lit.site.cfg.py",
os.read(litConfigIn().path)
.replaceAll("@SCALA_VERSION@", scalaVersion())
.replaceAll("@RUN_CLASSPATH@", runClasspath().mkString(","))
.replaceAll("@SCALA_PLUGIN_JARS@", pluginJars().mkString(","))
.replaceAll("@JAVA_HOME@", javaHome().toString)
.replaceAll("@JAVA_LIBRARY_PATH@", javaLibraryPath().mkString(","))
.replaceAll("@CHISEL_LIT_DIR@", chiselLitDir().toString)
)
PathRef(T.dest)
}
def run(args: String*) = T.command(
os.proc("lit", litConfig().path)
.call(T.dest, stdout = os.ProcessOutput.Readlines(line => T.ctx().log.info("[lit] " + line)))
)
}
Copy link
Member

@sequencer sequencer Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about inline the LitModule?

build.sc Outdated Show resolved Hide resolved
build.sc Outdated Show resolved Hide resolved
build.sc Show resolved Hide resolved
build.sc Show resolved Hide resolved
@adkian-sifive adkian-sifive force-pushed the adkian-sifive/mill-cross-build-support branch from a73c7c0 to 29e8613 Compare November 12, 2024 19:21
@adkian-sifive adkian-sifive force-pushed the adkian-sifive/mill-cross-build-support branch from 29e8613 to e8ffe80 Compare November 12, 2024 21:12
@adkian-sifive adkian-sifive merged commit 7ade4df into main Nov 12, 2024
15 checks passed
@adkian-sifive adkian-sifive deleted the adkian-sifive/mill-cross-build-support branch November 12, 2024 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internal Internal change, does not affect users, will be included in release notes Scala 3 Changes related to upgrading to Scala 3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants