Boost logo

Boost :

From: Larry Evans (jcampbell3_at_[hidden])
Date: 2002-01-29 23:37:06


Vladimir Prus wrote:

>

[snip]

>
> Now I seem to understand what you mean. You refer to lib/src/class1.cpp in
> two main targets (lib/tests/correctness/driver{1,2}) and the file is compiled
> twice, right? Yes, such problem is present. In the new build system, it will
> be partially solved:
>
> exe main1 : main1.cpp lib.cpp ;
> exe main2 : main2.cpp lib.cpp ;
>
> In this case, it is easy to note that neither main target has explicit
> requirements, and lib.cpp can be compiled only once. Your example can be
> handled like:
>
> # Jamfile in lib/tests/correctness
> exe driver1 : driver1/main.cpp lib/src/class1.cpp ;
> exe driver2 : driver2/main.cpp lib/src/class1.cpp ;
>
> Is this solution ok? Another approach would be to define new feature, say

Almost, but not quite. I would like to avoid mixing code in the same directory
which doesn't pertain to each other. For example, driver1/main.cpp has nothing
to do with driver2/main.cpp.

>
> "testing-type", with values "correctness" and "performance", then to make a
> library of lib/src/*.cpp and use it for test drivers. This approach might
> even work in the current system (sorry, have not tried yet, so may be wrong)
>
> > Of course, maybe I'm missing something. If so, please help me find it :).
>
> Or maybe it's me who's missing something, and knoweledge of what you'd like
> from the build system is very important.
>

Thanks for you interest.

This is what I'd like:

Currently I'm using gnu make and provide it with
two macro arguments, TARGET and BUILD as well as a target, e.g. link.
TARGET and BUILD are directories containing target.imk and build.imk
files, respectively. The target.imk specifies what program to build and the
build.imk specifies what compiler and options to use.

It may help to view the directory heirarchy. Here it is:
<---------- directory heirarchy---------------
boost/dev/Makefile
boost/dev/build_variants/gcc/compiler.imk
boost/dev/build_variants/gcc/debug/build.imk
boost/dev/lib/col_io/tests/common.imk
boost/dev/lib/col_io/tests/marg_buffer_put/main.cpp
boost/dev/lib/col_io/tests/marg_buffer_put/target.imk
boost/dev/lib/col_io/tests/marg_ostream/main_cout.cpp
boost/dev/lib/col_io/tests/marg_ostream/target.imk
boost/dev/build/gcc/debug/lib/col_io/tests/marg_buffer_put/main.o.dep
boost/dev/build/gcc/debug/lib/col_io/tests/marg_buffer_put/main.o
boost/dev/build/gcc/debug/lib/col_io/tests/marg_buffer_put/main.exe
boost/dev/build/gcc/debug/lib/col_io/tests/marg_ostream/main_cout.o
boost/dev/build/gcc/debug/lib/col_io/tests/marg_ostream/main_cout.o.dep
boost/dev/build/gcc/debug/lib/col_io/tests/marg_ostream/main_cout.exe
boost/dev/build/gcc/debug/lib/col_io/src/marg_put.o.dep
boost/dev/build/gcc/debug/lib/col_io/src/marg_put.o
boost/dev/build/gcc/debug/lib/col_io/src/marg_ostreambuf.o.dep
boost/dev/build/gcc/debug/lib/col_io/src/marg_ostreambuf.o
boost/dev/build/gcc/debug/lib/col_io/src/marg_ostream.o.dep
boost/dev/build/gcc/debug/lib/col_io/src/marg_ostream.o
boost/dev/build/gcc/debug/lib/col_io/src/marg_buffer_put.o.dep
boost/dev/build/gcc/debug/lib/col_io/src/marg_buffer_put.o
boost/dev/release/gcc/debug/lib/col_io/tests/marg_buffer_put/main.release.log
boost/dev/release/gcc/debug/lib/col_io/tests/marg_ostream/main_cout.release.log
>---------- directory heirarchy---------------
So, to build:
   boost/dev/build/gcc/debug/lib/col_io/tests/marg_ostream/main_cout.exe
I invoke make as follows:
   make TARGET=lib/col_io/tests/marg_ostream BUILD=gcc/debug link
This produces, as needed, the *.o *.o.dep and *.exe files in
    boost/dev/build/gcc/debug/lib/col_io/src/
    boost/dev/build/gcc/debug/lib/col_io/tests/marg_ostream/
The *release.log files simply record which version of the files are used to create
the .exe file. They are produced with the release target instead of the link target
in the make command. This also vc's any file that doesn't have the used file stored
in RCS. This target uses the *.o.dep files which are produced with the g++ -MMD
flag, which is specified in the compiler.imk file. This file is included by the build.imk
file in the same way as the target.imk file includes the common.imk file. This
is explained a little more in the next paragraph.

The content of the marg_ostream/target.imk file is:
<---------------- marg_ostream/target.imk --------------
IMK.pops:=$(shell perl -e 'print $(IMK.pops) + 1')
include $(shell echo $(IMK.path)/common.imk|tee -a Makefile.d)
IMK.pops:=$(shell perl -e 'print $(IMK.pops) - 1')

TMP.cpps:=marg_put.cpp marg_buffer_put.cpp marg_ostreambuf.cpp marg_ostream.cpp
SRC.cpps:=$(SRC.cpps) $(TMP.cpps:%.cpp=$(SRC.path)/%.cpp)

SRC.path:=$(IMK.path)
#MAIN.cpp=main
MAIN.cpp=main_cout
TMP.cpps:=$(MAIN.cpp).cpp
SRC.cpps:=$(SRC.cpps) $(TMP.cpps:%.cpp=$(SRC.path)/%.cpp)
>---------------- marg_ostream/target.imk --------------
The path to this file is stored in IMK.path macro. The 1st 3 lines include the common.imk
file in the directory just above the one with target.imk. This is useful when you want to
store values common to several .imk files in upper level directories.

Please let me know if I need to explain more. Again, thanks for your interest.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk