configuration features #523

Closed
bos opened this Issue May 24, 2012 · 1 comment

2 participants

@bos
Haskell member

(Imported from Trac #530, reported by guest on 2009-03-22)

Currently Cabal has support for configuration flags.

This is a nice feature, but quite limited. It can only take a boolean value, and the flag must be manually set during Setup.hs configure.

Here I propose a more powerfull feature, that it is yet easy to use (and, hopefully, easy to implement).

The idea is to add support for configuration features.

A configuration feature is similar to a configuration flag, but with
some important differences.

Example

data Feature = Bool | String
A feature block:

Feature HAVE_URANDOM
action: execute
include-dirs: ...
c-sources: features/urandom.c
-- other possible properties, as listed in
-- "Build information chapter", excluding buildable and
-- other-modules
-- The action property can have values compile (default)
-- or execute
This means that I'm testing for a feature named HAVE_URANDOM, and the
testing requires to compile/build and then execute some code.

Rules

  1. If compilation fails, HAVE_URANDOM will have value Feature False.
    If action property is compile, then a successful compilation will
    result in HAVE_URANDOM having a value of Feature True.
  1. If action property is execute and the executable returns a value /= 1,
    then HAVE_URANDOM will have value Feature False.
  1. If action property is execute and executable write something on stdout,
    then HAVE_URANDOM will have value Feature string.
  1. Otherwise HAVE_URANDOM will have value Feature True.
This provides a small but useful subset of what can be obtained using autoconf, with the advantages that it is much more declarative, integrated with Cabal and portable.

@tibbe
Haskell member

Closing as there's been no activity in years.

We're cleaning up the bug tracker to make it useful again and are thus closing bugs that haven't seen any activity in a long time. Please re-open (or file a new bug) if the problem reappears.

@tibbe tibbe closed this May 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment