Extending the dependency syntax
Brian Smith
brianlsmith at gmail.com
Wed Aug 10 01:55:53 EDT 2005
On 8/9/05, Simon Marlow <simonmar at microsoft.com> wrote:
> ------------------
> build-depends:
> ghc? (ghc >= 6.4, [ghc64] | ghc >= 5.04, [ghc-old])
> | hugs? [hugs],
> debug?
> (HUnit-1.0, [debug])
> [release],
> gnome? ( libglade >= 2,
> gtksourceview >= 0.6,
> gconf >= 2, [gnome] ),
> mozilla? ( mozilla >= 1.4, [mozilla] ),
> doc? ( haddock >= 0.6 )
>
> [gnome]
> extra-libraries: gnome
> extra-ghc-options: -DENABLE_GNOME
> ...
>
> [debug]
> extra-ghc-options: -O0 -DDEBUG
>
> [release]
> 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
"unix"?
I think there is too much overloading being used:
1. "ghc" refers to both a flag and a package
2. "debug," "release," and "gnome," are flags and configurations.
If I pass "--enable-gnome" as a flag then the "gnome" configuration
gets used, if I pass "--enable-release" then the "release"
configuration gets used, etc.. But, if I pass "--enable-ghc64" as a
flag then the ghc64 configuration will not be used, right? Will the
"--enable-ghc64" just be silently ignored? It would be nice to be able
to catch typos like "--enable-debgu"
What is the difference between the following?:
ghc? (ghc >= 6.4, [ghc64] | ghc >= 5.04, [ghc-old])
| hugs? [hugs],
vs.
( ghc >= 6.4, [ghc64] | ghc >= 5.04, [ghc-old] | hugs, [hugs] | )
vs.
ghc >= 6.4, [ghc64] | ghc >= 5.04, [ghc-old] | hugs, [hugs]
My understanding is that the first two are equivalent but the third
one additional means "fail if building with anything other than GHC >=
5.04 or hugs," assuming that Cabal automatically enables the flags
"ghc" or "hugs" appropriately. Am I correct?
"a, b" means "require a and b." But, "a, [b]" means "require
dependency a and use configuration b" or, equivalently "if dependency
a is satisfied, then automatically use configuration b." I think it
would be better to avoid overloading the comma operator with these two
meanings.
Can configurations contain their own "Build-depends", like this?:
[windows]
Build-depends: Win32
extra-libraries: gnome
It seems counterintuitive to allow "extra-libraries" but to disallow
"build-depends." Yet, we may want to prohibit the build-depends flag
from including other configurations syntax, to prevent cycles and
non-intuitive behavior:
Build-depends: windows? [windows]
[windows]
Build-Depends: Win32, wxHaskell [gui] |
extra-libraries: gdi32
[gui]
Build-Depends: wxHaskell, (Win32 [windows] | )
I think it would be clearer to specify the configuration seperately, like this:
configuration:
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
[gnome]
Build-Depends: libglade >= 2, gtksourceview >= 0.6, gconf >= 2,
extra-libraries: gnome
extra-ghc-options: -DENABLE_GNOME
[debug]
Build-depends: HUnit-1.0
extra-ghc-options: -O0 -DDEBUG
[release]
extra-ghc-options: -O2
[mozilla]
Build-depends: mozilla >= 1.4
[doc]
Build-depends: haddock >= 0.6
Notice here that the "Build-Depends:" syntax would remain the same as
in Cabal 1.0, as [stanza] and the "?" operator would only be allowed
in "configuration:". Also notice that this requires that dependencies
be allowed as the left operand of the "?" operator, but they would no
longer be allowed as the right operand; only stanza names are allowed.
Finally, are you intending to allow multiple executable stanzas inside
configurations?:
Build-depends: wxHaskell, [gui] |
[gui]
Executable: admin-gui
Main-Is: AdminGui.hs
Executable: another-gui
Main-Is: AnotherGui.hs
Regards,
Brian
More information about the Libraries
mailing list