Skip to content

New build-tool-depends goals to complement build-tools #3708

@hvr

Description

@hvr

When you write build-tools: alex, Cabal checks that an executable of this name is installed. It is jointly the responsibility of the package manager, e.g., cabal-install, to arrange for an executable named alex to be installed.

In a recent commit (c0a4860) we added a special case in cabal-install to handle "well known" build-tools like alex and happy, building and installing them automatically when they are requested in build-tools. However, there remains a more general problem of letting users ask for an executable, which is known to live in a particular package. build-tools as currently specified cannot really handle this, because it is specified to only specify executable names (not package names.) So it seems we really need a new field to give this information. Here is the proposal:

  • We introduce a new tool-depends field, which consists of pkg:exename version-constraints specifications, e.g., tool-depends: gtk2hs-buildtools:gtk2hs2hs < 2.0. This means that we must build the gtk2hsc2hs executable from gtk2hs-buildtools before building this package. In principle cabal-install need only build the gtk2hsc2hs executable, although it's also permissible to just build all the executables in the package (if, e.g., the Setup script doesn't support per-component Cabal <https://github.com/ezyang/ghc-proposals/blob/master/proposals/0000-componentized-cabal.rst>_). If qualification is omitted it is assumed that you need ALL executables from the package.
  • build-tools refers exclusively to non-packaged executables, e.g. provided by the system. However, for backwards compatibility, we introduce an internal mapping hard-coded into cabal-install which maps some build-tools fields to package names. The intended interpretation is that build-tools: happy > 0.4 actually elaborates to tool-depends: happy:happy > 0.4. This mapping will be configurable using the build-tool-packages field in a cabal-project and also modifiable by command line argument. (Names can be bikeshedded of course.)

Examples:

  • tool-depends: mytoolpkg: cabal-install will install all executables defined by a package named mytoolpkg, and ensure they are available prior to building this package.
  • tool-depends: mytoolpkg:mytool: cabal-install will install the executable mytool from mytoolpkg before building this package
  • build-tools: happy: this is equivalent to writing tool-depends: happy:happy.
  • build-tools: someprog: as before this does not effect solver behavior; there just simply needs to be a someprog in the path.

Note: this was originally conceived by @ezyang as part of #220 (which has been addressed); however, since this represents an extension of the .cabal format and hasn't yet been implemented it's been split out into its own issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions