-
Notifications
You must be signed in to change notification settings - Fork 701
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
Add show-build-info command #2771
Conversation
Bringing in @edsko, who provided the motivation for this feature. |
At the moment I think it is fair to say that this is a bit rough still. For instance, note the fact that |
I guess that this needs a corresponding user guide update? And please also update the changelog. Code looks OK on a first glance. May be worth making /cc @dcoutts |
Yes, absolutely. Really I would first like to get some feedback from other tooling authors. I know what I need but others may want information beyond what I provide here. /cc @alanz @kazu-yamamoto |
@bgamari There's also a Travis failure. |
maybeWithSandboxDirOnSearchPath useSandbox $ | ||
showBuildInfo verbosity config distPref buildFlags extraArgs | ||
|
||
-- | Actually do the work of building the package. This is separate from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was probably copied from somewhere else and needs to be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, thanks for catching that.
Except for the comment and the Travis failure, LGTM. |
This allows users to get a JSON representation of various information about how Cabal would go about building a package. The output of this command is intended for external tools and therefore the format should remain stable.
Brining in @GanielG as well. |
Who's @GanielG? :P I fully support this in theory but just getting the complete set of renered GHC options turned out not to be sufficient for ghc-mod. I had to extract various subsets of options too: https://github.com/DanielG/cabal-helper/blob/master/CabalHelper/Main.hs#L95 |
Oh dear, it's apparently still early in the morning. Indeed you do scrape a lot out of Cabal. My original goal was to avoid reimplementing a JSON representation of the Cabal API and instead just focus on those cases which are complicated by linking considerations (e.g. user installs That was merely my original idea, however, and I'm not opposed to adding more surface area to the interface so long as we can do so in a way that is unlikely to pose compatibility issues going forward. Could you offer some more details on precisely what subsets of flags are needed and why? My understanding is that there are a few classes of options that should be reasonably easy to isolate,
To get any more specific then this begins to wear away at Cabal's (perhaps not unnecessary) compiler independence. I'm not sure whether we want to enter this territory (@23Skidoo, thoughts?). |
Yes yes yes. +1. |
@chrisdone / @mgsloan I don't know if you guys still read the cabal data in |
The other commands should be obvious. |
@bgamari I think this PR can go in since it's low-risk and marked as unstable anyway. Do you want me to merge it in the current form or do you think it still needs more work? |
I would still like to see the subsets of options added to the interface before this gets merged. Otherwise I'd not be able to use it in ghc-mod which would be a pitty. It would also be nice if I could more or less implement all the stuff in I might be able to find some time to work on this unless @bgamari wants to do it. But my schedule is pretty packed so I'm not sure when that would be. |
where | ||
go [] = id | ||
go [x] = x | ||
go (x:xs) = x . showString sep . go xs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Just a casual observer, not a contributor) I assume the intention is to avoid adding another dependency to Cabal, but this still feels like a candidate for a separate library, even if it is a small library that is a minimal subset of Aeson... cabal-aeson-lite or something. I am sure others have already thought this through though..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kanishka-azimi This part of the patch is actually going to vanish anyway, since we already have a aeson-ish mini library in cabal-install
(which generates plan.json
). But more generally, there is IMO no point to release a small trivial mini-aeson library unless somebody other than cabal wants to actually use it. But I don't see this happening, as aeson
is so ubiquitous that virtually everyone just uses aeson
if they need JSON capabilities. Last but not least, there's a significant cost involved in maintaining a library on Hackage in a responsible manner (writing proper documentation, testing, keeping it working with updated dependencies and compilers, being careful about API breakges, reacting to feature requests and bug reports etc.).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I wrote that comment I ended up releasing an extended version of my llightweight JSON library as https://hackage.haskell.org/package/microaeson as I ended up needing a dependency-minimal JSON library...
In any case, this PR ought to get rid of the redundant JSON impl in favor of the one we're using already for plan.json
.
@robinp BTW, you might be interesting in reviving this PR for haskell-indexer. The idea here is to add an easier way to integrate "processors" with Cabal, so that new ones could be added with zero/minimal changes to Cabal code. |
@23Skidoo thank you, will consider. For now a GHC frontend plugin might work, but for long-term when we need to capture the precise inputs (for later compilation) this looks required. |
So, essentially the only thing blocking this from being merged is the option subsets DanielG's described? |
what's the status on this? |
Stalled. Someone needs to take action to revive it. |
FWIW I've forked @bgamari's commit and updated it against cabal master, over here. @DanielG could you please explain the options subsets bit? Is it the equivalent of There is now the additional complication of having this work against new-build however, at this point I'm well out of my depth. I've added the scaffolding for it, and will work on figuring it out. Could take a while though. |
@cfraz89 I've finally found some time to work on new-build support for my packages and |
What is the status of this? If reasonable, @fendor and me could pick up at the current state during the next Could someone familiar with this issue list a roadmap of next steps required for completing this PR? |
Can we please rebase and merge this? Any future changes can be made incrementally. |
OK with me, if it's clearly marked as unstable/experimental. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove redundant JSON implementation
where | ||
go [] = id | ||
go [x] = x | ||
go (x:xs) = x . showString sep . go xs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I wrote that comment I ended up releasing an extended version of my llightweight JSON library as https://hackage.haskell.org/package/microaeson as I ended up needing a dependency-minimal JSON library...
In any case, this PR ought to get rid of the redundant JSON impl in favor of the one we're using already for plan.json
.
Interaction with Cabal poses a few challenges to third-party tooling authors,
cabal-install
, which currently has no publicly accessible programmatic interfacescabal-install
in the presence of upgradesWhile (1) can be addressed with library support easing common use-casese (see, for instance, https://github.com/bgamari/cabal-ghc-dynflags), (2) and (3) pose severe impediments to tooling development. This patch seeks to address this by removing the need to link against
Cabal
to retrieve build information. It does this by introducing theshow-build-info
command, which produces a small JSON document describing the compiler arguments Cabal would use to build the various components of the package. For instance,The goal here is not to replace the
Cabal
library as the primary means of querying package information. Rather, this command is supposed to target the narrow but important use-case of querying for build information, only providing enough information to allow a third-party tool to reconstruct the compiler configuration and relevant modules without having to link againstCabal
. The format is small with the goal of making it relatively easy to ensure compatibility going forwards.