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

Refactored root modules finder #2648

Closed
wants to merge 6 commits into from
Closed

Conversation

lefou
Copy link
Member

@lefou lefou commented Jul 4, 2023

Moved root module finder logic into dedicated RootModuleFinder object.

Changed PrefixLogger to accept a Logger instead of a ColorLogger.

Also added a quiet flag to MainModule.resolve. This is useful, if we need the return value, but do not want the command to print the resolved outcome.

lefou added 4 commits July 14, 2023 09:31
Changed `PrefixLogger` to accept a `Logger` instead of a `ColorLogger`.

Also added a `quiet` flat to `MainModule.resolve`.
@lefou lefou force-pushed the refactor-find-root-modules branch from ce3f846 to 552d312 Compare July 14, 2023 07:31
@lefou lefou marked this pull request as ready for review July 14, 2023 14:01
lihaoyi added a commit that referenced this pull request Aug 15, 2023
…in BSP to avoid using the wrong evaluator (#2692)

Should fix #2643.

The basic problem is previously BSP always used the `frame(0)` evaluator
passed in to `updateEvaluator`, which is meant specifically for
evaluating user tasks in the root `./build.sc`. However, BSP also
querying of modules and tasks both in `build.sc` as well as meta-builds
in `mill-build/build.sc` and nested meta-builds. This ends up evaluating
the meta-builds in the same `out/` folder as the main build, rather than
in the `out/mill-build/` folders they should be evaluated in.

This PR avoids using the `Evaluator` given in `updateEvaluator`, and
instead preserves the `Evaluator`s we already construct as part of
`MillBuildBootstrap` in `mill.bsp.worker.State`, and passes them as a
`Seq[Evaluator]` from the enclosing `MillBuildBootstrap` code all the
way to the Mill-BSP code so we can associate each `Module` with its
respective `Ealuator`. We then use those associated `Evaluator`s to
perform the actual evaluation throughout the
`Mill{Scala,Java,Jvm,}BuildServer` implementations. There's some
additional re-shaping, so that in case a single BSP API call wants to
query modules/tasks from multiple evaluators at once we properly group
the tasks/modules together according to their respective evaluators for
evaluation.

By passing the `Seq[Evaluator]` from the enclosing `MillBuildBootstrap`,
this also lets us remove the now-redundant call to `MillBuildBootstrap`
buried within `State.scala`. We already have all the necessary data
structures from the enclosing `MillBuildBootstrap` and its evaluators,
so we don't need to re-run the bootstrap process and re-construct all of
it from scratch just for BSP

I haven't managed to reproduce the original error, so confirming the fix
will have to wait until this lands in master and people can try it out.
But I have manually tested using VSCode to load and jump around
`example/basic/1-simple-scala/` and
`example/scalabuilds/10-scala-realistic/`, and it seems all the
references and modules work and are set up correctly. So at least we
have some confidence that this doesn't cause any regressions.

This should also supersede
#2648, since we now no longer
need to re-run the `MillBuildBootstrap`/`RootModuleFinder` logic at all
since we just take the existing list of `Evaluator`s from the enclosing
bootstrap process
@lefou
Copy link
Member Author

lefou commented Aug 21, 2023

This PR is obsolete.

@lefou lefou closed this Aug 21, 2023
@lefou lefou deleted the refactor-find-root-modules branch October 16, 2023 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant