issues with configurations

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Thu Aug 10 17:51:46 EDT 2006


On Thu, 2006-08-10 at 22:13 +0100, Duncan Coutts wrote:

> So, with this in mind, can we come up with a syntax & semantics that is
> close to our current configurations proposals but is not evil?

One thing that might help is if we split the 'package' condional test
into two distinct things.

I think we're using it for different purposes which correspond roughly
to Gentoo's "dep || dep" xor dep syntax and it's "flag? dep" syntax. In
one case it's an inconsequential decision to pick one dep, we use the
other when the user might legitimately want to control if the dependency
is used.

So perhaps we could have 'package'(dependecy) and 'use'(dependency).
I'll try and explain what both mean.

'package' conditionals would be for selecting things depending on which
version of a package we depend on ends up getting used.

'use' conditionals would be for selecting optional dependencies from the
environment. These would get corresponding --enable-foo --disable-foo
configure flags, though would default depending on the presence of the
package.

So, examples:

-- if the base package is <2.0, depend on fps:

build-depends: base

configuration: package(base < 2.0)
build-depends: fps>=1.0
ghc-options: -DUSE_OLD_FPS

-- optional gui
build-depends: base

configuration: use(gtk) && use(cairo)
build-depends: gtk, cairo
ghc-options: -DUSE_GUI


I'm not sure that's ideal when we need to depend on multiple optional
packages. Maybe something like this'd be nicer

flag: debug
default: False

flag: gui
default: use(gtk >= 0.9.10) && use(cabal >= 0.9.10)

configuration: flag(gui)
build-depends: gtk, cairo
ghc-options: -DUSE_GUI

configuration: flag(debug)
ghc-options: -DDEBUG -O0

configuration: !flag(debug)
ghc-options: -O2 -funbox-strict-fields


So we have a flag with a reasonable default value but all flags can be
manually overridden.

I'm  still concerned that the order of configurations is significant:

build-depends: base

flag: debug
default: False

configuration: flag(debug)
build-depends: HUnit>=1.0

configuration: package(HUnit>=1.1)
ghc-options: -DBlah


Since we do not know which packages we're depending on 'til we've dealt
with the first configuration. So looking at them in a different order
would give different results. Perhaps we just live with it and say that
they get done in order.

There's still the possibility that we put all build-depends upfront:

flag: debug
default: False

build-depends: base, flag(debug)? ( HUnit>=1.0 )

configuration: package(HUnit>=1.1)
ghc-options: -DBlah


So I think I'm suggesting that we explicitly specify flags and give them
default values which may be based on the environment.

Then deps are specified in terms of those flags, and os/arch.

Then configurations can be conditional on flags, os/arch, and versions
of packages that we're actually going to build with.

Duncan



More information about the cabal-devel mailing list