Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fd760fc

Browse files
Merge pull request #118 from alonsodomin/native
Support for Scala Native
2 parents 615b70f + c70911d commit fd760fc

File tree

5 files changed

+66
-5
lines changed

5 files changed

+66
-5
lines changed

‎.travis.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
language: scala
22

3+
dist: trusty
4+
5+
sudo: required
6+
37
addons:
48
apt:
59
packages:
@@ -11,6 +15,7 @@ before_install:
1115
- sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\1円 $(hostname | cut -c1-63)/" /etc/hosts > /tmp/hosts
1216
- sudo mv /tmp/hosts /etc/hosts
1317
- cat /etc/hosts # optionally check the content *after*
18+
- admin/setup_travis.sh
1419

1520
env:
1621
global:

‎admin/setup_travis.sh‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
6+
sudo apt-get -qq update
7+
sudo apt-get install -y -qq \
8+
clang++-3.8 \
9+
libgc-dev \
10+
libunwind8-dev
11+
12+
# Install re2
13+
# Starting from Ubuntu 16.04 LTS, it'll be available as http://packages.ubuntu.com/xenial/libre2-dev
14+
sudo apt-get install -y make
15+
export CXX=clang++-3.8
16+
git clone https://code.googlesource.com/re2
17+
pushd re2
18+
git checkout 2017年03月01日
19+
make -j4 test
20+
sudo make install prefix=/usr
21+
make testinstall prefix=/usr
22+
popd

‎build.sbt‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ScalaModulePlugin._
2+
import sbtcrossproject.{crossProject, CrossType}
23

34
scalaVersionsByJvm in ThisBuild := {
45
val v211 = "2.11.11"
@@ -14,12 +15,11 @@ scalaVersionsByJvm in ThisBuild := {
1415
}
1516

1617
lazy val root = project.in(file("."))
17-
.aggregate(`scala-parser-combinatorsJS`, `scala-parser-combinatorsJVM`)
18+
.aggregate(`scala-parser-combinatorsJS`, `scala-parser-combinatorsJVM`, `scala-parser-combinatorsNative`)
1819
.settings(disablePublishing)
1920

20-
lazy val `scala-parser-combinators` = crossProject.in(file(".")).
21+
lazy val `scala-parser-combinators` = crossProject(JSPlatform, JVMPlatform, NativePlatform).in(file(".")).
2122
settings(scalaModuleSettings: _*).
22-
jvmSettings(scalaModuleSettingsJVM).
2323
settings(
2424
name := "scala-parser-combinators",
2525
version := "1.0.7-SNAPSHOT",
@@ -40,16 +40,33 @@ lazy val `scala-parser-combinators` = crossProject.in(file(".")).
4040
version.value
4141
)
4242
).
43+
jvmSettings(scalaModuleSettingsJVM).
4344
jvmSettings(
45+
// Mima uses the name of the jvm project in the artifactId
46+
// when resolving previous versions (so no "-jvm" project)
47+
name := "scala-parser-combinators",
4448
OsgiKeys.exportPackage := Seq(s"scala.util.parsing.*;version=${version.value}"),
4549
libraryDependencies += "junit" % "junit" % "4.12" % "test",
4650
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test"
4751
).
4852
jsSettings(
53+
name := "scala-parser-combinators-js",
4954
// Scala.js cannot run forked tests
5055
fork in Test := false
5156
).
52-
jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin))
57+
jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin)).
58+
nativeSettings(
59+
name := "scala-parser-combinators-native",
60+
scalaVersion := "2.11.11",
61+
skip in compile := System.getProperty("java.version").startsWith("1.6"),
62+
test := {},
63+
libraryDependencies := {
64+
if (!scalaVersion.value.startsWith("2.11"))
65+
libraryDependencies.value.filterNot(_.organization == "org.scala-native")
66+
else libraryDependencies.value
67+
}
68+
)
5369

5470
lazy val `scala-parser-combinatorsJVM` = `scala-parser-combinators`.jvm
5571
lazy val `scala-parser-combinatorsJS` = `scala-parser-combinators`.js
72+
lazy val `scala-parser-combinatorsNative` = `scala-parser-combinators`.native
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package scala.util.parsing.input
2+
3+
import java.lang.CharSequence
4+
import java.util.{AbstractMap, Collections}
5+
6+
private[input] trait PositionCache {
7+
private[input] lazy val indexCache: java.util.Map[CharSequence,Array[Int]] = new AbstractMap[CharSequence, Array[Int]] {
8+
9+
override def entrySet() = Collections.emptySet()
10+
11+
// the /dev/null of Maps
12+
override def put(ch: CharSequence, a: Array[Int]) = null
13+
}
14+
}

‎project/plugins.sbt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "1.0.12")
22

3-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.18")
3+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.18")
4+
addSbtPlugin("org.scala-native" % "sbt-crossproject" % "0.2.0")
5+
addSbtPlugin("org.scala-native" % "sbt-scalajs-crossproject" % "0.2.0")
6+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.1")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /