Extending the dependency syntax
simonmar at microsoft.com
Wed Aug 10 07:49:49 EDT 2005
On 10 August 2005 06:56, Brian Smith wrote:
> On 8/9/05, Simon Marlow <simonmar at microsoft.com> wrote:
>> ghc? (ghc >= 6.4, [ghc64] | ghc >= 5.04, [ghc-old])
>> | hugs? [hugs], debug?
>> (HUnit-1.0, [debug])
>> gnome? ( libglade >= 2,
>> gtksourceview >= 0.6,
>> gconf >= 2, [gnome] ),
>> mozilla? ( mozilla >= 1.4, [mozilla] ),
>> doc? ( haddock >= 0.6 )
>> extra-libraries: gnome
>> extra-ghc-options: -DENABLE_GNOME
>> extra-ghc-options: -O0 -DDEBUG
>> extra-ghc-options: -O2
> As described, it seems like I would need to pass "--enable-hugs" or
> "--enable-ghc" explicitly, or else this program's build would fail.
> But, I don't think that is your intention; instead you are intending
> for Cabal to automatically enable these flags as appropriate, right?
> Perhaps there would be other automatic flags too, like "windows" and
Actually I made a mistake in the above example, I meant to write
ghc? (ghc >= 6.4, [ghc64] | ghc >= 5.04, [ghc-old])
but anyway, this syntax has caught several people out, me included, so
we should pick something better (again). It seems that most people
would be happier if
x? (a) | b
means b if x is false. I think we can fix it, though. How about this
deps ::= choice
| choice ',' deps
choice ::= alt1 '|' ... '|' altN (n >= 1)
alt ::= adep '?' adep
adep ::= pkg version-range
| '(' deps ')'
The point is that now a disjunction is always of the form (x1?(a1) |
... | xn?(an)), and the meaning is that we take the leftmost branch for
which x is true. It's a case statement.
Also, to avoid some of the overloading you pointed out, I'm writing
flags as --enable-flag.
The example in this syntax:
ghc>=6.4 ? [ghc64] |
ghc>=5.04 ? [ghc-old])
| --enable-hugs? [hugs]
| true ? true, -- other compilers are allowed
--enable-debug? (HUnit-1.0, [debug]) | true? [release]
libglade >= 2,
gtksourceview >= 0.6,
gconf >= 2, [gnome] ),
--enable-mozilla? ( mozilla >= 1.4, [mozilla] ),
--enable-doc? ( haddock >= 0.6 )
I'm not wildly excited about "true ? true", but we could add special
syntax for that if it turns out to be used often.
> Can configurations contain their own "Build-depends", like this?:
> Build-depends: Win32
> extra-libraries: gnome
The problem I have with this is that it means you can only decide
dependencies based on the settings of flags, rather than the other way
around. We use both in the above example - [ghc64] is decided based on
the availability of ghc versions, whereas [mozilla] is chosen based on a
configuration flag. You had to hack it in your example:
> I think it would be clearer to specify the configuration seperately,
> like this:
> ghc >= 6.4 ? [ghc64] | ghc >= 5.04 ? [ghc-old]) | hugs?
> [hugs], debug enabled ? [debug] | [release],
> gnome enabled ? [gnome],
> mozilla enabled ? [mozilla],
> doc enabled ? [doc]
> -- the "global" Build-depends applies to everything
> Build-depends: base >= 1.0, haskell98 >= 1.0
So configuration contains dependencies like ghc >= 6.4. I think it's
clearer to put all the dependencies in one place.
> Finally, are you intending to allow multiple executable stanzas inside
I've been avoiding this issue for now. I believe we need to completely
redesign the way multiple executables are handled, and provide a more
general framework for a package that contains multiple libraries &
executables (essentially a wrapper for multiple packages with
interdependencies). I know Isaac is thinking about this too. Let's
deal with one issue at a time.
More information about the Libraries