cons-discuss
[Top][All Lists]
Advanced

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

Re: [Cons-discuss] TAGS anyone?


From: Johan Holmberg
Subject: Re: [Cons-discuss] TAGS anyone?
Date: Wed, 20 Sep 2000 23:13:33 +0200 (MET DST)

On 20 Sep 2000, Doug Alcorn wrote:
[...]
> I would like to be able to have one TAG file in the common directory
> that is for all the files in that hierarchy.  Actually, it would be
> nice if each subproject only had one TAG file in it's toplevel
> directory.
> 
[...]
> 

I'm not sure I understand exactly what you want to do, but I'll try
to answer to what I think you mean ...

Suppose we have the following file-tree:

    ./Construct
    ./top/TAGS
    ./top/gamma.c
    ./top/sub1/beta.c
    ./top/sub1/Conscript
    ./top/sub2/alfa.c
    ./top/sub2/Conscript
    ./top/Conscript

Are you trying to update TAGS when any of the c-files in the tree changes ?
And is the command something like the following ?

    $ etags -o ./top/TAGS ./top/gamma.c ./top/sub1/beta.c ./top/sub2/alfa.c


I wrote an example solution assuming that the problem
description above is correct. Othwise the following is
probably gibberish :-)

I don't know if my solution is the best,
and would be interested to know of any better solution.

Your requirement of having no "centralized" knowledge of all files,
indicates that it would be suitable to use any of the methods where
Conscript files in different directories can contribute to the same
target (ie. Module, LinkedModule, Library (are there more?)).

But unfortunately all these methods assume that c-files should
be compiled to object files before they are "linked together".
So I created a new method:

#----------------------------------------------------------------------
sub cons::TagsFile
{
    my($env) = shift;
    my($tgt) = $dir::cwd->lookupfile($env->_subst(shift));
    my($progenv) = $env->_resolve($tgt);
    $tgt->bind(find build::command::linkedmodule($progenv,
                                                 $progenv->{TAGSCOM}),
               map($dir::cwd->lookupfile($env->_subst($_)), @_));
}
#----------------------------------------------------------------------

This is almost like "LinkedModule", but without trying to compile
the c-files. And with a new command symbol "TAGSCOM" that is supposed
to be set to something like:

    $e = cons->new(
                   ENV =>     { PATH => "/usr/local/bin"},
                   TAGSCOM => "etags -o %> %<"
                   );

I've also "reused" the "build::command::linkedmodule" class in the TagsFile
method (I don't know if this is appropriate).

Anyway, with the definitions above I could then use lines like:

    TagsFile $e $tags_file, "beta.c";

in the different Conscript files, to make contributions to one
single TAGS file (the name propagated with "Export" between the
different Conscript files as the variable $tags_file).

All files of my example follow below.

Was this anywhere near what you tried to solve ?

/Johan Holmberg

----------------------------------------------------------------------
==> ./Construct <==


sub cons::TagsFile
{
    my($env) = shift;
    my($tgt) = $dir::cwd->lookupfile($env->_subst(shift));
    my($progenv) = $env->_resolve($tgt);
    $tgt->bind(find build::command::linkedmodule($progenv,
                                                 $progenv->{TAGSCOM}),
               map($dir::cwd->lookupfile($env->_subst($_)), @_));
}

Build qw(
         top/Conscript
         );



----------------------------------------------------------------------
==> ./top/Conscript <==


$e = cons->new(
               ENV => { PATH => "/usr/local/bin"},
               TAGSCOM => "etags -o %> %<"
               );

$tags_file = "#" . FilePath("TAGS");

Export qw( e tags_file );


Build qw(
         sub1/Conscript
         sub2/Conscript
         );


TagsFile $e $tags_file, "gamma.c";

----------------------------------------------------------------------
==> ./top/gamma.c <==
int gamma; /* trivial C file */

----------------------------------------------------------------------
==> ./top/sub1/Conscript <==


Import qw( e tags_file );

TagsFile $e $tags_file, "beta.c";

----------------------------------------------------------------------
==> ./top/sub1/beta.c <==
int beta; /* trivial C file */

----------------------------------------------------------------------
==> ./top/sub2/Conscript <==

Import qw( e tags_file );

TagsFile $e $tags_file, "alfa.c";

----------------------------------------------------------------------
==> ./top/sub2/alfa.c <==
int alfa; /* trivial C file */

----------------------------------------------------------------------




reply via email to

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