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

Define cabal flags #417

Closed
ryskajakub opened this issue Jun 25, 2015 · 8 comments
Closed

Define cabal flags #417

ryskajakub opened this issue Jun 25, 2015 · 8 comments

Comments

@ryskajakub
Copy link

Does stack currently support enabling flags defined in the .cabal file? There is a flag option in the stack install command, but it seems to refer to stack flags rather than to cabal flags.

I need it because I use the cabal's buildable thing to differ whether to build an executable or not, I control it by running cabal install -f myflag.

@snoyberg
Copy link
Contributor

That option is for cabal flags, and works for the build, test, and bench
commands as well.

On Thu, Jun 25, 2015, 11:00 PM Jakub Ryška notifications@github.com wrote:

Does stack currently support enabling flags defined in the .cabal file?
There is a flag option in the stack install command, but it seems to
refer to stack flags rather than to cabal flags.

I need it because I use the cabal's buildable thing to differ whether
to build an executable or not, I control it by running cabal install -f
myflag.


Reply to this email directly or view it on GitHub
#417.

@ryskajakub
Copy link
Author

I have a .cabal file having these lines (lines non-essential for description of the problem omitted):

Name: server

flag build-gen-api
  default:     False
  manual:      True

Library
  hs-source-dirs: src

Executable gen-api
  hs-source-dirs: gen-api
  if flag(build-gen-api)
    buildable: True
  else
    buildable: False

If I make changes in the gen-api project, that is in the files under directory gen-api and then try to build the project with the command stack install --flag server:build-gen-api, then it doesn't pick my changes and just copies the the executable from the last-build.

I would expect it to build a new executable or fail with compile error but it does not.

Am I running the command that should meet my expectations? If yes then it looks like a bug and I'll attach the --verbose output.

@snoyberg
Copy link
Contributor

That may be #365 affecting you. Can you run stack clean first? Alternatively, running the latest stack code from master may help.

@ryskajakub
Copy link
Author

It looks like that this is different at least I tried to do the same steps with the current master:

$ stack --version
Version 0.1.0.0, Git revision 711f2e91715ef77f01e917ca7f61db635911ef1b

but it's behaving the same. Running the stack clean beforehand helps, but I'd like to be able not to compile the entire project on every run, of course.

Will making a reproducable repo like the issue reporter in #365 did help here?

@snoyberg
Copy link
Contributor

Absolutely, that would be very helpful. Something minimal that could be tested and then added to the integration test suite to check for regression will win you 3 extra Internets.

@ryskajakub
Copy link
Author

Ok, so it was caused by not having other-modules in my executable like you suggested in #365. Therefore, it works as I want when I add it.

Some notes:

  1. cabal-install doesn't mind not having the other-modules section in the executable and still rebuilds my changes after running cabal install -f build-gen-api
  2. I actually put the the other-modules section after reading the Success return code after there were build errors #365, but into a wrong one. One clearly has to apply different mentality when dealing with .cabal than when .hs, it won't report mistakes.

@snoyberg
Copy link
Contributor

It's definitely a limitation that we can't discover the necessary modules without using other-modules. We're planning to address it with #105

@ryskajakub
Copy link
Author

Yes, that would be nice to have, especially for folks transitioning from cabal-install.

Anyway, thanks for helping!

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

No branches or pull requests

2 participants