diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-12-12 22:15:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-12 22:15:38 +0800 |
commit | ea7fceb6e56f53bde3517586dfc57e10a605a524 (patch) | |
tree | cf2e4b7a403f8bcbcf3d1c4c45a8abd315cbefe6 /scalanativelib/src | |
parent | d0e1b572e88d311e1aee23d92e0384a81de4bcb6 (diff) | |
download | mill-ea7fceb6e56f53bde3517586dfc57e10a605a524.tar.gz mill-ea7fceb6e56f53bde3517586dfc57e10a605a524.tar.bz2 mill-ea7fceb6e56f53bde3517586dfc57e10a605a524.zip |
First pass at splitting out worker-api from mill core. (#504)
This reduces the {scala,scalajs,scalanative}-worker dependency from the entirety of Mill to a much narrower `mill.api` module. This reduces the amount of classpath pollution within these workers, should mean they're much faster to download the first time, and reduces the amount of random junk they would pull in if they were to be used outside of the Mill project.
The interactions between the various *Modules and their *WorkerImpls has been narrowed down to the `*.api` modules, which only depend on other `*.api` modules.
A lot of things have been moved around; user code is unlikely to break, but it's possible some will if it references classes that have been moved around. Forwarders have been left for the few internal classes that Mill uses in it's own `build.sc`, to support bootstrapping. Third-party code which breaks should be a straightforward to fix just by updating imports
The `*.api` modules have minimal dependencies (mostly uPickle and os-lib) and minimal code. There is still a bunch of implementation code in there: some of it defining data-types that are commonly sent across the module/worker interface (`Agg`, `PathRef`, ...), and some of it just general helper functions that are needed both in modules and workers. The latter code isn't strictly API definitions, but for now is small enough it's not worth splitting into it's own module
Diffstat (limited to 'scalanativelib/src')
-rw-r--r-- | scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala | 27 | ||||
-rw-r--r-- | scalanativelib/src/mill/scalanativelib/ScalaNativeWorkerApi.scala | 34 |
2 files changed, 3 insertions, 58 deletions
diff --git a/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala b/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala index d8a282de..a7a2b96b 100644 --- a/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala +++ b/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala @@ -6,37 +6,14 @@ import java.net.URLClassLoader import coursier.Cache import coursier.maven.MavenRepository import mill.define.{Target, Task} -import mill.eval.Result +import mill.api.Result import mill.modules.Jvm import mill.scalalib.{Dep, DepSyntax, Lib, SbtModule, ScalaModule, TestModule, TestRunner} import mill.util.Loose.Agg import sbt.testing.{AnnotatedFingerprint, SubclassFingerprint} import sbt.testing.Fingerprint import upickle.default.{ReadWriter => RW, macroRW} - - -sealed abstract class NativeLogLevel(val level: Int) extends Ordered[NativeLogLevel] { - def compare(that: NativeLogLevel) = this.level - that.level -} - -object NativeLogLevel { - case object Error extends NativeLogLevel(200) - case object Warn extends NativeLogLevel(300) - case object Info extends NativeLogLevel(400) - case object Debug extends NativeLogLevel(500) - case object Trace extends NativeLogLevel(600) - - implicit def rw: RW[NativeLogLevel] = macroRW -} - -sealed abstract class ReleaseMode(val name: String) - -object ReleaseMode { - case object Debug extends ReleaseMode("debug") - case object Release extends ReleaseMode("release") - - implicit def rw: RW[ReleaseMode] = macroRW -} +import mill.scalanativelib.api._ trait ScalaNativeModule extends ScalaModule { outer => diff --git a/scalanativelib/src/mill/scalanativelib/ScalaNativeWorkerApi.scala b/scalanativelib/src/mill/scalanativelib/ScalaNativeWorkerApi.scala index be834e89..80325f1e 100644 --- a/scalanativelib/src/mill/scalanativelib/ScalaNativeWorkerApi.scala +++ b/scalanativelib/src/mill/scalanativelib/ScalaNativeWorkerApi.scala @@ -5,7 +5,7 @@ import java.net.URLClassLoader import mill.define.{Discover, Worker} import mill.{Agg, T} -import sbt.testing.Framework +import mill.scalanativelib.api._ class ScalaNativeWorker { @@ -38,38 +38,6 @@ class ScalaNativeWorker { } } - -// result wrapper to preserve some type safety -case class NativeConfig(config: Any) - -trait ScalaNativeWorkerApi { - def discoverClang: os.Path - def discoverClangPP: os.Path - def discoverTarget(clang: os.Path, workDir: os.Path): String - def discoverCompileOptions: Seq[String] - def discoverLinkingOptions: Seq[String] - - def config(nativeLibJar: os.Path, - mainClass: String, - classpath: Seq[os.Path], - nativeWorkdir: os.Path, - nativeClang: os.Path, - nativeClangPP: os.Path, - nativeTarget: String, - nativeCompileOptions: Seq[String], - nativeLinkingOptions: Seq[String], - nativeGC: String, - nativeLinkStubs: Boolean, - releaseMode: ReleaseMode, - logLevel: NativeLogLevel): NativeConfig - - def defaultGarbageCollector: String - def nativeLink(nativeConfig: NativeConfig, outPath: os.Path): os.Path - - def newScalaNativeFrameWork(framework: Framework, id: Int, testBinary: File, - logLevel: NativeLogLevel, envVars: Map[String, String]): Framework -} - object ScalaNativeWorkerApi extends mill.define.ExternalModule { def scalaNativeWorker: Worker[ScalaNativeWorker] = T.worker { new ScalaNativeWorker() } lazy val millDiscover = Discover[this.type] |