diff --git a/.circleci/config.yml b/.circleci/config.yml index c91fb5898..a5f38c020 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: @@ -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: @@ -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 diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 000000000..ffbdff9fd --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1 @@ +version = "2.7.4" diff --git a/.travis.yml b/.travis.yml index 7449e1727..4778e5ee8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/build.sbt b/build.sbt index a392cce29..9ff6394ee 100644 --- a/build.sbt +++ b/build.sbt @@ -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(".")) @@ -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") + ) diff --git a/build.sh b/build.sh index 4c5a682a7..b5253d68b 100755 --- a/build.sh +++ b/build.sh @@ -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 diff --git a/project/plugins.sbt b/project/plugins.sbt index ba23fbaeb..ecd454c3c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -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")