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

Support build-depends: injection from cabal.project #9733

Open
lawcho opened this issue Feb 22, 2024 · 1 comment
Open

Support build-depends: injection from cabal.project #9733

lawcho opened this issue Feb 22, 2024 · 1 comment

Comments

@lawcho
Copy link

lawcho commented Feb 22, 2024

Proposal

Support the build-depends: field in a cabal.project file.

For example, this cabal.project file:

package *
  build-depends: ghc-tags-plugin
  ghc-options:
    -plugin-package=ghc-tags-plugin
    -fplugin=Plugin.GhcTags

would tell cabal build to build every component as if ghc-tags-plugin had been added to its build-depends:.

Motivation

I'm looking for a user-friendly way to run global GHC plugins 1 with Cabal.

Currently, users of ghc-tags-plugin are asked to:

  1. cabal install --lib ghc-tags-plugin
  2. Find out where their package-db is
    (for me it was /home/lawrence/.local/state/cabal/store/ghc-9.4.8/package.db/)
  3. Write a cabal.project similar to:
    package *
      ghc-options:
        -package-db=/home/lawrence/.local/state/cabal/store/ghc-9.4.8/package.db/
        -plugin-package=ghc-tags-plugin
        -fplugin=Plugin.GhcTags
  4. cabal build

Related Issues

If #7901 is implemented, cabal.project would only need to contain:

package *
  plugin-depends: ghc-tags-plugin

And no cabal install --lib call would be required.

Unfortunately, a full implementation of #7901 'will be messy': #7901 (comment).

This feature might be easier to implement that #7901, because:

  • Cabal already supports build-depends: in .cabal files
  • No GHC-specific details need to be considered (build-depends: is compiler-agnositc)
  • No plugin-specific details need to be considered (build-depends: works with any library)

Footnotes

  1. A GHC plugin is global if it needs to run on all transitive dependencies of a package. (e.g. cabal-audit, ghc-tags-plugin, ghc-wpc)

@gbaz
Copy link
Collaborator

gbaz commented Mar 8, 2024

I commented on the other issue, as the initial version of that is the same as this, except with plugin-depends instead of build-depends used in cabal project files. I prefer that, because I think build-depends should be what a package knows it depends on, and not be injectable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants