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 hpack command line option #3443

Merged
merged 1 commit into from
Sep 23, 2017

Conversation

scott-fleischman
Copy link
Contributor

@scott-fleischman scott-fleischman commented Sep 19, 2017

Resolves #3179.

  • Any changes that could be relevant to users have been recorded in the ChangeLog.md
  • The documentation has been updated, if necessary.

I tested it with the --with-hpack option and without, and it works as I intended. I couldn't think of a good way to test this in code, so I did not add any tests to the test suite.

Details

The core change is pretty basic.

  • I added an HpackExecutable type with two cases--one for the bundled hpack, and one with the hpack command.
  • I added HpackExecutable as a field to the GlobalOpts and BuildConfig types.
  • I used runCmd to execute the command, which requires an EnvOverride to create a Cmd value.
  • Then the remaining effort was in propagating the necessary information to the hpack function.
    • When HasEnvConfig was available, I used the hpackExecutableL lens to retrieve the HpackExecutable
    • Else I passed HpackExecutable and EnvOverride as needed as function arguments.

@mgsloan
Copy link
Contributor

mgsloan commented Sep 20, 2017

LGTM! I think it probably makes sense to also support this as a configuration option, similarly to with-gcc:. This way you can just stick it in your config.yaml to easily change hpack version globally. Do you want to add that to this PR? If not, that's fine, this looks great to me otherwise, ready to merge.

@scott-fleischman
Copy link
Contributor Author

@mgsloan I updated the PR based on your suggestion. And thanks too! That radically simplifies the code, since all code paths to hpack had HasConfig env, so I was able to avoid all of the extra argument passing. I was able to add a couple simple tests to verify that the configuration option is parsed correctly.

One question is whether it's ok that the hpack output is simply inherited. A typical run looks like:

$ stack build --with-hpack=hpack
generated testhp.cabal
testhp.cabal is up-to-date
testhp.cabal is up-to-date
testhp.cabal is up-to-date
testhp.cabal is up-to-date
testhp.cabal is up-to-date
testhp-0.1.0.0: configure (exe)
Configuring testhp-0.1.0.0...
testhp-0.1.0.0: build (exe)
Preprocessing executable 'testhp' for testhp-0.1.0.0...
testhp-0.1.0.0: copy/register
...

Also, it's surprising that the hpack function gets called 6 times as part of a stack build! And it apparently gets called twice as part of a stack clean. Is that expected?

@scott-fleischman
Copy link
Contributor Author

Ok I see that the multiple hpack invocations are addressed in #3382

@mgsloan
Copy link
Contributor

mgsloan commented Sep 23, 2017

LGTM, thanks!

@mgsloan mgsloan merged commit 93f3863 into commercialhaskell:master Sep 23, 2017
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.

2 participants