Skip to content

Specify components when configuring, not building #2802

Closed
@snoyberg

Description

@snoyberg

I'd like to share an idea and get feedback as to whether such a change would be accepted in Cabal. Currently, selection of which components to build is done as part of the build step. I know of at least three issues with this:

  • Dependencies for components we don't want to build must still be present. Consider a .cabal file with 2 executables: A has very few dependencies, and B has many dependencies. In order to build executable A, we have to provide all of the dependencies for B. (Related: dependencies are checked even if buildable is False #1725)
  • Suppose a package has a library and two executables. If you build the library and one executable and then run the copy command, it will fail since the second executable is not present (see: copy command fails when building only some components #2780)
  • If an executable relies on a library in the cabal file, there's no way to say "use the already installed version of the library, and don't rebuild the library here." This can be useful for avoiding unnecessary recompilation, especially in the presence of changing cabal_macros.h files (see: Disable library building, only build other components #2775)

My proposal: add a new command line option to the configure command, which will take a command-separated list of components to include, ignoring all other components. E.g.:

runghc Setup.hs configure --components=lib,exe:foo,test:bar,bench:baz

The semantics would be: all further commands run will implicitly filter out all non-listed components from the .cabal file.

An alternative- and possibly simpler- implementation that would be a bit hairier but still probably work would be providing a --cabal-file argument that would force Cabal to read from a given .cabal file. Then we could create temporary .cabal files with the necessary components stripped out.

Can someone comment on whether such a patch would be accepted, and give any insight into best approach to implementing if so?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions