-
Notifications
You must be signed in to change notification settings - Fork 80
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
Build executables in stack_snapshot and use them as tools #1306
Comments
Addressing the comment in #1303 (comment)
That would work around name clashes, however, I'm not sure it's worth the complexity. With libraries and binaries in separate workspaces we would have to fetch the Cabal sources twice, which seems wasteful, and would have to generate criss-cross dependencies between these two workspaces for cases like
Sure, that would be an option. It's worth pointing out that some of these targets would have to be aliases, if we don't want to duplicate the package sources multiple times. Currently
As mentioned above, I'm not convinced that separating binaries and libraries into different workspaces doesn't introduce more problems than it solves. |
That's not the only way to do it. Assuming we have a way to determine which packages have executables (this is a problem either way, and contingent on commercialhaskell/stack#5275), then e.g.
This is again not necessarily the case I believe, because
... or exe aliases elsewhere. That looks good to me: mangled target names internally if that's what's necessary for technical reasons, and aliases to give short, memorable names to the user.
Fair enough. I think the problems that it introduces are essentially vacuous, because AFAICS these can be aliases. And the interface to the user looks quite a bit nicer to me. No mangling, which requires to learn and to remember the mangling scheme, and no unholy mix of |
Yes, with aliases we are free to expose libraries and binaries to the user under any name.
Great, #1303 is in line with that approach.
Sounds good to me. On a side-note, aliases are not without cost either. In particular, |
Is your feature request related to a problem? Please describe.
Some of the packages defined by a call to
stack_snapshot
depend on executables (tools) that themselves are Hackage packages. Examples include libraries likelanguage-c
which depends onalex
andhappy
, orgrpc-haskell-core
which depends onc2hs
. Furthermore, some packages provide executables that the user ofstack_snapshot
will likely wish to invoke directly, e.g.doctest
orghcide
.Since #907
stack_snapshot
provides thetools
attribute which allows to pass executables that are built outside ofstack_snapshot
in to be available as build tools for the packages defined bystack_snapshot
. This approach is very limited:c2hs
is such an example, it itself depends on Hackage packages likelanguage-c
, which in turn depends onalex
andhappy
. I.e. to build a package that depends onc2hs
, sayhaskell-grpc-core
we need to providealex
andhappy
, then astack_snapshot
forc2hs
dependencies, then buildc2hs
itself, and then finally astack_snapshot
forhaskell-grpc-core
and other packages. I.e. in a typical use-case we end up with external workspaces@alex
,@happy
,@c2hs_deps
,@c2hs
, and@stackage
.ghcide
has many dependencies and provides a library and an executable. If we wish to build it withstack_snapshot
we need to define astack_snapshot
exportingghcide
the library and all dependencies ofghcide
the binary, and then define a separate external workspace for theghcide
binary where we import all these dependencies. This incurs a lot of boilerplate and we have to be careful to keep the versions/revisions in sync betweenstack_snapshot
and thehttp_archive
used for thehaskell_cabal_binary
call. Alternatively, we could build both the library and binary in onehttp_archive
but then we have to manually perform the dependency resolution forghcide
.Describe the solution you'd like
I'd like
stack_snapshot
to build both library and executable components of packages and integrate them into the dependency graph as appropriate. I.e. we shouldn't have to providealex
,happy
,c2hs
, ... to thetools
attribute ofstack_snapshot
. And we shouldn't have to resort to intermediatestack_snapshot
invocations as required for tools likec2hs
.As of now
stack
does not provide us any information about the components provided by a package. And we would prefer to avoid implementing a Cabal file parser in Starlark. For that reason I'd propose to have users define the components of the packages they expect to be built, with a predefined set for common packages likealex
,happy
, .... In the end this would look something like thisDescribe alternatives you've considered
components
attribute should be user defined or inferred.stack ls dependencies json
could possibly be patched to include information on package components. However, it is unclear how much effort that would require. Also, parsing JSON into Starlark is not without issues either. As above this only addresses whethercomponents
should be user defined or inferred.Additional context
The text was updated successfully, but these errors were encountered: