Skip to content

Commit 7af5889

Browse files
authored
Merge pull request #482 from lolgab/support-scala-native
2 parents 97a9018 + 05c8ba2 commit 7af5889

File tree

6 files changed

+84
-6
lines changed

6 files changed

+84
-6
lines changed

.circleci/config.yml

+38
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ executors:
1313
scala_jdk16_executor:
1414
docker:
1515
- image: circleci/openjdk:16-buster
16+
scala_native_executor:
17+
machine:
18+
image: ubuntu-1604:202004-01
1619

1720
commands:
1821
sbt_cmd:
@@ -76,6 +79,33 @@ jobs:
7679
- sbt_cmd:
7780
scala_version: << parameters.scala_version >>
7881
sbt_tasks: xmlJS/update xmlJS/compile xmlJS/test:compile xmlJS/test xmlJS/doc xmlJS/package
82+
scalanative_job:
83+
executor: scala_native_executor
84+
parameters:
85+
scala_version:
86+
description: "Scala version"
87+
default: 2.12.13
88+
type: string
89+
scalanative_version:
90+
description: "Scala Native version"
91+
default: 0.4.0
92+
type: string
93+
environment:
94+
SCALANATIVE_VERSION: << parameters.scalanative_version >>
95+
steps:
96+
- checkout
97+
- run:
98+
name: Install dependencies
99+
command: |
100+
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
101+
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add
102+
sudo apt-get update
103+
sudo apt-get install -y sbt clang-8 openjdk-8-jdk
104+
sudo ln -s /usr/lib/llvm-8/bin/clang /usr/bin/clang
105+
sudo ln -s /usr/lib/llvm-8/bin/clang++ /usr/bin/clang++
106+
- sbt_cmd:
107+
scala_version: << parameters.scala_version >>
108+
sbt_tasks: xmlNative/update xmlNative/compile xmlNative/test:compile xmlNative/test xmlNative/doc xmlNative/package
79109

80110
workflows:
81111
build:
@@ -140,3 +170,11 @@ workflows:
140170
name: sjs1.0_2.13
141171
scala_version: 2.13.4
142172
scalajs_version: 1.4.0
173+
- scalanative_job:
174+
name: native0.4_2.12
175+
scala_version: 2.12.13
176+
scalanative_version: 0.4.0
177+
- scalanative_job:
178+
name: native0.4_2.13
179+
scala_version: 2.13.4
180+
scalanative_version: 0.4.0

.scalafmt.conf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version = "2.7.4"

.travis.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@ scala:
1111
- 2.13.4
1212

1313
env:
14-
- SCALAJS_VERSION= ADOPTOPENJDK=8
15-
- SCALAJS_VERSION=1.4.0 ADOPTOPENJDK=8
16-
- SCALAJS_VERSION= ADOPTOPENJDK=11
17-
- SCALAJS_VERSION= ADOPTOPENJDK=15
14+
- SCALAJS_VERSION= ADOPTOPENJDK=8
15+
- SCALAJS_VERSION=1.4.0 ADOPTOPENJDK=8
16+
- SCALANATIVE_VERSION=0.4.0 ADOPTOPENJDK=8
17+
- SCALAJS_VERSION= ADOPTOPENJDK=11
18+
- SCALAJS_VERSION= ADOPTOPENJDK=15
19+
20+
jobs:
21+
exclude:
22+
- scala: 3.0.0-M2
23+
env: SCALANATIVE_VERSION=0.4.0 ADOPTOPENJDK=8
24+
- scala: 3.0.0-M3
25+
env: SCALANATIVE_VERSION=0.4.0 ADOPTOPENJDK=8
1826

1927
install:
2028
- git fetch --tags # get all tags for sbt-dynver

build.sbt

+25-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ lazy val configSettings: Seq[Setting[_]] = Seq(
1818
}
1919
)
2020

21-
lazy val xml = crossProject(JSPlatform, JVMPlatform)
21+
lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform)
2222
.withoutSuffixFor(JVMPlatform)
2323
.crossType(CrossType.Full)
2424
.in(file("."))
@@ -163,3 +163,27 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform)
163163
Test / fork := false
164164
)
165165
.jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin))
166+
.nativeSettings(
167+
scalaModuleMimaPreviousVersion := None, // No such release yet
168+
// Scala Native cannot run forked tests
169+
Test / fork := false,
170+
libraryDependencies += "org.scala-native" %%% "junit-runtime" % nativeVersion % Test,
171+
Test / scalacOptions += {
172+
val log = streams.value.log
173+
val retrieveDir = baseDirectory.value / "scala-native-junit-plugin-jars"
174+
val lm = dependencyResolution.value
175+
val cp = lm
176+
.retrieve(
177+
"org.scala-native" % s"junit-plugin_${scalaVersion.value}" % nativeVersion,
178+
scalaModuleInfo = None,
179+
retrieveDir,
180+
log
181+
)
182+
.fold(w => throw w.resolveException, identity(_))
183+
val jarPath = cp
184+
.find(_.toString.contains("junit-plugin"))
185+
.getOrElse(throw new Exception("Can't find Scala Native junit-plugin jar"))
186+
s"-Xplugin:$jarPath"
187+
},
188+
Test / testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-s", "-v")
189+
)

build.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ isReleaseJob() {
2525
fi
2626
}
2727

28-
if [[ "$SCALAJS_VERSION" == "" ]]; then
28+
if [[ "$SCALAJS_VERSION" == "" ]] && [[ "$SCALANATIVE_VERSION" == "" ]]; then
2929
projectPrefix="xml/"
30+
elif [[ "$SCALAJS_VERSION" == "" ]]; then
31+
projectPrefix="xmlNative/"
3032
else
3133
projectPrefix="xmlJS/"
3234
fi

project/plugins.sbt

+5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
val scalaJSVersion =
22
Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty).getOrElse("1.4.0")
33

4+
val scalaNativeVersion =
5+
Option(System.getenv("SCALANATIVE_VERSION")).filter(_.nonEmpty).getOrElse("0.4.0")
6+
47
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.2.3")
58
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
9+
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.0.0")
610
addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)
11+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion)
712
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.2")

0 commit comments

Comments
 (0)