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

Scala Native 0.4.0 #751

Merged
merged 4 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [3.0.0-M2, 3.0.0-M3, 2.11.12, 2.12.13, 2.13.3]
scala: [3.0.0-M2, 3.0.0-M3, 2.12.13, 2.13.4]
java: [adopt@1.8, adopt@1.11]
platform: [jvm]
workers: [1, 4]
Expand All @@ -45,20 +45,18 @@ jobs:
- workers: 1
os: ubuntu-latest
java: adopt@1.8
scala: 2.13.3
scala: 2.13.4
platform: js
- workers: 1
os: ubuntu-latest
java: adopt@1.8
scala: 2.11.12
scala: 2.12.13
platform: native
pluginversion: 0.3.9
- workers: 1
os: ubuntu-latest
java: adopt@1.8
scala: 2.11.12
scala: 2.13.4
platform: native
pluginversion: 0.4.0-M2
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand Down Expand Up @@ -93,7 +91,6 @@ jobs:
- name: Run the build script
env:
PLATFORM: ${{ matrix.platform }}
PLUGIN_VERSION: ${{ matrix.pluginversion }}
TRAVIS_SCALA_VERSION: ${{ matrix.scala }}
WORKERS: ${{ matrix.workers }}
run: ./tools/travis-script.sh
Expand All @@ -103,7 +100,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.3]
scala: [2.13.4]
java: [adopt@1.8]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -139,7 +136,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [3.0.0-M2, 3.0.0-M3, 2.11.12, 2.12.13, 2.13.3]
scala: [3.0.0-M2, 3.0.0-M3, 2.12.13, 2.13.4]
java: [adopt@1.8]
runs-on: ${{ matrix.os }}
steps:
Expand Down
32 changes: 12 additions & 20 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ val scalaMajorVersion = SettingKey[Int]("scalaMajorVersion")

scalaVersionSettings

val Scala211 = "2.11.12"
val Scala212 = "2.12.13"
val Scala213 = "2.13.3"
val Scala213 = "2.13.4"
val DottyOld = "3.0.0-M2"
val DottyNew = "3.0.0-M3"

ThisBuild / crossScalaVersions := Seq(DottyOld, DottyNew, Scala211, Scala212, Scala213)
ThisBuild / crossScalaVersions := Seq(DottyOld, DottyNew, Scala212, Scala213)
ThisBuild / scalaVersion := (ThisBuild / crossScalaVersions).value.last

ThisBuild / githubWorkflowPublishTargetBranches := Seq()
Expand All @@ -29,20 +28,20 @@ ThisBuild / githubWorkflowBuildMatrixAdditions += "platform" -> List("jvm")
ThisBuild / githubWorkflowBuildMatrixAdditions += "workers" -> List("1", "4")

ThisBuild / githubWorkflowBuildMatrixInclusions ++=
crossScalaVersions.value.filterNot(Set(Scala211)) map { scala =>
crossScalaVersions.value map { scala =>
MatrixInclude(
Map("os" -> PrimaryOS, "java" -> Java8, "scala" -> scala),
Map("platform" -> "js", "workers" -> "1"))
}

ThisBuild / githubWorkflowBuildMatrixInclusions ++=
Seq("0.3.9", "0.4.0-M2") map { v =>
crossScalaVersions.value.filter(_.startsWith("2.")) map { scala =>
MatrixInclude(
Map(
"os" -> PrimaryOS,
"scala" -> Scala211,
"scala" -> scala,
"java" -> Java8),
Map("platform" -> "native", "pluginversion" -> v, "workers" -> "1"))
Map("platform" -> "native", "workers" -> "1"))
}

ThisBuild / githubWorkflowBuildPreamble +=
Expand All @@ -57,7 +56,6 @@ ThisBuild / githubWorkflowBuild := Seq(
name = Some("Run the build script"),
env = Map(
"PLATFORM" -> "${{ matrix.platform }}",
"PLUGIN_VERSION" -> "${{ matrix.pluginversion }}",
"TRAVIS_SCALA_VERSION" -> "${{ matrix.scala }}",
"WORKERS" -> "${{ matrix.workers }}")))

Expand Down Expand Up @@ -161,13 +159,11 @@ lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq(
(n: Int) => if (r.contains(n)) strs else Seq.empty

val groups: Seq[Int => Seq[String]] = Seq(
mk(11 to 11)("-Xlint"),
mk(11 to 12)("-Ywarn-inaccessible", "-Ywarn-nullary-override",
mk(12 to 12)("-Ywarn-inaccessible", "-Ywarn-nullary-override",
"-Ywarn-nullary-unit", "-Xfuture", "-Xfatal-warnings", "-deprecation",
"-Ywarn-infer-any", "-Ywarn-unused-import"),
mk(11 to 13)("-encoding", "UTF-8", "-feature", "-unchecked",
"-Ywarn-dead-code", "-Ywarn-numeric-widen"),
mk(12 to 13)("-Xlint:-unused",
mk(12 to 13)("-encoding", "UTF-8", "-feature", "-unchecked",
"-Ywarn-dead-code", "-Ywarn-numeric-widen", "-Xlint:-unused",
"-Ywarn-unused:-patvars,-implicits,-locals,-privates,-explicits"))

val n = scalaMajorVersion.value
Expand Down Expand Up @@ -245,11 +241,7 @@ lazy val js = project.in(file("js"))
.settings(
Global / scalaJSStage := FastOptStage,
libraryDependencies +=
("org.scala-js" %% "scalajs-test-interface" % scalaJSVersion).withDottyCompat(scalaVersion.value),

scalacOptions ++= {
if (scalaVersion.value == "3.0.0-M1") Seq("-Yskip:explicitJSClasses") else Nil
},
("org.scala-js" %% "scalajs-test-interface" % scalaJSVersion).withDottyCompat(scalaVersion.value)
)
.enablePlugins(ScalaJSPlugin)

Expand All @@ -276,8 +268,8 @@ lazy val native = project.in(file("native"))
.settings(sharedSettings: _*)
.settings(
Compile / doc := (jvm / Compile / doc).value,
scalaVersion := "2.11.12",
crossScalaVersions := Seq("2.11.12"),
scalaVersion := Scala212,
crossScalaVersions := Seq(Scala212, Scala213),
// TODO: re-enable MiMa for native once published
mimaPreviousArtifacts := Set(),
libraryDependencies ++= Seq(
Expand Down
27 changes: 18 additions & 9 deletions native/src/main/scala/org/scalacheck/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package org.scalacheck

import Test._

import scala.scalanative.testinterface.PreloadedClassLoader
import scala.scalanative.reflect.Reflect

private[scalacheck] object Platform {

Expand All @@ -23,14 +23,23 @@ private[scalacheck] object Platform {
workerFun(0)
}

def loadModule(name: String, loader: ClassLoader): AnyRef =
loader.asInstanceOf[PreloadedClassLoader].loadPreloaded(name)
def loadModule(name: String, loader: ClassLoader): AnyRef = {
Reflect
.lookupLoadableModuleClass(name + "$")
.getOrElse(throw new ClassNotFoundException(name + "$"))
.loadModule()
.asInstanceOf[AnyRef]
}

def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[_]])(args: Seq[AnyRef]): AnyRef =
org.scalajs.testinterface.TestUtils.newInstance(name, loader, paramTypes)(args)
def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[_]])(args: Seq[AnyRef]): AnyRef = {
Reflect
.lookupInstantiatableClass(name)
.getOrElse(throw new ClassNotFoundException(name))
.getConstructor(paramTypes: _*)
.getOrElse(throw new NoSuchMethodError(paramTypes.mkString("<init>(", ",", ")")))
.newInstance(args: _*)
.asInstanceOf[AnyRef]
}

// We don't need those annotation in Native, and they have been deprecated.
// We use `String` instead of the definition in Native because `-Xfatal-warnings`
// is set.
type EnableReflectiveInstantiation = String
type EnableReflectiveInstantiation = scala.scalanative.reflect.annotation.EnableReflectiveInstantiation
}
9 changes: 1 addition & 8 deletions project/plugin.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ def printAndDie(msg: String): Nothing = {
sys.error(msg)
}

// Update SCALANATIVE_VERSION in release.sh, as well
val scalaNativeVersion = env("SCALANATIVE_VERSION") match {
case Some("0.3.9") | Some("") | None => "0.3.9"
case Some("0.4.0-M2") => "0.4.0-M2"
case Some(v) => printAndDie(s"unsupported scala native version: $v")
}

addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion)
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0")

addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.0")

Expand Down
6 changes: 2 additions & 4 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,5 @@ runsbt "+ jvm/$CMD"
# step 4b: js releases
runsbt "+ js/$CMD"

# step 4c: native releases (clean versions)
SCALANATIVE_VERSION="0.3.9" runsbt "+ native/$CMD"
runsbt "+ native/clean"
SCALANATIVE_VERSION="0.4.0-M2" runsbt "+ native/$CMD"
# step 4c: native releases
runsbt "+ native/$CMD"
4 changes: 1 addition & 3 deletions tools/travis-script.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/bash
set -evu

export SCALANATIVE_VERSION="$PLUGIN_VERSION"

sbt_cmd=(sbt ++$TRAVIS_SCALA_VERSION)

if [[ "$PLATFORM" == "js" ]]; then
Expand All @@ -11,7 +9,7 @@ else
TESTS=1000
fi

for t in clean compile "testOnly * -- -s $TESTS -w $WORKERS" mimaReportBinaryIssues package; do
for t in clean compile "testOnly * -- \"-s $TESTS -w $WORKERS\"" mimaReportBinaryIssues package; do
sbt_cmd+=("$PLATFORM/$t")
done

Expand Down