[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: cons - 2 things to think about
From: |
Gary Oberbrunner |
Subject: |
RE: cons - 2 things to think about |
Date: |
Fri, 22 Jun 2001 20:09:58 -0400 |
Been there, done that. You need AfterBuild.
Here's the general idea: build foo.in as usual, then do something like this
(I'm typing this in by hand, no testing, but hopefully you'll get the idea):
AfterBuild('foo.in', 'gen_src_list(...)');
sub gen_src_list {
system("foo -list foo.in >/tmp/srclist"); # or whatever...
SRCLIST=open('/tmp/srclist');
while(<SRCLIST>) {
push @generated_srcs, $env->Objects($_); # Dynamically add rule!
}
$env->Program("a.out", @generated_srcs);
}
The only two catches are:
- something else must reference your a.out: it cannot be a top-level target
or cons won't find it and nothing will get built. If you're building an
installer from it or something this will take care of it. (I have an
AddTarget patch which does this, but it's not in 2.3.0.)
- there may be some issues with perl packages above. Make sure cons can
find your $env, and your gen_src_list. I'm not sure how 2.3.0 is handling
this, but at the very least if you put them both in special named packages
it'll be sure to find them. The thing to remember is that gen_src_list will
not get run when the rest of your Conscript does; it'll get run at build
time, when targets are being built, and the current package then may be
different.
- You *might* need to add a dependency here or there (with Depends), it all
depends. :-)
Enjoy!
-- Gary Oberbrunner
> -----Original Message-----
> From: address@hidden [mailto:address@hidden
> Behalf Of Paul Heely
> Sent: Friday, June 22, 2001 6:41 PM
> To: 'address@hidden'
> Subject: cons - 2 things to think about
>
>
> I am new to cons and have a problem that I would like to express as a
> scenario.
>
> Say,
>
> foo.xxx created foo.in by executing a command bar
>
> Then foo.in created a list of c and h files that need to be
> built.. but the
> list of sources that are created is dependent on the contents of foo.in
>
> But, the command foo when given a -list parameter would list the set of
> output files
> that it would generate if executed without the -list
>
> % foo -list foo.in
> foo.x.cc
> foo.y.cc
> foo.x.h
> foo.y.h
>
> Now executing the command
> % foo foo.in
>
> produces these files, and I need to compile and link them with, maybe,
>
> Program $env "a.out", @sources_produced_from_foo.in;
>
> I would like to create a cons script that builds these.. Looks like cons
> currently doesn't lend itself well to this type of operation.
>
> Can anyone help?
>
> Thanks
> --Paul
>
> _______________________________________________
> address@hidden
> http://mail.gnu.org/mailman/listinfo/cons-discuss
> Cons URL: http://www.dsmit.com/cons/
>