[Hackage] #530: configuration features

Hackage trac at galois.com
Sun Mar 22 09:25:45 EDT 2009


#530: configuration features
----------------------------+-----------------------------------------------
  Reporter:  guest          |        Owner:         
      Type:  enhancement    |       Status:  new    
  Priority:  normal         |    Milestone:         
 Component:  Cabal library  |      Version:  1.6.0.1
  Severity:  normal         |     Keywords:         
Difficulty:  unknown        |   Ghcversion:         
  Platform:                 |  
----------------------------+-----------------------------------------------
 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''.

  2. If ''action'' property is ''execute'' and the executable returns a
 value /= 1,
  then ''HAVE_URANDOM'' will have value ''Feature False''.

  3. If ''action'' property is ''execute'' and executable write something
 on stdout,
  then ''HAVE_URANDOM'' will have value ''Feature string''.

  4. 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.

-- 
Ticket URL: <http://hackage.haskell.org/trac/hackage/ticket/530>
Hackage <http://haskell.org/cabal/>
Hackage: Cabal and related projects


More information about the cabal-devel mailing list