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

stack_snapshot use executable components in tools attribute #1305

Merged
merged 6 commits into from
Jun 10, 2020

Conversation

aherrmann
Copy link
Member

@aherrmann aherrmann commented Apr 20, 2020

Closes #1306

Uses executable components of package dependencies in the tools attribute in Cabal targets generated by stack_snapshot. E.g. we no longer need to build alex and happy outside of stack_snapshot to then pass them in via stack_snapshot's tools attribute. Instead, stack_snapshot will generate targets @stackage-exe//alex and @stackage-exe//happy and pass them into the tools attribute of any generated haskell_cabal_* target that depends on alex or happy respectively.

A use-case where this becomes very useful is the tool c2hs. Contrary to alex or happy it does itself depend on Hackage packages, e.g. language-c. Meaning, if someone wants to include a package that depends on c2hs in a stack_snapshot call, say grpc-haskell-core, then one has to first build c2hs separately. To achieve that one has to define a separate stack_snapshot for the dependencies of c2hs. This approach does not scale very well. With this PR the issue is avoided, as stack_snapshot will generate @stackage-exe//c2hs itself and pass it to grpc-haskell-core automatically.

The tools attribute to stack_snapshot is still available in case users do wish to provide external tools, e.g. a Nix provided alex binary. We keep an externally provided alex in rules_haskell's stack_snapshot as a test-case for this.

This also simplifies the start script, as it is no longer a common use-case to have to provide an externally built tool.

@aherrmann
Copy link
Member Author

Tested on the daml repository, see digital-asset/daml@04f38dc.

@aherrmann aherrmann force-pushed the stack-components branch 3 times, most recently from 7943a1d to 07a9e1c Compare June 5, 2020 08:39
Base automatically changed from stack-components to master June 5, 2020 12:48
@aherrmann aherrmann marked this pull request as ready for review June 5, 2020 14:21
@aherrmann aherrmann requested a review from guibou June 5, 2020 14:32
Copy link
Member

@mboes mboes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine, but I don't see in the PR where these executables are being called. What does their label look like?

@aherrmann
Copy link
Member Author

This looks fine, but I don't see in the PR where these executables are being called. What does their label look like?

The user facing labels are the ones generated by #1304, e.g. @stackage-exe//alex. These user facing labels are only generated for packages that are listed in the packages attribute. I.e. binaries of private packages are not exposed. Within stack_snapshot itself tools are referenced by this code using the internal labels of the form @stackage//:_alex_exe_alex. This is so that dependencies on executables of private packages work as well. These labels are not user facing.

@aherrmann aherrmann added the merge-queue merge on green CI label Jun 10, 2020
stack_snapshot now builds alex automatically as needed
This allows to distinguish library and tool dependencies in the
generated packages.bzl file. Otherwise, users of that file will
encounter errors when a package exports an executable component but not
a library component.
@mergify mergify bot merged commit 182995f into master Jun 10, 2020
@mergify mergify bot deleted the stack-tools-auto branch June 10, 2020 09:09
@mergify mergify bot removed the merge-queue merge on green CI label Jun 10, 2020
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.

Build executables in stack_snapshot and use them as tools
2 participants