commercialhaskell / commercialhaskell/stack

Per-package extra-include-dirs / extra-lib-dirs + boilerplate reduction in flags / ghc-options

Open
#2,626 0 comments 5 reactions 0 assignees View on GitHub
component: build type: enhancement
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

Adam Bergmark posted the following email to the haskell-stack mailing list:

> Hi,
>
> I'm struck by https://github.com/phonohawk/HsOpenSSL/issues/41 where one solution is to specify extra-include-dirs and extra-lib-dirs to use when compiling HsOpenSSL.
>
> One way is to add these to the stack.yaml's of all projects that use HsOpenSSL along with ~/.stack/global-project/stack.yaml. This could be added to the stack.yaml template but for shared stack.yaml's this is cruft for non-OS X users.
>
> Another way is to set this globally in ~/.stack/config.yaml. The disadvantage here is that this flag is set for local packages _and_ extra-deps, so when building unrelated things I get recompiles along these lines: "haskell-src-exts-1.18.2: unregistering (flags changed from [] to ["--extra-include-dirs=/usr/local/opt/openssl/include","--extra-lib-dirs=/usr/local/opt/openssl/lib"])".
>
> Optimally I would be able to specify this globally in ~/.stack/config.yaml but only have it apply to HsOpenSSL.
>
> As far as I can see this is not possible at the moment. Has it been discussed? Do you think it's a good idea?
>
> Regards,
> Adam

I think this is a great idea, and so making an issue about it. I think the configuration format should be extended to look like this:

```
extra-lib-dirs:
- for: [HsOpenSSL]
use: [/usr/local/opt/openssl/include]
extra-include-dirs:
- for: [HsOpenSSL]
use: [/usr/local/opt/openssl/lib]
```

In other words, you specify a set of package names which should have the .

One ugliness of this is that it is a deviation from the convention used by `flags` and `ghc-options`. I think that is OK, because the nature of this option is different. Perhaps those should also support this new format? If a bunch of packages share the same flag name or want the same ghc-options, this could reduce boilerplate. So, I'm imagining that ghc-options will also support:

```
ghc-options:
- for: [HsOpenSSL]
use: -O2
```

Seem good? I like it a lot!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.