-
Notifications
You must be signed in to change notification settings - Fork 697
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
Implementation and purpose of Show-Build-Info #7489
Comments
This issue serves as a discussion point that was missing so far. cc @jneira, @emilypi, @mpickering, @fgaz, @Mikolaj and everyone else who wants to give input! |
Each technical doc you write is better than the previous one, congrats! The discover of the config file is the worse caveat of 1 and 3 i can think of. What happened if the user changes the cabal build dir? We would need just s-b-i to know where s-b-i is placed! When cabal will change the default build dir all clients will have to change as well. What about doing 1 or 3 and add a flag to the build command to output the content of the file (or at least its location) |
Another option could be let the caller decide the location of the generated file: |
I think the latter is a good, lightweight option that we can add to |
If there is no strong preference either way from the feature's users nor implementors, then an extra flag sounds less intrusive for users not interested in the feature, doesn't it? Such users just see one more line deep down in the help output and the manual (as opposed to a more prominent mention for a command). Regarding codebase intrusiveness, I guess it's similar, given that the flag needs a counterpart in cabal.project, etc. (unless it's reflected fully automatically; I don't know). How would the flag interact with |
I think the flag However, a flag such as |
So is the idea for this new flag that this is what controls the generation of buldinfo.json by |
@DanielG Yes exactly. Maybe even one step further and combine the results into one build-info.json (e.g. |
I add here an overview of the current PRs, their relation, which I care about and which need to be reviewed. They are sorted by relevance, so the first PR is the most important for this issue.
Outdated PRs:
cc @emilypi |
@fendor Tzeenshe no longer works in Haskell, and has iceboxed the project until further notice |
I'm not sure where to post this exactly, but I would greatly appreciate a sensible decomposition of the tasks that cabal performs, so that some sum of parts does in fact equal
I am not looking forward to a It seems like it would be useful to describe the possible states that a cabal project can be in with respect to the presence/absence of generated build products/metadata, and put the commands in their proper context as transitions in this state space. This way, we would at least have some specification for an initial state in which it is valid to execute |
Indeed. That's one reason why we no longer have a To be clear, the current implementation follows the third idea from the top-post for |
Not sure if it's appropriate to discuss here, but if a standalone tool calls A custom My question is, currently, is it possible to take |
Yeah, that sounds like a use-case for |
EDIT:
Final implementation
Finally the chosen implementation has been the third ("Dump build info as side effect of
Setup.hs build
") with the pr #7498Nomenclature (uses recursive name bindings)
The command
show-build-info
is intended to help tooling based on Cabal to find detailed information on how to build each component individually. It is not intended to expose Cabal details, such as what preprocessors are executed, etc... It also does not subsume Cabal's build process, i.e. having the output ofshow-build-info
does not suffice to build a cabal component in certain situations. For example it is still Cabal's task to generatePaths_*.hs
. Therefore,show-build-info
only works to compile a project, if Cabal has basically built the project, already.But then tooling such as hie-bios and hsinspect can use the output of
show-build-info
to feed them into a GHC session and provide IDE functionality.Implementation
Extracting compiler information is theoretically not a problem for cabal. Since we parse the
.cabal
file description and already solve for which dependencies to use, basically all information should be present, right? However, Cabal has been designed with extensibility in mind and achieved that by allowing developers to overwrite certain cycles of a build via custom Setup.hs hooks. These hooks are basically a way for a developer of a Cabal package to overwrite or redefine various build-steps in Cabal.This means that while
exe:cabal
knows everything about the package to build,lib:Cabal
can change compilation flags when building the project.Therefore,
exe:cabal
alone can not provide us with the low-level details on how to compile a component, as only lib:Cabal has the full build information (when usingbuild-type: Custom
). Thus,show-build-info
must be a part of lib:Cabal, as long as we have build hooks in order to generate the correct build-info reliably.For the implementation itself, we present three ideas:
Dump build info as side effect in
v2-build
Idea: Add an option to
exe:cabal
v2-build to dump the build information during the build. We would explicitly invokeSetup.hs show-build-info
from thev2-build
command.Pros:
Con:
build
will compile a component, although we might not need to (e.g. build a component of which we only need the ghc options)--only-prebuild
Issues:
plan.json
--dry-run
to the rescue! Tells you when a component needs to be rebuilt.New command,
v2-show-build-info
, which callsSetup.hs show-build-info
Idea: manually trigger the generation of build information.
Pros:
--buildinfo-project
that prints project global information (quickly).Con:
Issues:
plan.json
Dump build info as side effect of
Setup.hs build
Idea: Generate build info whenever
Cabal
builds a component and put it into the "old-style" builddir ofSetup.hs build
, i.e. next tosetup-config
.Pros:
Con:
Issues:
plan.json
--dry-run
to the rescue! Tells you when a component needs to be rebuilt.Implementation details
We can generate the build-info and write it to the
build
directory of each component (e.g.dist-newstyle/build/.../<package-name>
).After performing a
v2-build
,exe:cabal
writes outbuild-info.list
file todist-newstyle/cache
, containing the list of all build-info files which might exist, i.e. all enabled components. This file can be parsed by external tools to discover all build-infos of the project.Optionally, we can add a command
v2-ide
that does:Summary
I discussed
show-build-info
quite thoroughly with @DanielG, and we concluded that the third approach is probably the cleanest solution.Current PR: #7478 which basically implements approach 2.
The text was updated successfully, but these errors were encountered: