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

Simplify and rationalize provider model #852

Merged
merged 14 commits into from
Apr 30, 2019
Merged

Simplify and rationalize provider model #852

merged 14 commits into from
Apr 30, 2019

Conversation

mboes
Copy link
Member

@mboes mboes commented Apr 27, 2019

Depends on #844.

We used to have the following main providers:

  • HaskellBuildInfo exposing information common to both binaries and
    libraries,
  • HaskellBinaryInfo exposing information specific to binaries,
  • HaskellLibraryInfo exposing information specific to libraries.

We now have:

  • HaskellInfo, a generic provider returned by all core Haskell
    rules.
  • HaskellLibraryInfo, returned only by haskell_library.

Most of the provider attributes are now in HaskellInfo (though
several have been removed entirely). A library is something that
additionally has an identifier and a version number, that's it.

It's best to review this commit by commit, but for each commit, first
look at the changes in haskell/providers.bzl. All other changes in
the commit are a direct consequence of any changes in that first file.

@mboes mboes requested a review from aherrmann April 27, 2019 12:34
Copy link
Contributor

@Profpatsch Profpatsch left a comment

Choose a reason for hiding this comment

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

Great cleanup.

haskell/cc.bzl Outdated
@@ -312,8 +305,8 @@ cc_haskell_import = rule(
attrs = {
"dep": attr.label(
doc = """
Target providing a `HaskellLibraryInfo` or `HaskellBinaryInfo`, such as
`haskell_library` or `haskell_binary`.
Target providing a `HaskellLiInfo` such as `haskell_library` or
Copy link
Contributor

Choose a reason for hiding this comment

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

HaskellLiInfo

haskell/haddock.bzl Show resolved Hide resolved
Copy link
Member

@aherrmann aherrmann left a comment

Choose a reason for hiding this comment

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

Nice! Looks much better.

Also checked that it doesn't break our use-site.

@mboes
Copy link
Member Author

mboes commented Apr 29, 2019

@aherrmann this branch interacts badly with #847 in ways that I don't understand. Could you have a look?

@aherrmann
Copy link
Member

@mboes Sure, I'll have a look.

@aherrmann
Copy link
Member

I've rebased this PR on master. I had to change the version macros generation because it was relying on the headers attribute of the HaskellLibrary provider. See commit message for details.

mboes and others added 14 commits April 30, 2019 17:52
We will in future commits merge `HaskellBinaryInfo` and
`HaskellLibrary` into `HaskellBuildInfo`, which at that point will
become the one-stop shop generic provider for Haskell, much like
`JavaInfo` and `CcInfo`. So it makes sense to follow the same naming
scheme.
They are not read by the compiler, only the .cache files are.
We rename package_caches to package_databases. Cache files are an
implementation detail.
import_dirs are common to HaskellLibraryInfo and HaskellBinary. Move
it up to HaskellInfo.
This field was common to HaskellLibraryInfo and HaskellBinaryInfo.
Only `haskell_library` returned `CcInfo` previously. Now
`haskell_binary` and `haskell_protobuf_library` do so too - at least
by forwarding the CcInfos that were given to them.
As a side effect of this, we no longer export headers, which by
default should be considered private. There is no mechanism to export
headers now, though we could add a `hdrs` attribute like `cc_library`
has.
…lags internally

This is to be consistent with cc_common API.
It has no fields by now, so conveys no useful information.
Before, the version_macros header file was forwarded in the
HaskellLibrary.header_files attribute, which contained the
cc_interop_info.hdrs attribute, which contained the version_macros
header.

HaskellLibrary.header_files was effectively replaced by CcInfo. However,
CcInfo tracks the full transitive closure of dependencies, whereas we
only want to include the version_macros header files of direct
dependencies. (Some packages treat the presence of version macros as
indication that the package is a direct dependency. This can cause
missing module errors).

This commit changes the handling of version macro headers to not forward
them in cc_interop_info, but instead explicitly collect them for the
preprocessors c2hs and hsc2hs which require them. It also only forwards
those headers if the target itself defines the version attribute.
@mboes mboes merged commit 6c550c8 into master Apr 30, 2019
@mboes mboes deleted the providers-collapse branch April 30, 2019 17:06
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.

3 participants