cons-discuss
[Top][All Lists]
Advanced

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

Re: AfterBuild, Dynamic target/dynamic dependencies: How?


From: Steven Knight
Subject: Re: AfterBuild, Dynamic target/dynamic dependencies: How?
Date: Wed, 29 Nov 2000 17:30:39 -0600 (CST)

On Wed, 22 Nov 2000, Zachary Deretsky wrote:
> A. Take [qw(input1.txt input2.txt)] and generate a list
> of python files @python_files and/or a text file with this
> list, python_files.txt. Some of these python files are repository
> files and some are being built and installed into the $EXPORT
> tree by the parallel Conscripts.
> 
> I succeeded in writing the Command method whith [perl] clause to call a
> function which creates @python_files (local to that function) and
> python_files.txt.
> 
> python_files.txt gets written to the disk and that is where my success
> stops.
> 
> The BIG question is how do I make @python_files visible in my Conscript and
> how do I make the next step depend on this list, so that the files in the
> list are built and installed before the next step, B., is run?

One trick I've used with Command in the past is to not worry about
getting the list into a perl array.  Since the list is contained in
the python_files.txt file, you can just use the contents of the file to
maintain the list.  On UNIX, it could look something like this:

        Command $env 'output', 'python_files.txt', qq(
                create_output_file `cat %<` > %>
        );

On NT, you could do something similar with "[perl]" if you didn't have
UNIX utilities like "cat" available.

This would work because Cons' computation of the MD5 checksum of
python_files.txt will detect any time the contents of the list has
changed, and will cause 'output' to be re-generated in that case.

> B. Take the result of A., @python_files or python_files.txt
> and generate a parallel list @c_files and/or text file, c_files.txt.
> 
> Again, if I succeed in B., how do I make the list @c_files visible in my
> Conscript, so that this list is valid for <sources> for the Program method
> in C.?
>
> C. Take the list from B., append one more c source file, main.c
> and call the Program method to obtain result.exe

As you're experiencing, the above trick wouldn't work for Program because
Program needs to see the .c extensions on the files.

I believe this is where the combination of Gary's Afterbuild + AddTarget
patches would be necessary.  I haven't used them much, but I think you'd
do something along the following lines (modulo typos):

        Command $env 'python_files.txt', qw(whatever input files), qq(
                command_to_create_python_files_txt %< > %>
        );
        AfterBuild $env 'python_files.txt', qq(
                @python_files = `cat python_files.txt`;
                @c_files = map {s/\.py$/\.c/} @python_files;
                Program $env 'result.exe', @c_files;
                AddTarget $env, 'result.exe';
        );

The upshot is you don't make the array visible in the Conscript file,
you do what you need entirely within the AfterBuild code.

Gary, please correct me if I've gotten the details wrong on how (or
whether) to use AfterBuild + AddTarget in this case.

        --SK




reply via email to

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