From 61fa0fdadf5cc2b2c23cecad6efc0f61ac602759 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Sat, 23 Jan 2021 19:40:10 +0100 Subject: [PATCH 1/8] Add support for Scala Native 0.4 --- .travis.yml | 9 +++++---- build.sbt | 10 +++++++++- build.sh | 4 +++- project/plugins.sbt | 5 +++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7449e1727..b7ad9c919 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,10 +11,11 @@ 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 install: - git fetch --tags # get all tags for sbt-dynver diff --git a/build.sbt b/build.sbt index a392cce29..d4241eec8 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,11 @@ 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, + addCompilerPlugin("org.scala-native" % "junit-plugin" % nativeVersion cross CrossVersion.full), + 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") From 154361ba0108477425665b76f18092d43995dd34 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Sat, 23 Jan 2021 19:55:27 +0100 Subject: [PATCH 2/8] Exclude Scala 3 from Scala Native builds --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index b7ad9c919..4778e5ee8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,13 @@ env: - 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 From 047e95391e6a2a4b6c0aa122e98446f184edd6ea Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Sat, 23 Jan 2021 20:13:25 +0100 Subject: [PATCH 3/8] Add junit-runtime in the compile scope --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index d4241eec8..4a869a866 100644 --- a/build.sbt +++ b/build.sbt @@ -167,7 +167,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) scalaModuleMimaPreviousVersion := None, // No such release yet // Scala Native cannot run forked tests Test / fork := false, - libraryDependencies += "org.scala-native" %%% "junit-runtime" % nativeVersion % Test, + libraryDependencies += "org.scala-native" %%% "junit-runtime" % nativeVersion, addCompilerPlugin("org.scala-native" % "junit-plugin" % nativeVersion cross CrossVersion.full), Test / testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-s", "-v") ) From 4dff89960b0cb828b7037d3a0020e54443a5f403 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Fri, 29 Jan 2021 13:55:49 +0100 Subject: [PATCH 4/8] Move JUnit Plugin to the test scope --- build.sbt | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 4a869a866..c3a6009cb 100644 --- a/build.sbt +++ b/build.sbt @@ -167,7 +167,23 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) scalaModuleMimaPreviousVersion := None, // No such release yet // Scala Native cannot run forked tests Test / fork := false, - libraryDependencies += "org.scala-native" %%% "junit-runtime" % nativeVersion, - addCompilerPlugin("org.scala-native" % "junit-plugin" % nativeVersion cross CrossVersion.full), + 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(s"/org/scala-native/junit-plugin_${scalaVersion.value}/$nativeVersion/junit-plugin_${scalaVersion.value}-$nativeVersion.jar")) + .getOrElse(throw new Exception("Can't find Scala Native junit-plugin jar")) + s"-Xplugin:$jarPath" + }, Test / testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-s", "-v") ) From 79f9bb915fbf87b28c4d32d8961665b245ba23a2 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Fri, 29 Jan 2021 15:13:33 +0100 Subject: [PATCH 5/8] Simplify classpath search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Doeraene --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index c3a6009cb..9ff6394ee 100644 --- a/build.sbt +++ b/build.sbt @@ -181,7 +181,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) .fold(w => throw w.resolveException, identity(_)) val jarPath = cp - .find(_.toString.contains(s"/org/scala-native/junit-plugin_${scalaVersion.value}/$nativeVersion/junit-plugin_${scalaVersion.value}-$nativeVersion.jar")) + .find(_.toString.contains("junit-plugin")) .getOrElse(throw new Exception("Can't find Scala Native junit-plugin jar")) s"-Xplugin:$jarPath" }, From e5f4e516f3737ff9f648a3f2b53299d829d71fc6 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Fri, 29 Jan 2021 17:13:45 +0100 Subject: [PATCH 6/8] Add CircleCI Scala Native steps --- .circleci/config.yml | 36 ++++++++++++++++++++++++++++++++++++ .scalafmt.conf | 1 + 2 files changed, 37 insertions(+) create mode 100644 .scalafmt.conf diff --git a/.circleci/config.yml b/.circleci/config.yml index c91fb5898..099837669 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,31 @@ 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 sbt clang-8 openjdk-8-jdk + - 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 +168,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" From 03bb7ad82c335c2f725adcd7213bd5bd9ea1e433 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Fri, 29 Jan 2021 17:25:32 +0100 Subject: [PATCH 7/8] Add clang system links --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 099837669..52c67f749 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -101,6 +101,8 @@ jobs: curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add sudo apt-get update sudo apt-get install 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 From 05c8ba2de0e7155f4e97a601237853c72fba5c47 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Fri, 29 Jan 2021 17:32:38 +0100 Subject: [PATCH 8/8] Add -y to apt-get install command in CircleCI --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 52c67f749..a5f38c020 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -100,7 +100,7 @@ jobs: 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 sbt clang-8 openjdk-8-jdk + 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: