Implement `--{enable,disable}-executables`
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
This may have been subsumed by other tickets (e.g. #4087) but I figured it may be worth sketching a more modest enhancement which "completes" cabal's UI (scroll down for rationale):
## What?
We already have the ability to enable/disable tests and benchmark, via
```
--enable-tests Enable dependency checking and compilation
for test suites listed in the package
description file.
--disable-tests Disable dependency checking and
compilation for test suites listed in the
package description file.
--enable-benchmarks Enable dependency checking and compilation
for benchmarks listed in the package
description file.
--disable-benchmarks Disable dependency checking and
compilation for benchmarks listed in the
package description file.
```
which translates to `cabal.project` files as
```
tests: True
benchmarks: False
package bar
tests: False
benchmarks: True
```
as well as the [`--constraint` syntax](http://cabal.readthedocs.io/en/latest/installing-packages.html#cmdoption-setup-configure-constraint) to force the solver to enable tests/benchmarks
```
--constraint="bar bench"
--constraint="bar test"
```
(but I'm not sure this works properly in new-build btw; also I'm missing a `no-bench`/`no-test` token for symmetry)
What I'm suggesting now is to extend this logic to executable components, i.e.
```
--enable-executables Enable dependency checking and compilation
for executables listed in the package
description file.
--disable-executables Disable dependency checking and
compilation for executables listed in the
package description file.
```
and
```
--constraint="bar exe"
--constraint="bar no-exe"
```
as well as the respective `executables: ` property for `cabal.project` files
The default settings would be:
- executables are enabled by default for local packages (i.e. those specified via `packages: ...`)
- executables are obviously enabled by default where they're needed to satisfy build-tool-depends goals
- else, executables are disabled by default (e.g. when only the library of a package is requested via `build-depends`
## Why?
Finally, the rationale for this feature request (beyond improving symmetry of executables w/ tests & benchmark) is the situation that you have packages which bundle libraries + executables to form the unit of distribution. This has become more attractive with `new-build`'s per-component building, where you can depend on the library part of a package w/o cabal building all the executables (& their deps) as well.
However, cabal currently still has to solve for all executables even if all you ever need is the library component.
The library may often have a smaller dependency footprint and would therefore puts less pressure on the constraint solver.
However, the executables often have additional library dependencies, like e.g. `optparse-applicative` or even heavier dependencies (http libraries, GUI toolkits, terminal UI toolkits, etc).
So having to satisfy the executable's constraints provides no benefit for `build-depends` dependencies, and can instead result in the cabal solver not finding a solution, even though there would be if executables' constraints would have been ignored.
Contributor guide
Assessment
This issue has not been assessed yet.