-
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
stack_snapshot build executable components #1304
Conversation
@@ -845,6 +900,10 @@ def _compute_dependency_graph(repository_ctx, snapshot, core_packages, versioned | |||
is_core_package = name in _CORE_PACKAGES | |||
all_packages[name] = struct( | |||
name = name, | |||
components = _parse_components( | |||
name, | |||
remaining_components.pop(name, ["lib"]), |
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.
Why only "lib"
?
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.
That forms the default set of package components. I.e. by default we say a package only has a library component. (dict.pop(key, default=unbound)
)
🎉 All dependencies have been resolved ! |
5b59535
to
08bdfdb
Compare
Defines a separate external workspace `@stackage-exe` for a `stack_snapshot` named `@stackage` that will contain aliases pointing to the Cabal executable targets to packages in `@stackage`.
08bdfdb
to
7943a1d
Compare
7943a1d
to
07a9e1c
Compare
💔 Pull request #1303's state different from open. |
Hm, what does this message mean? |
I updated the PR message and didn't remove the "depends on" line. The PR that this one depends on has since been merged, so dpulls complains about depending on a closed PR. However, the status dpulls emits is green, so it can be ignored. |
Depends on #1303.
Adds a new attribute
components
tostack_snapshot
which allows users to specify which Cabal components to build for a given package in the snapshot (defaults to building the library component). E.g. for theproto-lens-protoc
package a user could specify the following to build both the library and executable components.This reduces the need for dedicated
http_archive
definitions for executable components of Cabal packages.The executable targets are available under labels of the form
@<snapshot>-exe//<package_name>:<exe_name>
, as discussed in #1306. For executable components that share the package's name the short form@<snapshot>-exe//<package>
applies. For technical reasons (described in #1306) these executable targets arealias
es pointing tohaskell_cabal_binary
targets of the form@<snapshot>//:_<package>_exe_<exe_name>
. These labels are considered an implementation detail and not publicly visible.The dependency graph generated by
stack
captures the library and executable dependencies of a package. When generatinghaskell_cabal_binary
targets based on declaredexe
components, we pass in all package dependencies as well as the library component (if present).The dependency graph generated by
stack
does not provide information on which components a package includes. Therefore, there is no easy way to automatically determine the set of components. However, only few packages define executable components, so it is feasible for users to manually define them as needed.A set of known executable components is included in
rules_haskell
for common packages such asalex
orhappy
.proto-lens-protoc
is converted from a dedicatedhttp_archive
to use thecomponents
attribute instead. This functions as a test-case for this feature.ghcide
is also converted from a dedicatedhttp_archive
to use thecomponents
attribute. Theghcide
use-case documentation is updated accordingly.Note, this PR does not yet inject executable components into the
tools
attribute of generated Cabal targets. E.g.alex
andhappy
still have to be passed intostack_snapshot
using thetools
attribute. This will be addressed in a follow-up PR.