Skip to content

Commit

Permalink
Merge pull request #34 from olafurpg/2.13
Browse files Browse the repository at this point in the history
Cross build to 2.13 and Scala Native
  • Loading branch information
olafurpg authored Jul 8, 2017
2 parents d0e8d3c + fdbe6d1 commit f917ee8
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 61 deletions.
34 changes: 25 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
language: scala
sudo: required
dist: trusty
script:
- sbt ++$TRAVIS_SCALA_VERSION sourcecodeJVM/test:run sourcecodeJS/test:run
scala:
- 2.10.6
- 2.11.8
- 2.12.0
# plz is like ++ except it skips projects that are not defined for that scala version.
- sbt "plz $TRAVIS_SCALA_VERSION test"
jdk:
- openjdk7
- oraclejdk8
scala:
- 2.10.6
- 2.11.11
- 2.12.2
- 2.13.0-M1
matrix:
exclude:
- scala: 2.12.0
include:
- scala: 2.10.6
jdk: openjdk7
sudo: false
before_install:
- bash bin/travis_setup.sh
cache:
directories:
- $HOME/.sbt/0.13/dependency
- $HOME/.sbt/boot/scala*
- $HOME/.sbt/launchers
- $HOME/.ivy2/cache
- $HOME/.nvm
before_cache:
- du -h -d 1 $HOME/.ivy2/cache
- du -h -d 2 $HOME/.sbt/
- find $HOME/.sbt -name "*.lock" -type f -delete
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -type f -delete
42 changes: 42 additions & 0 deletions bin/travis_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Original script from https:/scala-native/scala-native/blob/c4eac0707bebc08f4979a0d0eaed16427b734171/bin/travis_setup.sh

# Enable strict mode and fail the script on non-zero exit code,
# unresolved variable or pipe failure.
set -euo pipefail
IFS=$'\n\t'

if [ "$(uname)" == "Darwin" ]; then

brew update
brew install sbt
brew install bdw-gc
brew link bdw-gc
brew install jq
brew install re2
brew install llvm@4
export PATH="/usr/local/opt/llvm@4/bin:$PATH"

else

# Install LLVM/Clang, Boehm GC, libunwind
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

fi
101 changes: 60 additions & 41 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
import sbtcrossproject.{crossProject, CrossType}
import OsgiKeys._

crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.0")
val scala210 = "2.10.6"
val scala211 = "2.11.11"
val scala212 = "2.12.2"
val scala213 = "2.13.0-M1"
val baseSettings = Seq(
organization := "com.lihaoyi",
name := "sourcecode",
version := "0.1.4",
scalaVersion := scala211,
crossScalaVersions := Seq(scala210, scala211, scala212, scala213),
scmInfo := Some(ScmInfo(
browseUrl = url("https:/lihaoyi/sourcecode"),
connection = "scm:git:[email protected]:lihaoyi/sourcecode.git"
)),
homepage := Some(url("https:/lihaoyi/sourcecode")),
licenses := Seq("MIT" -> url("http://www.opensource.org/licenses/mit-license.html")),
developers += Developer(
email = "[email protected]",
id = "lihaoyi",
name = "Li Haoyi",
url = url("https:/lihaoyi")
),
publishTo := Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
)
lazy val noPublish = Seq(
publishArtifact := false,
publish := {},
publishLocal := {}
)

baseSettings
noPublish

def macroDependencies(version: String) =
Seq(
Expand All @@ -13,46 +45,33 @@ def macroDependencies(version: String) =
else
Seq())

lazy val sourcecode = crossProject.settings(
version := "0.1.4",
scalaVersion := "2.11.8",
name := "sourcecode" ,
organization := "com.lihaoyi",
libraryDependencies ++= macroDependencies(scalaVersion.value),
unmanagedSourceDirectories in Compile ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 12 =>
Seq(baseDirectory.value / ".."/"shared"/"src"/ "main" / "scala-2.11")
case _ =>
Seq()
}
},
publishTo := Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2"),

pomExtra :=
<url>https://github.com/lihaoyi/sourcecode</url>
<licenses>
<license>
<name>MIT license</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>
<scm>
<url>git://github.com/lihaoyi/sourcecode.git</url>
<connection>scm:git://github.com/lihaoyi/sourcecode.git</connection>
</scm>
<developers>
<developer>
<id>lihaoyi</id>
<name>Li Haoyi</name>
<url>https://github.com/lihaoyi</url>
</developer>
</developers>
).enablePlugins(SbtOsgi).settings(osgiSettings).settings(
exportPackage := Seq("sourcecode.*"),
privatePackage := Seq(),
dynamicImportPackage := Seq("*")
)
lazy val sourcecode = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.settings(
baseSettings,
libraryDependencies ++= macroDependencies(scalaVersion.value),
test in Test := (run in Test).toTask("").value,
unmanagedSourceDirectories in Compile ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 12 =>
Seq(baseDirectory.value / ".." / "shared" / "src" / "main" / "scala-2.11")
case _ =>
Seq()
}
},
// Osgi settings
osgiSettings,
exportPackage := Seq("sourcecode.*"),
privatePackage := Seq(),
dynamicImportPackage := Seq("*")
)
.enablePlugins(SbtOsgi)
.jsSettings(
scalaJSUseMainModuleInitializer in Test := true // use JVM-style main.
)
.nativeSettings(
crossScalaVersions := Seq(scala211)
)

lazy val js = sourcecode.js
lazy val jvm = sourcecode.jvm
lazy val native = sourcecode.native
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.13
sbt.version=0.13.15
6 changes: 5 additions & 1 deletion project/build.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.13")
addSbtPlugin("com.eed3si9n" % "sbt-doge" % "0.1.5")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.18")
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.8.0")
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.3.1")
9 changes: 0 additions & 9 deletions sourcecode/js/src/test/scala/sourcecode/Main.scala

This file was deleted.

0 comments on commit f917ee8

Please sign in to comment.