diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-12-30 19:01:03 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-12-30 20:35:31 -0800 |
commit | 356dca0f92931b07e1a80013aefb025b6a7d7d42 (patch) | |
tree | 6517cbd15943361cbd896e64a7007c058f20281d /scalajslib/bridge_0_6/src/main | |
parent | e84eff79f6f23b9a6518c74ba137ab4ce1347929 (diff) | |
download | mill-356dca0f92931b07e1a80013aefb025b6a7d7d42.tar.gz mill-356dca0f92931b07e1a80013aefb025b6a7d7d42.tar.bz2 mill-356dca0f92931b07e1a80013aefb025b6a7d7d42.zip |
`Core` -> `core`, for consistency with SBT naming schemes
`ScalaPlugin` -> `scalalib`, to avoid confusion with Scala compiler plugins
`ScalaModule` -> `module`, to be used via `scalalib.Module`, avoid unnecessary duplication in th name prefix
`plugin` -> `moduledefs`, to more accurately describe what it does (since it includes `Cacher` as well)
Diffstat (limited to 'scalajslib/bridge_0_6/src/main')
-rw-r--r-- | scalajslib/bridge_0_6/src/main/scala/mill/scalajslib/bridge/ScalaJSLinkerBridge.scala | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/scalajslib/bridge_0_6/src/main/scala/mill/scalajslib/bridge/ScalaJSLinkerBridge.scala b/scalajslib/bridge_0_6/src/main/scala/mill/scalajslib/bridge/ScalaJSLinkerBridge.scala new file mode 100644 index 00000000..4826b1cd --- /dev/null +++ b/scalajslib/bridge_0_6/src/main/scala/mill/scalajslib/bridge/ScalaJSLinkerBridge.scala @@ -0,0 +1,24 @@ +package mill +package scalajslib +package bridge + +import java.io.File + +import org.scalajs.core.tools.io.IRFileCache.IRContainer +import org.scalajs.core.tools.io.{AtomicWritableFileVirtualJSFile, FileVirtualBinaryFile, FileVirtualScalaJSIRFile, VirtualJarFile} +import org.scalajs.core.tools.linker.{ModuleInitializer, StandardLinker} +import org.scalajs.core.tools.logging.ScalaConsoleLogger + +class ScalaJSLinkerBridge { + def link(sources: Array[File], libraries: Array[File], dest: File, main: String, fullOpt: Boolean): Unit = { + val config = StandardLinker.Config().withOptimizer(fullOpt) + val linker = StandardLinker(config) + val sourceSJSIRs = sources.map(new FileVirtualScalaJSIRFile(_)) + val jars = libraries.map(jar => IRContainer.Jar(new FileVirtualBinaryFile(jar) with VirtualJarFile)) + val jarSJSIRs = jars.flatMap(_.jar.sjsirFiles) + val destFile = AtomicWritableFileVirtualJSFile(dest) + val logger = new ScalaConsoleLogger + val initializer = Option(main).map { cls => ModuleInitializer.mainMethodWithArgs(cls, "main") } + linker.link(sourceSJSIRs ++ jarSJSIRs, initializer.toSeq, destFile, logger) + } +}
\ No newline at end of file |