Skip to content

Commit

Permalink
Support meta-build in Bloop
Browse files Browse the repository at this point in the history
  • Loading branch information
lolgab committed Jun 14, 2024
1 parent 56323c8 commit 1c48033
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion contrib/bloop/src/mill/contrib/bloop/Bloop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import mill.eval.Evaluator
/**
* Usage : `mill mill.contrib.bloop.Bloop/install`
*/
object Bloop extends BloopImpl(() => Evaluator.currentEvaluator.value, os.pwd)
object Bloop extends BloopImpl(() => Evaluator.allBootstrapEvaluators.value, os.pwd)
21 changes: 10 additions & 11 deletions contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import mill.scalanativelib.api.ReleaseMode
* `mill.contrib.bloop.Bloop` object, and usable in tests by passing
* a custom evaluator.
*/
class BloopImpl(ev: () => Evaluator, wd: os.Path) extends ExternalModule { outer =>
class BloopImpl(evs: () => Seq[Evaluator], wd: os.Path) extends ExternalModule { outer =>
import BloopFormats._

private val bloopDir = wd / ".bloop"
Expand Down Expand Up @@ -116,12 +116,14 @@ class BloopImpl(ev: () => Evaluator, wd: os.Path) extends ExternalModule { outer
}

protected def computeModules: Seq[JavaModule] = {
val eval = ev()
if (eval != null)
JavaModuleUtils.transitiveModules(eval.rootModule, accept)
.collect { case jm: JavaModule => jm }
else
Seq.empty
val evals = evs()
evals.flatMap { eval =>
if (eval != null)
JavaModuleUtils.transitiveModules(eval.rootModule, accept)
.collect { case jm: JavaModule => jm }
else
Seq.empty
}
}

// class-based pattern matching against path-dependant types doesn't seem to work.
Expand All @@ -144,10 +146,7 @@ class BloopImpl(ev: () => Evaluator, wd: os.Path) extends ExternalModule { outer
Result.Success(sources.toMap)
}

protected def name(m: JavaModule): String = ModuleUtils.moduleDisplayName(m) match {
case "" => "root-module"
case n => n
}
protected def name(m: JavaModule): String = m.bspDisplayName.replace('/', '-')

protected def bloopConfigPath(module: JavaModule): os.Path =
bloopDir / s"${name(module)}.json"
Expand Down

0 comments on commit 1c48033

Please sign in to comment.