Skip to content

Commit a65a1aa

Browse files
committed
Port built to Scala Native.
Scala.js 0.6.18 added support for JVM-style main functions which makes it possible to use the same entry point for the tests on all platforms.
1 parent 4f2fe77 commit a65a1aa

File tree

6 files changed

+63
-19
lines changed

6 files changed

+63
-19
lines changed

.travis.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
language: scala
2-
32
sudo: required
4-
53
dist: trusty
6-
74
jdk:
85
- oraclejdk8
96
scala:
@@ -15,16 +12,15 @@ matrix:
1512
include:
1613
- scala: 2.10.6
1714
jdk: openjdk7
18-
19-
# Taken from https://github.com/typelevel/cats/blob/master/.travis.yml
15+
before_install:
16+
- bash bin/travis_setup.sh
2017
cache:
2118
directories:
2219
- $HOME/.sbt/0.13/dependency
2320
- $HOME/.sbt/boot/scala*
2421
- $HOME/.sbt/launchers
2522
- $HOME/.ivy2/cache
2623
- $HOME/.nvm
27-
2824
before_cache:
2925
- du -h -d 1 $HOME/.ivy2/cache
3026
- du -h -d 2 $HOME/.sbt/

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: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
import sbtcrossproject.{crossProject, CrossType}
12
import OsgiKeys._
23

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"
38
val baseSettings = Seq(
49
organization := "com.lihaoyi",
510
name := "sourcecode",
611
version := "0.1.4",
7-
scalaVersion := "2.11.11",
8-
crossScalaVersions := Seq("2.10.6", "2.11.11", "2.12.2", "2.13.0-M1"),
12+
scalaVersion := scala211,
13+
crossScalaVersions := Seq(scala210, scala211, scala212, scala213),
914
scmInfo := Some(ScmInfo(
1015
browseUrl = url("https://github.com/lihaoyi/sourcecode"),
1116
connection = "scm:git:git@github.com:lihaoyi/sourcecode.git"
@@ -33,7 +38,7 @@ def macroDependencies(version: String) =
3338
else
3439
Seq())
3540

36-
lazy val sourcecode = crossProject
41+
lazy val sourcecode = crossProject(JSPlatform, JVMPlatform, NativePlatform)
3742
.settings(baseSettings)
3843
.settings(
3944
libraryDependencies ++= macroDependencies(scalaVersion.value),
@@ -55,6 +60,13 @@ lazy val sourcecode = crossProject
5560
privatePackage := Seq(),
5661
dynamicImportPackage := Seq("*")
5762
)
63+
.jsSettings(
64+
scalaJSUseMainModuleInitializer in Test := true // use JVM-style main.
65+
)
66+
.nativeSettings(
67+
crossScalaVersions := Seq(scala211)
68+
)
5869

5970
lazy val js = sourcecode.js
6071
lazy val jvm = sourcecode.jvm
72+
lazy val native = sourcecode.native

project/build.sbt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.16")
1+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.18")
22
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.8.0")
3+
addSbtPlugin("org.scala-native" % "sbt-crossproject" % "0.2.0")
4+
addSbtPlugin("org.scala-native" % "sbt-scalajs-crossproject" % "0.2.0")
5+
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)