Skip to content

Commit

Permalink
Scala-Native 0.5.0 support (#154)
Browse files Browse the repository at this point in the history
This required a Mill version upgrade to 0.11.x, which involved cleaning
up a lot of now-unnecessary boilerplate in the `build.sc`.

Same version changes as elsewhere: drop 2.11.x/3.1.x/3.2.x support, add
Scala-Native 0.5.0
  • Loading branch information
lihaoyi authored Apr 14, 2024
1 parent 99c30e1 commit 71c26bb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Run tests
run: ./mill -i all __.publishArtifacts __.test
run: ./mill -i __.publishArtifacts + __.test.run

check-binary-compatibility:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.12
0.11.7-29-f2e220
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,13 @@ in its `.toString` method.
Version History
===============

master
------

* Support for Scala-Native 0.5.0
* Minimum version of Scala 2 raised to 2.12.x
* Minimum version of Scala 3 raised to 3.3.1

0.3.1
-----

Expand Down
103 changes: 22 additions & 81 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ import $ivy.`com.github.lolgab::mill-mima::0.1.0`
import mill._, scalalib._, scalajslib._, scalanativelib._, publish._
import de.tobiasroeser.mill.vcs.version.VcsVersion
import com.github.lolgab.mill.mima._
import mill.scalalib.api.Util.isScala3
import mill.scalalib.api.ZincWorkerUtil.isScala3

val dottyCommunityBuildVersion = sys.props.get("dottyVersion").toList

val scalaVersions =
"2.11.12" :: "2.12.16" :: "2.13.8" :: "3.1.3" :: dottyCommunityBuildVersion

val scalaJSVersions = scalaVersions.map((_, "1.10.1"))
val scalaNativeVersions = scalaVersions.map((_, "0.4.5"))
"2.12.16" :: "2.13.8" :: "3.3.1" :: dottyCommunityBuildVersion

trait MimaCheck extends Mima {
def mimaPreviousVersions = Seq("0.2.4", "0.2.5", "0.2.6", "0.2.7", "0.2.8", "0.3.0", "0.3.1")
Expand Down Expand Up @@ -41,98 +38,42 @@ trait SourcecodeModule extends PublishModule with MimaCheck {
)
)
}
trait SourcecodeMainModule extends CrossScalaModule {
def millSourcePath = super.millSourcePath / offset

def offset: os.RelPath = os.rel

trait SourcecodeMainModule extends CrossScalaModule with PlatformScalaModule {
def compileIvyDeps =
if (crossScalaVersion.startsWith("2")) Agg(
ivy"org.scala-lang:scala-reflect:${crossScalaVersion}",
ivy"org.scala-lang:scala-compiler:${crossScalaVersion}"
)
else Agg.empty[Dep]

def sources = T.sources(
super.sources()
.flatMap(source =>
Seq(
PathRef(source.path / os.up / source.path.last),
PathRef(source.path / os.up / os.up / source.path.last)
)
)
)
}

object sourcecode extends Module {
object jvm extends Cross[JvmSourcecodeModule](scalaVersions)
trait JvmSourcecodeModule extends SourcecodeMainModule with ScalaModule with SourcecodeModule {

trait SourcecodeTestModule extends ScalaModule {
def crossScalaVersion: String

def offset: os.RelPath = os.rel
def millSourcePath = super.millSourcePath / os.up

def sources = T.sources(
super.sources()
.++(CrossModuleBase.scalaVersionPaths(crossScalaVersion, s => millSourcePath / s"src-$s" ))
.flatMap(source =>
Seq(
PathRef(source.path / os.up / "test" / source.path.last),
PathRef(source.path / os.up / os.up / "test" / source.path.last)
)
)
.distinct
)
}
object test extends ScalaTests{

object sourcecode extends Module {
object jvm extends Cross[JvmSourcecodeModule](scalaVersions: _*)
class JvmSourcecodeModule(val crossScalaVersion: String)
extends SourcecodeMainModule with ScalaModule with SourcecodeModule {

object test extends SourcecodeTestModule{
def scalaVersion = crossScalaVersion
def moduleDeps = Seq(JvmSourcecodeModule.this)
val crossScalaVersion = JvmSourcecodeModule.this.crossScalaVersion
def testFramework = ""
}
}

object js extends Cross[JsSourcecodeModule](scalaJSVersions: _*)
class JsSourcecodeModule(val crossScalaVersion: String, crossJSVersion: String)
extends SourcecodeMainModule with ScalaJSModule with SourcecodeModule {
def offset = os.up

def scalaJSVersion = crossJSVersion
object test extends SourcecodeTestModule with ScalaJSModule{
def scalaVersion = crossScalaVersion
def scalaJSVersion = crossJSVersion
def offset = os.up
def moduleDeps = Seq(JsSourcecodeModule.this)
val crossScalaVersion = JsSourcecodeModule.this.crossScalaVersion
object js extends Cross[JsSourcecodeModule](scalaVersions)
trait JsSourcecodeModule extends SourcecodeMainModule with ScalaJSModule with SourcecodeModule {

def scalaJSVersion = "1.12.0"
object test extends ScalaJSTests{
def testFramework = ""
}
}

object native extends Cross[NativeSourcecodeModule](scalaNativeVersions: _*)
class NativeSourcecodeModule(val crossScalaVersion: String, crossScalaNativeVersion: String)
extends SourcecodeMainModule with ScalaNativeModule with SourcecodeModule {
def offset = os.up

def scalaNativeVersion = crossScalaNativeVersion

override def docJar =
if (crossScalaVersion.startsWith("2.")) super.docJar
else T {
val outDir = T.ctx().dest
val javadocDir = outDir / "javadoc"
os.makeDir.all(javadocDir)
mill.api.Result.Success(mill.modules.Jvm.createJar(Agg(javadocDir))(outDir))
}

object test extends SourcecodeTestModule with ScalaNativeModule{
def scalaVersion = crossScalaVersion
def scalaNativeVersion = crossScalaNativeVersion
def offset = os.up
def moduleDeps = Seq(NativeSourcecodeModule.this)
val crossScalaVersion = NativeSourcecodeModule.this.crossScalaVersion
object native extends Cross[NativeSourcecodeModule](scalaVersions)
trait NativeSourcecodeModule extends SourcecodeMainModule with ScalaNativeModule with SourcecodeModule {

def scalaNativeVersion = "0.5.0"
object test extends ScalaNativeTests{
// stub to make use of test plumbing but not running a test suite
def mainClass = Some("sourcecode.Main")
def testFramework = ""
}
}
}

0 comments on commit 71c26bb

Please sign in to comment.