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

Make ./mill without any arguments point you towards --help, flesh out --help into a cheat sheet #3556

Merged
merged 20 commits into from
Sep 16, 2024
2 changes: 1 addition & 1 deletion .config/mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.0-RC2
0.12.0-RC2
4 changes: 0 additions & 4 deletions docs/modules/ROOT/partials/Intro_to_Mill_Footer.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ usage: mill [options] [[target [target-options]] [+ [target ...]]]
in both REPL and scripts mode if the console is interactive, and
disabled otherwise.
-d --debug Show debug output on STDOUT
--disable-callgraph-invalidation Disable the fine-grained callgraph-based target invalidation in
response to code changes, and instead fall back to the previous
coarse-grained implementation relying on the script `import
$file` graph
--disable-ticker Disable ticker log (e.g. short-lived prints of stages and
progress bars).
--enable-ticker <bool> Enable ticker log (e.g. short-lived prints of stages and
Expand Down
2 changes: 1 addition & 1 deletion example/depth/tasks/2-primary-tasks/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ Expected Signature: run
args <str>...
...

> ./mill --allow-positional-command-args run foo.Foo hello world # this succeeds due to --allow-positional-command-args
> ./mill --allow-positional run foo.Foo hello world # this succeeds due to --allow-positional
Foo.value: 31337
args: hello world
foo.txt resource: My Example Text
Expand Down
2 changes: 1 addition & 1 deletion main/eval/src/mill/eval/EvaluatorImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private[mill] case class EvaluatorImpl(
threadCount: Option[Int] = Some(1),
scriptImportGraph: Map[os.Path, (Int, Seq[os.Path])] = Map.empty,
methodCodeHashSignatures: Map[String, Int],
override val disableCallgraphInvalidation: Boolean,
override val disableCallgraph: Boolean,
override val allowPositionalCommandArgs: Boolean,
val systemExit: Int => Nothing
) extends Evaluator with EvaluatorCore {
Expand Down
105 changes: 53 additions & 52 deletions main/eval/src/mill/eval/GroupEvaluator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private[mill] trait GroupEvaluator {
def threadCount: Option[Int]
def scriptImportGraph: Map[os.Path, (Int, Seq[os.Path])]
def methodCodeHashSignatures: Map[String, Int]
def disableCallgraphInvalidation: Boolean
def disableCallgraph: Boolean
def systemExit: Int => Nothing

lazy val constructorHashSignatures: Map[String, Seq[(String, Int)]] = methodCodeHashSignatures
Expand Down Expand Up @@ -64,59 +64,60 @@ private[mill] trait GroupEvaluator {

val sideHashes = MurmurHash3.orderedHash(group.iterator.map(_.sideHash))

val scriptsHash = group
.iterator
.collect {
case namedTask: NamedTask[_] =>
val encodedTaskName = encode(namedTask.ctx.segment.pathSegments.head)
val methodOpt = for {
parentCls <- classToTransitiveClasses(namedTask.ctx.enclosingCls).iterator
m <- allTransitiveClassMethods(parentCls).get(encodedTaskName)
} yield m

val methodClass = methodOpt
.nextOption()
.getOrElse(throw new MillException(
s"Could not detect the parent class of target ${namedTask}. " +
s"Please report this at ${BuildInfo.millReportNewIssueUrl} . " +
s"As a workaround, you can run Mill with `--disable-callgraph-invalidation` option."
))
.getDeclaringClass.getName

val name = namedTask.ctx.segment.pathSegments.last
val expectedName = methodClass + "#" + name + "()mill.define.Target"

// We not only need to look up the code hash of the Target method being called,
// but also the code hash of the constructors required to instantiate the Module
// that the Target is being called on. This can be done by walking up the nested
// modules and looking at their constructors (they're `object`s and should each
// have only one)
val allEnclosingModules = Vector.unfold(namedTask.ctx) {
case null => None
case ctx =>
ctx.enclosingModule match {
case null => None
case m: mill.define.Module => Some((m, m.millOuterCtx))
case unknown =>
throw new MillException(s"Unknown ctx of target ${namedTask}: $unknown")
}
}
val scriptsHash =
if (disableCallgraph) 0
else group
.iterator
.collect {
case namedTask: NamedTask[_] =>
val encodedTaskName = encode(namedTask.ctx.segment.pathSegments.head)
val methodOpt = for {
parentCls <- classToTransitiveClasses(namedTask.ctx.enclosingCls).iterator
m <- allTransitiveClassMethods(parentCls).get(encodedTaskName)
} yield m

val methodClass = methodOpt
.nextOption()
.getOrElse(throw new MillException(
s"Could not detect the parent class of target ${namedTask}. " +
s"Please report this at ${BuildInfo.millReportNewIssueUrl} . "
))
.getDeclaringClass.getName

val name = namedTask.ctx.segment.pathSegments.last
val expectedName = methodClass + "#" + name + "()mill.define.Target"

// We not only need to look up the code hash of the Target method being called,
// but also the code hash of the constructors required to instantiate the Module
// that the Target is being called on. This can be done by walking up the nested
// modules and looking at their constructors (they're `object`s and should each
// have only one)
val allEnclosingModules = Vector.unfold(namedTask.ctx) {
case null => None
case ctx =>
ctx.enclosingModule match {
case null => None
case m: mill.define.Module => Some((m, m.millOuterCtx))
case unknown =>
throw new MillException(s"Unknown ctx of target ${namedTask}: $unknown")
}
}

val constructorHashes = allEnclosingModules
.map(m =>
constructorHashSignatures.get(m.getClass.getName) match {
case Some(Seq((singleMethod, hash))) => hash
case Some(multiple) => throw new MillException(
s"Multiple constructors found for module $m: ${multiple.mkString(",")}"
)
case None => 0
}
)
val constructorHashes = allEnclosingModules
.map(m =>
constructorHashSignatures.get(m.getClass.getName) match {
case Some(Seq((singleMethod, hash))) => hash
case Some(multiple) => throw new MillException(
s"Multiple constructors found for module $m: ${multiple.mkString(",")}"
)
case None => 0
}
)

methodCodeHashSignatures.get(expectedName) ++ constructorHashes
}
.flatten
.sum
methodCodeHashSignatures.get(expectedName) ++ constructorHashes
}
.flatten
.sum

val inputsHash = externalInputsHash + sideHashes + classLoaderSigHash + scriptsHash

Expand Down
4 changes: 2 additions & 2 deletions runner/src/mill/runner/MillBuildBootstrap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MillBuildBootstrap(
targetsAndParams: Seq[String],
prevRunnerState: RunnerState,
logger: ColorLogger,
disableCallgraphInvalidation: Boolean,
disableCallgraph: Boolean,
needBuildSc: Boolean,
requestedMetaLevel: Option[Int],
allowPositionalCommandArgs: Boolean,
Expand Down Expand Up @@ -351,7 +351,7 @@ class MillBuildBootstrap(
failFast = !keepGoing,
threadCount = threadCount,
methodCodeHashSignatures = methodCodeHashSignatures,
disableCallgraphInvalidation = disableCallgraphInvalidation,
disableCallgraph = disableCallgraph,
allowPositionalCommandArgs = allowPositionalCommandArgs,
systemExit = systemExit
)
Expand Down
Loading
Loading