From 1d735700be30427bcc76c119655cd45673e144ce Mon Sep 17 00:00:00 2001 From: Antonio Alonso Dominguez Date: Mon, 19 Jun 2017 22:50:53 +0100 Subject: [PATCH 1/9] Initial support for Scala Native --- build.sbt | 24 ++++++++++++++----- .../util/parsing/input/PositionCache.scala | 14 +++++++++++ project/plugins.sbt | 7 ++++++ 3 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 native/src/main/scala/scala/util/parsing/input/PositionCache.scala diff --git a/build.sbt b/build.sbt index 2b28720b..3a5b2cb2 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,5 @@ import ScalaModulePlugin._ +import sbtcrossproject.{crossProject, CrossType} scalaVersionsByJvm in ThisBuild := { val v211 = "2.11.11" @@ -14,15 +15,16 @@ scalaVersionsByJvm in ThisBuild := { } lazy val root = project.in(file(".")) - .aggregate(`scala-parser-combinatorsJS`, `scala-parser-combinatorsJVM`) + .aggregate(`scala-parser-combinatorsJS`, `scala-parser-combinatorsJVM`, `scala-parser-combinatorsNative`) .settings(disablePublishing) -lazy val `scala-parser-combinators` = crossProject.in(file(".")). +lazy val `scala-parser-combinators` = crossProject(JSPlatform, JVMPlatform, NativePlatform).in(file(".")). settings(scalaModuleSettings: _*). - jvmSettings(scalaModuleSettingsJVM). settings( - repoName := "scala-parser-combinators", - version := "1.0.7-SNAPSHOT", + moduleName := "scala-parser-combinators", + repoName := moduleName.value, + version := "1.0.7-SNAPSHOT", + mimaPreviousVersion := Some("1.0.5"), apiMappings += (scalaInstance.value.libraryJar -> @@ -40,16 +42,26 @@ lazy val `scala-parser-combinators` = crossProject.in(file(".")). version.value ) ). + jvmSettings(scalaModuleSettingsJVM). jvmSettings( + // Mima uses the name of the jvm project in the artifactId + // when resolving previous versions (so no "-jvm" project) + name := "scala-parser-combinators", OsgiKeys.exportPackage := Seq(s"scala.util.parsing.*;version=${version.value}"), libraryDependencies += "junit" % "junit" % "4.12" % "test", libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test" ). jsSettings( + name := "scala-parser-combinators-js", // Scala.js cannot run forked tests fork in Test := false ). - jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin)) + jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin)). + nativeSettings( + name := "scala-parser-combinators-native", + scalaVersion := "2.11.11" + ) lazy val `scala-parser-combinatorsJVM` = `scala-parser-combinators`.jvm lazy val `scala-parser-combinatorsJS` = `scala-parser-combinators`.js +lazy val `scala-parser-combinatorsNative` = `scala-parser-combinators`.native diff --git a/native/src/main/scala/scala/util/parsing/input/PositionCache.scala b/native/src/main/scala/scala/util/parsing/input/PositionCache.scala new file mode 100644 index 00000000..ff9f144f --- /dev/null +++ b/native/src/main/scala/scala/util/parsing/input/PositionCache.scala @@ -0,0 +1,14 @@ +package scala.util.parsing.input + +import java.lang.CharSequence +import java.util.{AbstractMap, Collections} + +private[input] trait PositionCache { + private[input] lazy val indexCache: java.util.Map[CharSequence,Array[Int]] = new AbstractMap[CharSequence, Array[Int]] { + + override def entrySet() = Collections.emptySet() + + // the /dev/null of Maps + override def put(ch: CharSequence, a: Array[Int]) = null + } +} diff --git a/project/plugins.sbt b/project/plugins.sbt index f86a39c2..75992aef 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,10 @@ addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "1.0.12") +<<<<<<< HEAD addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.18") +======= +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.16") +addSbtPlugin("org.scala-native" % "sbt-crossproject" % "0.2.0") +addSbtPlugin("org.scala-native" % "sbt-scalajs-crossproject" % "0.2.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.2.1") +>>>>>>> Initial support for Scala Native From 1d825f6772346544d3b263946e19b4f4d1985956 Mon Sep 17 00:00:00 2001 From: Antonio Alonso Dominguez Date: Mon, 19 Jun 2017 23:13:35 +0100 Subject: [PATCH 2/9] Setup travis for native compilation --- .travis.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.travis.yml b/.travis.yml index 24adf95e..16cbcd3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,32 @@ before_install: - sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts > /tmp/hosts - sudo mv /tmp/hosts /etc/hosts - cat /etc/hosts # optionally check the content *after* + - sudo apt-get -qq update + - sudo sh -c "echo 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise-3.7 main' >> /etc/apt/sources.list" + - sudo sh -c "echo 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise main' >> /etc/apt/sources.list" + - wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add - + - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test + - sudo apt-get -qq update + - | + sudo apt-get install -y \ + clang++-3.7 \ + llvm-3.7 \ + llvm-3.7-dev \ + llvm-3.7-runtime \ + llvm-3.7-tool \ + libgc-dev \ + libunwind7-dev + # Install re2 + # (libre2-dev) since Xenial (16.04 LTS) http://packages.ubuntu.com/xenial/libre2-dev + - sudo apt-get install -y make + - export CXX=clang++-3.7 + - git clone https://code.googlesource.com/re2 + - pushd re2 + - git checkout 2017-03-01 + - make -j4 test + - sudo make install prefix=/usr + - make testinstall prefix=/usr + - popd env: global: From 0cf4ce6b15b4d1936082338672e826566a459936 Mon Sep 17 00:00:00 2001 From: Antonio Alonso Dominguez Date: Tue, 20 Jun 2017 08:26:43 +0100 Subject: [PATCH 3/9] Run Precise on TravisCI --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 16cbcd3d..ec79c899 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: scala +sudo: required + addons: apt: packages: From ee2513f87d5365d5d3f567e309c71565d3bab0dc Mon Sep 17 00:00:00 2001 From: Antonio Alonso Dominguez Date: Tue, 11 Jul 2017 13:19:09 +0100 Subject: [PATCH 4/9] Upgrade Scala Native --- project/plugins.sbt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 75992aef..7620ecc4 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,10 +1,6 @@ addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "1.0.12") -<<<<<<< HEAD -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.18") -======= -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.16") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.18") addSbtPlugin("org.scala-native" % "sbt-crossproject" % "0.2.0") addSbtPlugin("org.scala-native" % "sbt-scalajs-crossproject" % "0.2.0") -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.2.1") ->>>>>>> Initial support for Scala Native +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.1") From fed1867fe9dac35b04d767721fa4c6654d17eb5b Mon Sep 17 00:00:00 2001 From: Antonio Alonso Dominguez Date: Mon, 17 Jul 2017 23:37:37 +0100 Subject: [PATCH 5/9] Skip compilation in Java 6 --- build.sbt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 3a5b2cb2..6c0f2d91 100644 --- a/build.sbt +++ b/build.sbt @@ -59,7 +59,9 @@ lazy val `scala-parser-combinators` = crossProject(JSPlatform, JVMPlatform, Nati jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin)). nativeSettings( name := "scala-parser-combinators-native", - scalaVersion := "2.11.11" + scalaVersion := "2.11.11", + skip in compile := System.getProperty("java.version").startsWith("1.6"), + test := {} ) lazy val `scala-parser-combinatorsJVM` = `scala-parser-combinators`.jvm From 31895c52f85a91b1a1403d11833f303136113598 Mon Sep 17 00:00:00 2001 From: Antonio Alonso Dominguez Date: Mon, 17 Jul 2017 23:58:07 +0100 Subject: [PATCH 6/9] Run Travis build in Trusty --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ec79c899..c180cb7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,8 @@ language: scala sudo: required +dist: trusty + addons: apt: packages: From ed16889c86d617a3e47aee5eaa798b951ad03942 Mon Sep 17 00:00:00 2001 From: Antonio Alonso Dominguez Date: Tue, 18 Jul 2017 00:15:48 +0100 Subject: [PATCH 7/9] Configure Travis via a script --- .travis.yml | 31 ++----------------------------- admin/setup_travis.sh | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 29 deletions(-) create mode 100755 admin/setup_travis.sh diff --git a/.travis.yml b/.travis.yml index c180cb7c..a324da88 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,6 @@ language: scala sudo: required -dist: trusty - addons: apt: packages: @@ -14,33 +12,8 @@ before_install: - sudo hostname "$(hostname | cut -c1-63)" - sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts > /tmp/hosts - sudo mv /tmp/hosts /etc/hosts - - cat /etc/hosts # optionally check the content *after* - - sudo apt-get -qq update - - sudo sh -c "echo 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise-3.7 main' >> /etc/apt/sources.list" - - sudo sh -c "echo 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise main' >> /etc/apt/sources.list" - - wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add - - - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test - - sudo apt-get -qq update - - | - sudo apt-get install -y \ - clang++-3.7 \ - llvm-3.7 \ - llvm-3.7-dev \ - llvm-3.7-runtime \ - llvm-3.7-tool \ - libgc-dev \ - libunwind7-dev - # Install re2 - # (libre2-dev) since Xenial (16.04 LTS) http://packages.ubuntu.com/xenial/libre2-dev - - sudo apt-get install -y make - - export CXX=clang++-3.7 - - git clone https://code.googlesource.com/re2 - - pushd re2 - - git checkout 2017-03-01 - - make -j4 test - - sudo make install prefix=/usr - - make testinstall prefix=/usr - - popd + - cat /etc/hosts # optionally check the content *after* + - admin/setup_travis.sh env: global: diff --git a/admin/setup_travis.sh b/admin/setup_travis.sh new file mode 100755 index 00000000..294ee6a2 --- /dev/null +++ b/admin/setup_travis.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test +sudo apt-get -qq update +sudo apt-get install -y -qq \ + clang++-3.8 \ + libgc-dev \ + libunwind8-dev + +# Install re2 +# Starting from Ubuntu 16.04 LTS, it'll be available as http://packages.ubuntu.com/xenial/libre2-dev +sudo apt-get install -y make +export CXX=clang++-3.8 +git clone https://code.googlesource.com/re2 +pushd re2 +git checkout 2017-03-01 +make -j4 test +sudo make install prefix=/usr +make testinstall prefix=/usr +popd From 4f282903e39c5f17d84f24e54d329863f126807d Mon Sep 17 00:00:00 2001 From: Antonio Alonso Dominguez Date: Tue, 18 Jul 2017 00:17:47 +0100 Subject: [PATCH 8/9] Run on Trusty --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a324da88..1adc8e03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: scala +dist: trusty + sudo: required addons: @@ -12,7 +14,7 @@ before_install: - sudo hostname "$(hostname | cut -c1-63)" - sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts > /tmp/hosts - sudo mv /tmp/hosts /etc/hosts - - cat /etc/hosts # optionally check the content *after* + - cat /etc/hosts # optionally check the content *after* - admin/setup_travis.sh env: From 7370390a34b16ce85a4899c1e786959176dfa9e1 Mon Sep 17 00:00:00 2001 From: Antonio Alonso Dominguez Date: Tue, 18 Jul 2017 00:39:55 +0100 Subject: [PATCH 9/9] Remove Scala Native dependencies when not in Scala 2.11 --- build.sbt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 6c0f2d91..a73b07a8 100644 --- a/build.sbt +++ b/build.sbt @@ -61,7 +61,12 @@ lazy val `scala-parser-combinators` = crossProject(JSPlatform, JVMPlatform, Nati name := "scala-parser-combinators-native", scalaVersion := "2.11.11", skip in compile := System.getProperty("java.version").startsWith("1.6"), - test := {} + test := {}, + libraryDependencies := { + if (!scalaVersion.value.startsWith("2.11")) + libraryDependencies.value.filterNot(_.organization == "org.scala-native") + else libraryDependencies.value + } ) lazy val `scala-parser-combinatorsJVM` = `scala-parser-combinators`.jvm