cons-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extending cons


From: Johan Holmberg
Subject: Re: Extending cons
Date: Tue, 21 Nov 2000 13:26:05 +0100 (MET)

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

PS. I hope someone else on the list answers your file-method
    questions. If not, I'll make a try later ...
    (the list server at gnu.org seems to be "dead" for the moment)
DS.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]