[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Extending cons
From: |
wouter . batelaan |
Subject: |
Re: Extending cons |
Date: |
Wed, 22 Nov 2000 13:42:20 +0100 |
On 21/11/2000 12:30:09 holmberg wrote:
>...
>I don't know how to structure the solution to suite you problem,
>but I suppose it is possible.
Thanks Johan, that is more or less what I want to do.
In addition I want to map each component name onto a
<comp_name>/Construct file, by using a lookup along a component
search path. That can be done using a bit of perl.
Furthermore I want to use cons's variable export/import mechanism
to define and pass configuration variables to the make's. I am sure it is
possible,
just takes me some time to work it out!
Thanks,
Wouter Batelaan
>On Tue, 21 Nov 2000 address@hidden wrote:
>> >
>> >As I understand it, you declare the dependencies between
>> >"components" and then want to run "make" on each component in the
>> >"right" order (and to *always* run all the makes, since only they
>> >know if there is something to do in each component).
>> >
>> >Isn't this just a topological sort ?
>> >You could use the Graph::Directed-module to do it in Perl,
>> >but do you really need cons ?
>>
>> No, of course I could write something myself,
>> but cons has several features which I would like to use:
>> - It has a framework for reading Perl files.
>> - It has facilities to declare dependencies, which it
>> handles effectively in the right order.
>> - It has the capability to define (configuration) variables and control
>> inheritance of them.
>> - It allows building command lines, using variable substitution,
>> invoking them, and checking return status.
>> It allows me to gradually change from just controlling and sequencing make
>> builds to using cons for each component and the whole system.
>>
>
>I understand your resons.
>After reading your mail, I tried to implement topoligical sort in
>cons, and this is what I got:
>
>I wrote a Construct file like this:
>
> use ConsTopologicalSort;
>
> Component( "a" => "b", "d" );
> Component( "b" => "c", "f" );
> Component( "e" => "f" );
> Component( "f" => "x" );
>
>When running cons I got:
>
> $ cons sort
> make c
> make x
> make f
> make b
> make d
> make a
> make e
>
>I seem to have got the "make"-lines sorted accorded to the
>dependencies declared with the "Component" lines.
>
>The module doing the work is "ConsTopologicalSort". It looks like:
>
>-------------------------------------------------------
>$e = cons->new();
>
>Command $e "sort", "@/bin/true";
>
>sub Component
>{
> my ($name, @deps) = @_;
>
> Command $e $name, "@/bin/echo make $name";
> Depends $e "sort", $name;
> for my $dep (@deps) {
> Command $e $dep, "@/bin/echo make $dep";
> Depends $e $name, $dep;
> }
>}
>
>1;
>-------------------------------------------------------
>
>
>Maybe this is misusing "cons" a bit, :-)
>but it at least demonstrates *one* way to get "cons"
>to do a topological sort.
>
>I don't know how to structure the solution to suite you problem,
>but I suppose it is possible.
>
>/Johan Holmberg