[Module-build-general] A mini-language for dependencies?
Status: Beta
Brought to you by:
kwilliams
|
From: Ken W. <ke...@ma...> - 2003-02-19 04:49:54
|
Hey,
So, I think Dave was the first to suggest this, and now I'm thinking
it's maybe the right way to go too. I think we need a little boolean
mini-language to express module dependencies.
The reasoning is that some modules have complicated dependencies that
surpass even the capabilities of the current M::B system. When this
happens, the developer's only choice is to use perl code to set the
dependencies dynamically based on querying the user, poking around in
the environment (for instance, getting the version of perl or looking
at $^O), or whatever. This means that a comprehensive, static
dependency mapping much harder to maintain, since each dynamic
dependency creates an unknown blotch in the map.
Anything we can do to get these dependencies expressed in a static
declarative structure, rather than in runtime perl code, will help with
this kind of mapping.
Such a mini-language probably doesn't need to be very sophisticated -
probably just needs to support arbitrary boolean combinations, and have
a few things to represent things like the perl version and the
operating system.
The mini-language would probably be the province of a new module called
something like Module::Prereq or Module::Dependency, which
Module::Build would depend on (and because of a chicken/egg problem,
Module::Build can't actually use the mini-language to express this
dependency ;-).
I don't have a lot of experience designing mini-languages, but I'm
thinking it should do at least the following:
* Allow arbitrary boolean combinations of dependency on arbitrary
versions of modules
* Allow declarative branching based on perl version or OS
* Allow dependency specification based on feature sets, similar
to the way ExtUtils::AutoInstall groups things
* Let the author specify *why* a certain dependency is necessary,
especially in the case of optional dependencies
Here's a first stab at an example - it doesn't fulfill all of the above
criteria, and it's not very nice yet, but it could maybe get the ball
rolling.
-----------------------------------------------------------------------
SUBRULES:
$md = Crypt::MD5 | Crypt::MD4; # Subrules use '$' sigil?
REQUIRES:
perl 5.6.0; # Version number by itself, means "minimum required"
File::Basename
purpose => "To compute basenames for foo-function";
$md; # As defined above
(os = 'Windows' & Archive::Tar 0.23) # OS-dependent stuff
| (os != 'Windows' & Archive::Tar 0.17)
RECOMMENDS:
Term::ReadKey;
FEATURES:
feature1 => {
PURPOSE:
"Allows you to use feature 1"
REQUIRES:
Foo::Bar
}
-----------------------------------------------------------------------
Comments? Is there some precedent for this that I should follow?
One thing I specifically *haven't* addressed is external dependencies,
like libraries or shell commands. I don't know whether we want to get
into that stuff.
-Ken
|