[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Object & changing target of CXXCOM
From: |
Johan Holmberg |
Subject: |
RE: Object & changing target of CXXCOM |
Date: |
Mon, 18 Jun 2001 14:18:48 +0200 (MEST) |
On Fri, 15 Jun 2001, Gary Oberbrunner wrote:
>
> Steven Allen writes:
>
> > I guess I think of it as I should be able to say
> >
> > Objects $env "file.cpp", 'foo.cpp';
> > or
> > Objects $env "file.cpp" => "../../obj/file.o",
> > "foo.cpp" => "../../obj/foo.o";
>
> I'd also like to be able to do this (the above syntax doesn't
> work, but something could be worked out -- maybe just for one
> object at a time). Just yesterday I wanted to build a little
> test program using a few of my sources, built with different cmd
> line options (-DTEST_MODE); the obvious thing of just defining a
> new environment with -DTEST_MODE in it and using Program doesn't
> work, because the objects are built twice with different
> options.
I have also felt that it is too complicated to do these things.
Therefore I added functionality to make it easier in my "Cons::Plus"
module. There I can direct where object files are placed in two
new ways:
1) use the new method "ObjectsInDir":
use Cons::Plus;
$y1 = Cons::Plus->new(CFLAGS => "-DVARIANT1");
$y2 = Cons::Plus->new(CFLAGS => "-DVARIANT2");
@objs1 = $y1->ObjectsInDir('myprog.c', 'mylib.c', 'some-dir-1');
$y1->Program('myprog-1', @objs1);
@objs2 = $y2->ObjectsInDir('myprog.c', 'mylib.c', 'some-dir-2');
$y2->Program('myprog-2', @objs2);
'ObjectsInDir' works like 'Objects', but places the object files
in the directory specified as last argument. So the directory
layout in the example will be:
$ cons . -p
myprog-1
myprog-2
some-dir-1/mylib.o
some-dir-1/myprog.o
some-dir-2/mylib.o
some-dir-2/myprog.o
2) use the variable 'BUILD_TOP'. It is understood by 'Cons::Plus::Program'
and 'Cons::Plus::Objects', and works almost like the 'Link' command
(but without any hard links or copying):
use Cons::Plus;
$x1 = Cons::Plus->new(BUILD_TOP => "variant1",
CFLAGS => "-DVARIANT1" );
$x2 = Cons::Plus->new(BUILD_TOP => "variant2",
CFLAGS => "-DVARIANT2" );
$x1->Program('myprog', 'myprog.c', 'mylib.c');
$x2->Program('myprog', 'myprog.c', 'mylib.c');
In this case we get the following layout:
$ cons . -p
variant1/mylib.o
variant1/myprog
variant1/myprog.o
variant2/mylib.o
variant2/myprog
variant2/myprog.o
If anyone is interested in Cons::Plus, it is available from
ftp://mercury.iar.se/jhftp/cons/ (I also mentioned it in a mail to
the list on April 4).
/Johan Holmberg