Skip to content

Commit

Permalink
Merge pull request #482 from lolgab/support-scala-native
Browse files Browse the repository at this point in the history
  • Loading branch information
SethTisue authored Jan 29, 2021
2 parents 97a9018 + 05c8ba2 commit 7af5889
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 6 deletions.
38 changes: 38 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ executors:
scala_jdk16_executor:
docker:
- image: circleci/openjdk:16-buster
scala_native_executor:
machine:
image: ubuntu-1604:202004-01

commands:
sbt_cmd:
Expand Down Expand Up @@ -76,6 +79,33 @@ jobs:
- sbt_cmd:
scala_version: << parameters.scala_version >>
sbt_tasks: xmlJS/update xmlJS/compile xmlJS/test:compile xmlJS/test xmlJS/doc xmlJS/package
scalanative_job:
executor: scala_native_executor
parameters:
scala_version:
description: "Scala version"
default: 2.12.13
type: string
scalanative_version:
description: "Scala Native version"
default: 0.4.0
type: string
environment:
SCALANATIVE_VERSION: << parameters.scalanative_version >>
steps:
- checkout
- run:
name: Install dependencies
command: |
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add
sudo apt-get update
sudo apt-get install -y sbt clang-8 openjdk-8-jdk
sudo ln -s /usr/lib/llvm-8/bin/clang /usr/bin/clang
sudo ln -s /usr/lib/llvm-8/bin/clang++ /usr/bin/clang++
- sbt_cmd:
scala_version: << parameters.scala_version >>
sbt_tasks: xmlNative/update xmlNative/compile xmlNative/test:compile xmlNative/test xmlNative/doc xmlNative/package

workflows:
build:
Expand Down Expand Up @@ -140,3 +170,11 @@ workflows:
name: sjs1.0_2.13
scala_version: 2.13.4
scalajs_version: 1.4.0
- scalanative_job:
name: native0.4_2.12
scala_version: 2.12.13
scalanative_version: 0.4.0
- scalanative_job:
name: native0.4_2.13
scala_version: 2.13.4
scalanative_version: 0.4.0
1 change: 1 addition & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = "2.7.4"
16 changes: 12 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@ scala:
- 2.13.4

env:
- SCALAJS_VERSION= ADOPTOPENJDK=8
- SCALAJS_VERSION=1.4.0 ADOPTOPENJDK=8
- SCALAJS_VERSION= ADOPTOPENJDK=11
- SCALAJS_VERSION= ADOPTOPENJDK=15
- SCALAJS_VERSION= ADOPTOPENJDK=8
- SCALAJS_VERSION=1.4.0 ADOPTOPENJDK=8
- SCALANATIVE_VERSION=0.4.0 ADOPTOPENJDK=8
- SCALAJS_VERSION= ADOPTOPENJDK=11
- SCALAJS_VERSION= ADOPTOPENJDK=15

jobs:
exclude:
- scala: 3.0.0-M2
env: SCALANATIVE_VERSION=0.4.0 ADOPTOPENJDK=8
- scala: 3.0.0-M3
env: SCALANATIVE_VERSION=0.4.0 ADOPTOPENJDK=8

install:
- git fetch --tags # get all tags for sbt-dynver
Expand Down
26 changes: 25 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ lazy val configSettings: Seq[Setting[_]] = Seq(
}
)

lazy val xml = crossProject(JSPlatform, JVMPlatform)
lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Full)
.in(file("."))
Expand Down Expand Up @@ -163,3 +163,27 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform)
Test / fork := false
)
.jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin))
.nativeSettings(
scalaModuleMimaPreviousVersion := None, // No such release yet
// Scala Native cannot run forked tests
Test / fork := false,
libraryDependencies += "org.scala-native" %%% "junit-runtime" % nativeVersion % Test,
Test / scalacOptions += {
val log = streams.value.log
val retrieveDir = baseDirectory.value / "scala-native-junit-plugin-jars"
val lm = dependencyResolution.value
val cp = lm
.retrieve(
"org.scala-native" % s"junit-plugin_${scalaVersion.value}" % nativeVersion,
scalaModuleInfo = None,
retrieveDir,
log
)
.fold(w => throw w.resolveException, identity(_))
val jarPath = cp
.find(_.toString.contains("junit-plugin"))
.getOrElse(throw new Exception("Can't find Scala Native junit-plugin jar"))
s"-Xplugin:$jarPath"
},
Test / testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-s", "-v")
)
4 changes: 3 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ isReleaseJob() {
fi
}

if [[ "$SCALAJS_VERSION" == "" ]]; then
if [[ "$SCALAJS_VERSION" == "" ]] && [[ "$SCALANATIVE_VERSION" == "" ]]; then
projectPrefix="xml/"
elif [[ "$SCALAJS_VERSION" == "" ]]; then
projectPrefix="xmlNative/"
else
projectPrefix="xmlJS/"
fi
Expand Down
5 changes: 5 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
val scalaJSVersion =
Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty).getOrElse("1.4.0")

val scalaNativeVersion =
Option(System.getenv("SCALANATIVE_VERSION")).filter(_.nonEmpty).getOrElse("0.4.0")

addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.2.3")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.0.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)
addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion)
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.2")

0 comments on commit 7af5889

Please sign in to comment.