Skip to content

Commit

Permalink
Support Scala Native - Scala 3 (#380)
Browse files Browse the repository at this point in the history
Bump Geny and Utest
  • Loading branch information
lolgab authored Jan 27, 2022
1 parent 1090cc5 commit 693af26
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Run JS tests
run: |
./mill -i __.resolvedIvyDeps
./mill -i -j $(nproc) all __.js.__.compile __.js.__.publishArtifacts __.js.__.test
./mill -i -j 0 all __.js.__.compile __.js.__.publishArtifacts __.js.__.test
test-native:
runs-on: ubuntu-latest
env:
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Run Native tests
run: |
./mill -i __.resolvedIvyDeps
./mill -i -j $(nproc) all __.native.__.compile __.native.__.publishArtifacts __.native.__.test
./mill -i -j 0 all __.native.__.compile __.native.__.publishArtifacts __.native.__.test
test-jvm:
runs-on: ubuntu-latest
env:
Expand All @@ -55,7 +55,7 @@ jobs:
- name: Run JVM tests
run: |
./mill -i __.resolvedIvyDeps
./mill -i -j $(nproc) all __.jvm.__.compile __.jvm.__.publishArtifacts __.jvm.__.test
./mill -i -j 0 all __.jvm.__.compile __.jvm.__.publishArtifacts __.jvm.__.test
check-binary-compatibility:
runs-on: ubuntu-latest
steps:
Expand Down
38 changes: 18 additions & 20 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@ import mill.scalanativelib._
import mill.modules._
import mill.scalalib.api.Util.isScala3
import mill.scalanativelib.api.{LTO, ReleaseMode}
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version_mill0.9:0.1.1`
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.1.4`
import de.tobiasroeser.mill.vcs.version.VcsVersion
import $ivy.`com.github.lolgab::mill-mima_mill0.9:0.0.4`
import $ivy.`com.github.lolgab::mill-mima::0.0.9`
import com.github.lolgab.mill.mima._

val scala211 = "2.11.12"
val scala212 = "2.12.13"
val scala213 = "2.13.4"
val scala3 = "3.0.2"
val scala30 = "3.0.2"
val scala31 = "3.1.0"
val scalaJS06 = "0.6.33"
val scalaJS1 = "1.5.1"
val scalaNative = "0.4.0"
val scalaNative = "0.4.3"

val dottyCustomVersion = Option(sys.props("dottyVersion"))

val scala2JVMVersions = Seq(scala211, scala212, scala213)
val scalaJVMVersions = scala2JVMVersions ++ Seq(scala3) ++ dottyCustomVersion
val scalaJVMVersions = scala2JVMVersions ++ Seq(scala30) ++ dottyCustomVersion

val scalaJSVersions = Seq(
(scala211, scalaJS06),
Expand All @@ -31,13 +32,14 @@ val scalaJSVersions = Seq(
(scala211, scalaJS1),
(scala212, scalaJS1),
(scala213, scalaJS1),
(scala3, scalaJS1)
(scala30, scalaJS1)
)

val scalaNativeVersions = Seq(
(scala211, scalaNative),
(scala212, scalaNative),
(scala213, scalaNative)
(scala213, scalaNative),
(scala31, scalaNative)
)

trait CommonModule extends ScalaModule {
Expand Down Expand Up @@ -84,10 +86,7 @@ trait CommonPublishModule extends CommonModule with PublishModule with Mima with
organization = "com.lihaoyi",
url = "https://github.com/lihaoyi/upickle",
licenses = Seq(License.MIT),
scm = SCM(
"git://github.com/lihaoyi/upickle.git",
"scm:git://github.com/lihaoyi/upickle.git"
),
versionControl = VersionControl.github(owner = "com-lihaoyi", repo = "upickle"),
developers = Seq(
Developer("lihaoyi", "Li Haoyi","https://github.com/lihaoyi")
)
Expand Down Expand Up @@ -117,12 +116,11 @@ trait CommonPublishModule extends CommonModule with PublishModule with Mima with
}
}

trait CommonTestModule extends CommonModule with TestModule{
def ivyDeps = Agg(ivy"com.lihaoyi::utest::0.7.10") ++ (
trait CommonTestModule extends CommonModule with TestModule.Utest{
def ivyDeps = Agg(ivy"com.lihaoyi::utest::0.7.11") ++ (
if (isScala3(scalaVersion())) Agg.empty[mill.scalalib.Dep]
else Agg(ivy"com.lihaoyi::acyclic:0.2.1")
else Agg(ivy"com.lihaoyi:::acyclic:0.3.2")
)
def testFramework = "upickle.core.UTestFramework"
def docJar = T {
val outDir = T.ctx().dest
val javadocDir = outDir / 'javadoc
Expand Down Expand Up @@ -163,7 +161,7 @@ trait CommonNativeModule extends CommonPublishModule with ScalaNativeModule{

trait CommonCoreModule extends CommonPublishModule {
def artifactName = "upickle-core"
def ivyDeps = Agg(ivy"com.lihaoyi::geny::0.6.10")
def ivyDeps = Agg(ivy"com.lihaoyi::geny::0.7.1")
}
object core extends Module {
object js extends Cross[CoreJsModule](scalaJSVersions:_*)
Expand All @@ -187,14 +185,14 @@ object implicits extends Module {

trait ImplicitsModule extends CommonPublishModule{
def compileIvyDeps = if (!isDotty) Agg(
ivy"com.lihaoyi::acyclic:0.2.1",
ivy"com.lihaoyi:::acyclic:0.3.2",
ivy"org.scala-lang:scala-reflect:${scalaVersion()}"
)
else Agg.empty[Dep]
def generatedSources = T{
val dir = T.ctx().dest
val file = dir / "upickle" / "Generated.scala"
ammonite.ops.mkdir(dir / "upickle")
os.makeDir(dir / "upickle")
val tuples = (1 to 22).map{ i =>
def commaSeparated(s: Int => String) = (1 to i).map(s).mkString(", ")
val writerTypes = commaSeparated(j => s"T$j: Writer")
Expand All @@ -212,7 +210,7 @@ object implicits extends Module {
"""
}

ammonite.ops.write(file, s"""
os.write(file, s"""
package upickle.implicits
/**
* Auto-generated picklers and unpicklers, used for creating the 22
Expand Down Expand Up @@ -374,7 +372,7 @@ object ujson extends Module{
trait UpickleModule extends CommonPublishModule{
def artifactName = "upickle"
def compileIvyDeps = if (!isDotty) Agg(
ivy"com.lihaoyi::acyclic:0.2.1",
ivy"com.lihaoyi:::acyclic:0.3.2",
ivy"org.scala-lang:scala-reflect:${scalaVersion()}",
ivy"org.scala-lang:scala-compiler:${scalaVersion()}"
)
Expand Down
11 changes: 6 additions & 5 deletions mill
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# This is a wrapper script, that automatically download mill from GitHub release pages
# You can give the required mill version with MILL_VERSION env variable
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
DEFAULT_MILL_VERSION=0.9.8
DEFAULT_MILL_VERSION=0.10.0-21-c4247b

set -e

if [ -z "$MILL_VERSION" ] ; then
if [ -f ".mill-version" ] ; then
MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)"
elif [ -f "mill" ] && [ "$BASH_SOURCE" != "mill" ] ; then
elif [ -f "mill" ] && [ "$0" != "mill" ] ; then
MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2)
else
MILL_VERSION=$DEFAULT_MILL_VERSION
Expand All @@ -28,13 +28,14 @@ version_remainder="$MILL_VERSION"
MILL_MAJOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
MILL_MINOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"

if [ ! -x "$MILL_EXEC_PATH" ] ; then
mkdir -p $MILL_DOWNLOAD_PATH
if [ ! -s "$MILL_EXEC_PATH" ] ; then
mkdir -p "$MILL_DOWNLOAD_PATH"
if [ "$MILL_MAJOR_VERSION" -gt 0 ] || [ "$MILL_MINOR_VERSION" -ge 5 ] ; then
ASSEMBLY="-assembly"
fi
DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download
MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION${ASSEMBLY}"
MILL_VERSION_TAG=$(echo $MILL_VERSION | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/')
MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION_TAG}/$MILL_VERSION${ASSEMBLY}"
curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL"
chmod +x "$DOWNLOAD_FILE"
mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH"
Expand Down

0 comments on commit 693af26

Please sign in to comment.