Skip to content

Parse program options for local packages #7374

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

Closed
wants to merge 1 commit into from

Conversation

coot
Copy link
Collaborator

@coot coot commented May 1, 2021

This is a simple attempt to fix #3579

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog.
  • The documentation has been updated, if necessary.
    Documentation needs to be updated, but I'd like first see if this is an acceptable solution.

Please also shortly describe how you tested your change. Bonus points for added tests!
Manual testing by setting ghc-options in a cabal.project.local file.

'projectConfigLocalPackages' provides options for all local packages.
This patch allows to pass program options via 'PROG-options' field.
@coot
Copy link
Collaborator Author

coot commented May 1, 2021

Does cabal-testsuite require some specific setup:

cabal run cabal-testsuite:cabal-tests -- --with-cabal=$(cabal list-bin exe:cabal)   
Up to date
threads: 1
tests to run: 260
<command line>: cannot satisfy -package-id Cabal-3.5.0.0-inplace
    (use -v for more information)
GHCi exited with ExitFailure 1 (use -v for more information)
cabal-tests: fd:14: hGetLine: end of file

@emilypi
Copy link
Member

emilypi commented May 4, 2021

Thanks @coot! @fgaz or myself will be able to review this soon. I need to understand the issue first 😄

@fgaz
Copy link
Member

fgaz commented May 4, 2021

Does cabal-testsuite require some specific setup

Nope. I'm not sure why you're getting that error. The same command works for me. What OS/ghc/cabal are you using?

@fgaz
Copy link
Member

fgaz commented May 4, 2021

Oh actually if this is based on a commit preceding 6896c6a you may want to rebase: the structure of the repository is simpler now and it also affects tests (though that specific error looks unrelated)

@fgaz
Copy link
Member

fgaz commented May 4, 2021

Sounds like a good idea to have this in some form, but we should consider @dcoutts' comment first. By the way, doesn't the undocumented program-options mentioned in that issue work?

@coot
Copy link
Collaborator Author

coot commented May 5, 2021

@fgaz what's the syntax of the undocumented program-locations option?

@fgaz
Copy link
Member

fgaz commented May 5, 2021

I think you mean program-options (see #3812). The syntax is probably:

program-options
  ghc: -fsomething

or

program-options
  ghc-options: -fsomething

like in the global configuration
(and program-locations should be the same)

(just a guess, can't check if it's true right now)

@coot
Copy link
Collaborator Author

coot commented May 5, 2021

It is the latter syntax. However, it does not work for me because it applies options to all packages, but I'd like to only set ghc options for local packages without repeating it in every package stanza.

@phadej
Copy link
Collaborator

phadej commented May 6, 2021

Do i understand this right, it allows writing in cabal.project

ghc-options: -fsomething

which applies to local packages only?

However

program-options
  ghc-options: -fsomething

or

package *
  ghc-options: -fsomething

applies to every package.

This is unfortunately confusing. There should be a clear documentation section describing the difference of top-level and program-options and package *, it's confusing (and I don't think will be changed any time soon either).

EDiT: the fact program-options is not documented means that it doesn't exist. I kindly ask Cabal maintainers that if you tell something, point the link to the docs, if there is no docs, write them. (I tried to follow that practice, it's taxing, but OTOH spreading information across issues is not right either)

@phadej
Copy link
Collaborator

phadej commented May 6, 2021

Does program-options leak from cabal.config parser. Should they ever worked in cabal.project? Will this change affect cabal.config parser.

An exmaple: I find it slightly confusing that allow-newer works (or worked) in cabal.config - though it some makes sense. Setting local package settings in cabal.config also kind of make sense, but probably isn't what people expect if there isn't mention of local packages. cabal.project and cabal.config contexts are different!

@coot
Copy link
Collaborator Author

coot commented May 6, 2021

it seems that both

ghc-options: -fsomething

and

program-options
  ghc-options: -fsomething

apply to every package :/

@gbaz
Copy link
Collaborator

gbaz commented Feb 24, 2022

I believe this is superseded by #7973 ?

@coot
Copy link
Collaborator Author

coot commented Feb 25, 2022

Yes it is.

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

Successfully merging this pull request may close these issues.

Package sections in cabal.project are insufficient, need local section
6 participants