Skip to content

Commit f917ee8

Browse files
authored
Merge pull request #34 from olafurpg/2.13
Cross build to 2.13 and Scala Native
2 parents d0e8d3c + fdbe6d1 commit f917ee8

File tree

7 files changed

+133
-61
lines changed

7 files changed

+133
-61
lines changed

.travis.yml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
language: scala
2+
sudo: required
3+
dist: trusty
24
script:
3-
- sbt ++$TRAVIS_SCALA_VERSION sourcecodeJVM/test:run sourcecodeJS/test:run
4-
scala:
5-
- 2.10.6
6-
- 2.11.8
7-
- 2.12.0
5+
# plz is like ++ except it skips projects that are not defined for that scala version.
6+
- sbt "plz $TRAVIS_SCALA_VERSION test"
87
jdk:
9-
- openjdk7
108
- oraclejdk8
9+
scala:
10+
- 2.10.6
11+
- 2.11.11
12+
- 2.12.2
13+
- 2.13.0-M1
1114
matrix:
12-
exclude:
13-
- scala: 2.12.0
15+
include:
16+
- scala: 2.10.6
1417
jdk: openjdk7
15-
sudo: false
18+
before_install:
19+
- bash bin/travis_setup.sh
20+
cache:
21+
directories:
22+
- $HOME/.sbt/0.13/dependency
23+
- $HOME/.sbt/boot/scala*
24+
- $HOME/.sbt/launchers
25+
- $HOME/.ivy2/cache
26+
- $HOME/.nvm
27+
before_cache:
28+
- du -h -d 1 $HOME/.ivy2/cache
29+
- du -h -d 2 $HOME/.sbt/
30+
- find $HOME/.sbt -name "*.lock" -type f -delete
31+
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -type f -delete

bin/travis_setup.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
# Original script from https://github.com/scala-native/scala-native/blob/c4eac0707bebc08f4979a0d0eaed16427b734171/bin/travis_setup.sh
3+
4+
# Enable strict mode and fail the script on non-zero exit code,
5+
# unresolved variable or pipe failure.
6+
set -euo pipefail
7+
IFS=$'\n\t'
8+
9+
if [ "$(uname)" == "Darwin" ]; then
10+
11+
brew update
12+
brew install sbt
13+
brew install bdw-gc
14+
brew link bdw-gc
15+
brew install jq
16+
brew install re2
17+
brew install llvm@4
18+
export PATH="/usr/local/opt/llvm@4/bin:$PATH"
19+
20+
else
21+
22+
# Install LLVM/Clang, Boehm GC, libunwind
23+
sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
24+
sudo apt-get -qq update
25+
sudo apt-get install -y -qq \
26+
clang++-3.8 \
27+
libgc-dev \
28+
libunwind8-dev
29+
30+
# Install re2
31+
# Starting from Ubuntu 16.04 LTS, it'll be available as http://packages.ubuntu.com/xenial/libre2-dev
32+
sudo apt-get install -y make
33+
export CXX=clang++-3.8
34+
git clone https://code.googlesource.com/re2
35+
pushd re2
36+
git checkout 2017-03-01
37+
make -j4 test
38+
sudo make install prefix=/usr
39+
make testinstall prefix=/usr
40+
popd
41+
42+
fi

build.sbt

Lines changed: 60 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
1+
import sbtcrossproject.{crossProject, CrossType}
12
import OsgiKeys._
23

3-
crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.0")
4+
val scala210 = "2.10.6"
5+
val scala211 = "2.11.11"
6+
val scala212 = "2.12.2"
7+
val scala213 = "2.13.0-M1"
8+
val baseSettings = Seq(
9+
organization := "com.lihaoyi",
10+
name := "sourcecode",
11+
version := "0.1.4",
12+
scalaVersion := scala211,
13+
crossScalaVersions := Seq(scala210, scala211, scala212, scala213),
14+
scmInfo := Some(ScmInfo(
15+
browseUrl = url("https://github.com/lihaoyi/sourcecode"),
16+
connection = "scm:git:[email protected]:lihaoyi/sourcecode.git"
17+
)),
18+
homepage := Some(url("https://github.com/lihaoyi/sourcecode")),
19+
licenses := Seq("MIT" -> url("http://www.opensource.org/licenses/mit-license.html")),
20+
developers += Developer(
21+
email = "[email protected]",
22+
id = "lihaoyi",
23+
name = "Li Haoyi",
24+
url = url("https://github.com/lihaoyi")
25+
),
26+
publishTo := Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
27+
)
28+
lazy val noPublish = Seq(
29+
publishArtifact := false,
30+
publish := {},
31+
publishLocal := {}
32+
)
33+
34+
baseSettings
35+
noPublish
436

537
def macroDependencies(version: String) =
638
Seq(
@@ -13,46 +45,33 @@ def macroDependencies(version: String) =
1345
else
1446
Seq())
1547

16-
lazy val sourcecode = crossProject.settings(
17-
version := "0.1.4",
18-
scalaVersion := "2.11.8",
19-
name := "sourcecode" ,
20-
organization := "com.lihaoyi",
21-
libraryDependencies ++= macroDependencies(scalaVersion.value),
22-
unmanagedSourceDirectories in Compile ++= {
23-
CrossVersion.partialVersion(scalaVersion.value) match {
24-
case Some((2, n)) if n >= 12 =>
25-
Seq(baseDirectory.value / ".."/"shared"/"src"/ "main" / "scala-2.11")
26-
case _ =>
27-
Seq()
28-
}
29-
},
30-
publishTo := Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2"),
31-
32-
pomExtra :=
33-
<url>https://github.com/lihaoyi/sourcecode</url>
34-
<licenses>
35-
<license>
36-
<name>MIT license</name>
37-
<url>http://www.opensource.org/licenses/mit-license.php</url>
38-
</license>
39-
</licenses>
40-
<scm>
41-
<url>git://github.com/lihaoyi/sourcecode.git</url>
42-
<connection>scm:git://github.com/lihaoyi/sourcecode.git</connection>
43-
</scm>
44-
<developers>
45-
<developer>
46-
<id>lihaoyi</id>
47-
<name>Li Haoyi</name>
48-
<url>https://github.com/lihaoyi</url>
49-
</developer>
50-
</developers>
51-
).enablePlugins(SbtOsgi).settings(osgiSettings).settings(
52-
exportPackage := Seq("sourcecode.*"),
53-
privatePackage := Seq(),
54-
dynamicImportPackage := Seq("*")
55-
)
48+
lazy val sourcecode = crossProject(JSPlatform, JVMPlatform, NativePlatform)
49+
.settings(
50+
baseSettings,
51+
libraryDependencies ++= macroDependencies(scalaVersion.value),
52+
test in Test := (run in Test).toTask("").value,
53+
unmanagedSourceDirectories in Compile ++= {
54+
CrossVersion.partialVersion(scalaVersion.value) match {
55+
case Some((2, n)) if n >= 12 =>
56+
Seq(baseDirectory.value / ".." / "shared" / "src" / "main" / "scala-2.11")
57+
case _ =>
58+
Seq()
59+
}
60+
},
61+
// Osgi settings
62+
osgiSettings,
63+
exportPackage := Seq("sourcecode.*"),
64+
privatePackage := Seq(),
65+
dynamicImportPackage := Seq("*")
66+
)
67+
.enablePlugins(SbtOsgi)
68+
.jsSettings(
69+
scalaJSUseMainModuleInitializer in Test := true // use JVM-style main.
70+
)
71+
.nativeSettings(
72+
crossScalaVersions := Seq(scala211)
73+
)
5674

5775
lazy val js = sourcecode.js
5876
lazy val jvm = sourcecode.jvm
77+
lazy val native = sourcecode.native

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.13
1+
sbt.version=0.13.15

project/build.sbt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.13")
1+
addSbtPlugin("com.eed3si9n" % "sbt-doge" % "0.1.5")
2+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.18")
23
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.8.0")
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")

sourcecode/js/src/test/scala/sourcecode/Main.scala

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)