Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Mill CLI to select the meta-build frame it operates on #2719

Merged
merged 19 commits into from
Sep 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't evaluate higher level frames if we run with --frame option
I applied one hack-ish way to avoid instantiating the higher level evaluators by just assigning `null`.
This should be refactored, e.g. by representing a skipped frame by it's own case class.
lefou committed Aug 30, 2023
commit a3761a1864acdd3bb29ddff49cd3738afe78de14
36 changes: 19 additions & 17 deletions runner/src/mill/runner/MillBuildBootstrap.scala
Original file line number Diff line number Diff line change
@@ -117,7 +117,23 @@ class MillBuildBootstrap(
if (nestedState.errorOpt.isDefined) nestedState.add(errorOpt = nestedState.errorOpt)
else if (depth == 0 && requestedDepth > nestedState.frames.size) {
// User has requested a frame depth, we actually don't have
nestedState.add(errorOpt = Some(s"The project has no meta-build frame ${requestedDepth}"))
nestedState.add(errorOpt = Some(s"Invalid selected frame ${requestedDepth}. Valid range: 0 .. ${nestedState.frames.size}"))
} else if (depth < requestedDepth) {
// We already evaluated, hence we just need to make sure, we return a proper structure with all already existing watch data
val evalState = RunnerState.Frame(
prevFrameOpt.map(_.workerCache).getOrElse(Map.empty),
Seq.empty,
Seq.empty,
Map.empty,
Map.empty,
None,
Nil,
// FIXME we don't want to evaluator anything in this depth, so we just skip creating an evaluator,
// mainly because we didn't even constructed (compiled) it's classpath
// TODO: Instead, introduce a skipped frame type, so we can better comunicate that state
null
)
nestedState.add(frame = evalState, errorOpt = None)
} else {
val validatedRootModuleOrErr = nestedState.frames.headOption match {
case None =>
@@ -165,29 +181,15 @@ class MillBuildBootstrap(
)

if (retState.errorOpt.isEmpty && depth == requestedDepth) {
// TODO: print some message and indicate actual evaluated frame
val evalRet = processFinalTargets(nestedState, rootModule, evaluator)
if (evalRet.errorOpt.isEmpty) retState
else evalRet
} else
retState

} else {
if (depth == requestedDepth) {
processFinalTargets(nestedState, rootModule, evaluator)
} else {
// TODO what now, we already evaluated some level below, so we can just return with Success?
val evalState = RunnerState.Frame(
evaluator.workerCache.toMap,
Seq.empty,
Seq.empty,
Map.empty,
Map.empty,
None,
Nil,
evaluator
)
nestedState.add(frame = evalState, errorOpt = None)
}
processFinalTargets(nestedState, rootModule, evaluator)
}
}
}