- 
                Notifications
    You must be signed in to change notification settings 
- Fork 87
cabal: Add support for empty libraries #2355
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
base: master
Are you sure you want to change the base?
Conversation
Drop the check for `libraries != []` in the check for processing the package config file. Haskell supports empty libraries. In order for Bazel to support them, we need to process the package config, even for empty libraries.
| This has the test you asked for. I'm not done going through the other comments. | 
53fd56a    to
    4cd04b6      
    Compare
  
    | 
 
 
 I'm not sure we can. For the majority of cases, we want to use the same label, which means that we can't invert the dictionary. I'll add the TODO. | 
| 
 Moved as requested, and the references in the codebase have been updated. | 
Rather than continually proliferate additional settings on haskell_cabal_library, create a rule and provider that can hold cabal specific settings. Add `empty_lib` as the first such setting. When building an empty lib, bazel will look for the package file, instead of for any object files. This will fix several packages that are currently blacklisted. It will also allow the use of packages with sublibraries and an empty main lib. Currently there is no way to use this with a stack snapshot, short of vendoring a package and adding a `haskell_cabal_args` to the vendored build file. A simpler way is planned.
Empty haskell libraries have been a longstanding problem. Add support for an additional component type `empty_lib`, which is like `lib`, except that an additional `haskell_cabal_args` target will be created for the library, instructing Bazel not to look for any object files. Remove the longstanding package blacklist for empty packages. Replace it with the now possible correct entries for those libraries, indicating that the main library is empty.
It can occur that a module has a source file named "Setup.hs" that isn't a cabal setup module. The current setup finder will find such a module and then setup will break. Add a flag to cabal_args to indicate that any such module should be ignored.
Modules require a facade for stack_snapshot. Push components_args through the facade and back into the main implementation.
4cd04b6    to
    8f4d948      
    Compare
  
    | @avdv That was all of the comments on the previous PR resolved, with the exception of not using a label keyed string dict. I also found an issue from CI with profiling and an empty haskell_cabal_library. The issue is fixed. | 
| The one failure appears to be due to a transient network issue with hackage. I would re-run just that job, but I can't do that myself. | 
Migrated from this PR #2287 see there for additional history.
Original description below:
Previously, an empty library that only exported modules from another library failed to build. Bazel would error out when the .a file wasn't created. These libraries are becoming more common in the Haskell ecosystem, so we need to support them.
There is a straightforward way to handle these libraries. We make the package database the default output. We avoid creating an output file for any libraries if the library is marked as empty. This is all straightforward bazel dependency/output management.
Adjust the cabal wrapper to fix up the package database even in the case that there is no library. Otherwise we end up with an empty package database, which isn't what we're looking for.