diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-11-07 02:21:50 -0500 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-11-07 02:21:50 -0500 |
commit | c6b9a480879c101028b20b9cc8716b8ffa773630 (patch) | |
tree | fff15c1d6595455f6994f5793b63b08c5bf24d4a /plugins/scalajs/ScalaJsBuild.scala | |
parent | c89f87c9c9a0c7b256f225e37c55cb34f060aa6c (diff) | |
parent | fd849d293448d55c6bcb6f8440f44838b51fc860 (diff) | |
download | cbt-c6b9a480879c101028b20b9cc8716b8ffa773630.tar.gz cbt-c6b9a480879c101028b20b9cc8716b8ffa773630.tar.bz2 cbt-c6b9a480879c101028b20b9cc8716b8ffa773630.zip |
Merge remote-tracking branch 'origin/master' into integrate-eval
Diffstat (limited to 'plugins/scalajs/ScalaJsBuild.scala')
-rw-r--r-- | plugins/scalajs/ScalaJsBuild.scala | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/plugins/scalajs/ScalaJsBuild.scala b/plugins/scalajs/ScalaJsBuild.scala new file mode 100644 index 0000000..9374f66 --- /dev/null +++ b/plugins/scalajs/ScalaJsBuild.scala @@ -0,0 +1,52 @@ +package cbt +import java.io.File +import java.net.URL + +trait ScalaJsBuild extends BaseBuild { + final protected val scalaJsLib = ScalaJsLib( + scalaJsVersion, + scalaVersion, + context.cbtHasChanged, + context.classLoaderCache, + context.paths.mavenCache + ) + import scalaJsLib.{link => _,_} + + def scalaJsVersion = "0.6.8" + final protected val scalaJsMajorVersion: String = lib.libMajorVersion(scalaJsVersion) + final protected val artifactIdSuffix = s"_sjs$scalaJsMajorVersion" + + override def dependencies = super.dependencies :+ scalaJsLibraryDependency + override def scalacOptions = super.scalacOptions ++ scalaJsLib.scalacOptions + + /** Note: We make same assumption about scala version. + In order to be able to choose different scala version, one has to use %. */ + implicit class ScalaJsDependencyBuilder(groupId: String){ + def %%%(artifactId: String) = new DependencyBuilder2( + groupId, artifactId + artifactIdSuffix, Some(scalaMajorVersion)) + } + + private def link(mode: ScalaJsOutputMode, outputPath: File) = scalaJsLib.link( + mode, outputPath, scalaJsOptions, + target +: dependencies.collect{case d: BoundMavenDependency => d.jar} + ) + + def scalaJsOptions: Seq[String] = Seq() + def scalaJsOptionsFastOpt: Seq[String] = scalaJsOptions + def scalaJsOptionsFullOpt: Seq[String] = scalaJsOptions + + private def output(mode: ScalaJsOutputMode) = target ++ s"/$projectName-${mode.fileSuffix}.js" + protected def fastOptJSFile: File = output(FastOptJS) + protected def fullOptJSFile: File = output(FullOptJS) + + def fastOptJS = { + compile + link(FastOptJS, fastOptJSFile) + fastOptJSFile + } + def fullOptJS = { + compile + link(FullOptJS, fullOptJSFile) + fullOptJSFile + } +} |