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

Add --build-ghc-options flag for stack ghci (#971) #979

Closed
wants to merge 3 commits into from

Conversation

chrisdone
Copy link
Member

@bergmark

Now with --build-ghc-options you can retain the build flags:

bash-3.2$ stack build --test --ghc-options="-Wall -Werror"
stack-0.1.4.1: unregistering (components added: test:stack-test)
stack-0.1.4.1: configure
Configuring stack-0.1.4.1...
stack-0.1.4.1: build
[...]
Completed all 2 actions.
bash-3.2$ stack ghci --build-ghc-options="-Wall -Werror"
* * * * * * * *
The main module to load is ambiguous. Candidates are: 
Package `stack' component exe:stack with main-is file: /Users/chris/Work/stack/src/main/Main.hs
Package `stack' component test:stack-integration-test with main-is file: /Users/chris/Work/stack/test/integration/IntegrationSpec.hs
Package `stack' component test:stack-test with main-is file: /Users/chris/Work/stack/src/test/Test.hs
None will be loaded. You can specify which one to pick by: 
 1) Specifying targets to stack ghci e.g. stack ghci stack:exe:stack
 2) Specifying what the main is e.g. stack ghci --main-is stack:exe:stack
* * * * * * * *
Configuring GHCi with the following packages: stack
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
unknown option: 'c'
[...]
*Control.Concurrent.Execute> :q
Leaving GHCi.
bash-3.2$ 

Also added a --pedantic arg:

bash-3.2$ stack build --test --pedantic
stack-0.1.4.1: unregistering (components added: test:stack-test)
stack-0.1.4.1: configure
Configuring stack-0.1.4.1...
stack-0.1.4.1: build
Preprocessing library stack-0.1.4.1...
[..]
Completed all 2 actions.
bash-3.2$ stack ghci --pedantic
* * * * * * * *
The main module to load is ambiguous. Candidates are: 
Package `stack' component exe:stack with main-is file: /Users/chris/Work/stack/src/main/Main.hs
Package `stack' component test:stack-integration-test with main-is file: /Users/chris/Work/stack/test/integration/IntegrationSpec.hs
Package `stack' component test:stack-test with main-is file: /Users/chris/Work/stack/src/test/Test.hs
None will be loaded. You can specify which one to pick by: 
 1) Specifying targets to stack ghci e.g. stack ghci stack:exe:stack
 2) Specifying what the main is e.g. stack ghci --main-is stack:exe:stack
* * * * * * * *
Configuring GHCi with the following packages: stack
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
unknown option: 'c'
[...]
*Control.Concurrent.Execute> :q
Leaving GHCi.
bash-3.2$ 

If this sounds good I'll merge the redundant parts.

@bergmark
Copy link
Member

I tried this branch but I don't see the --build-ghc-options flag:

$ stack --version
Version 0.1.4.1, Git revision ac59fd035fa87f5dc1dab4e27bc740fb5486b40b (1826 commits) X86_64
$ stack ghci --build-ghc-options='-Wall -Werror' silk-event
Usage: stack ghci [TARGET] [--ghc-options OPTION] [--pedantic]
                  [--ghc-options OPTION] [--with-ghc GHC] [--no-load]
                  [--package ARG] [--main-is TARGET]
  Run ghci in the context of project(s) (experimental)

@chrisdone
Copy link
Member Author

Ah, looks like I regressed the argument name in ac59fd0. Pushed a fix.

@snoyberg
Copy link
Contributor

@chrisdone Is this blocked on feedback from @bergmark?

@bergmark
Copy link
Member

I tested it again now, thanks for the reminder.

I can't get this to work in a useful way for me, probably because of #743

* stack build --pedantic
<< Ooops my crappy package has warnings >>>
* stack ghci --build-ghc-options='-Wall -Werror' --pedantic my-crappy-package
generic-aeson-0.2.0.7: unregistering (flags changed from ["--ghc-options","-Wall","--ghc-options","-Werror"] to [])

(There also isn't a --dry-run for stack ghci by the way, it immediately unregister packages.)

So afaict there are these ways to handle the problem currently:

  • If the project is small: Use stack build and stack ghci to work on overything at once
  • Build one package at a time with stack ghci --pedantic foo (with flags) and install one by one using stack build foo (without flags). I'm not sure if there's a good way to know which package to install next while doing this
  • Use stack build w/o package names or flags, and use ghci freely

I suppose what I want is a project-global configuration on what flags to use for packages.

@borsboom
Copy link
Contributor

@chrisdone: is this PR still active?

@mgsloan
Copy link
Contributor

mgsloan commented Oct 29, 2015

Also worth considering how this relates to #1186

@mgsloan
Copy link
Contributor

mgsloan commented Dec 3, 2015

This is now available as --ghc-options, which get passed to both the build and ghci. GHCI specific options are passed via --ghci-options.

@mgsloan mgsloan closed this Dec 3, 2015
@mihaimaruseac mihaimaruseac deleted the 971-build-ghc-options branch July 30, 2018 13:44
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.

5 participants