Boost logo

Boost-Build :

From: Chris Dragan (cdragan_at_[hidden])
Date: 2005-11-17 16:56:44


The project site suggested contributing patches here, so here I am. :-)

The proposed patch fixes header dependency scanning in Jam.

The Problem

Consider the following example:

+++ Jamfile
Main deptest : deptest.c ;

+++ deptest.c
#include "subdir/a.h"
int main() { return 0; }

+++ subdir/a.h
#include "b.h"

+++ subdir/b.h

Now run jam. After you build the executable, touch file b.h and re-run
jam. You
would expect it to rebuild the executable, but it fails:

# jam
...found 12 target(s)...
...updating 2 target(s)...
Cc deptest.o
Link deptest
Chmod1 deptest
...updated 2 target(s)...

# touch subdir/b.h

# jam
...found 12 target(s)...

The Solution

For simplicity:
- includer - the header that includes another header
- includee - the header being included by the includer.

Apparently when searching for the includee Jam does not search relatively
to the directory where the includer was found. This becomes apparent, when
we look in HdrRule - we see there the following line:

HDRSEARCH, among system and explicitly specified directories also contains
".", which does not necessarily have to be the directory where the
includer is located, especially when the includer itself was included by
another file.

Fortunately, Boost Jam passes an undocumented, third argument to HdrRule -
bound file name of the includer. From it, we can extract the path where
the includer sits, and make Jam look there for the includee:
SEARCH on $(s) = $(3:D) $(HDRSEARCH)
Notice, that we should look there first, before we check other directories.

The Patch

The patch in the attachment applies the above solution both to Jambase and
to jambase.c. The patch was made against Boost Jam 3.1.9, but it is
working as well with e.g. 3.1.6.

I hope that someone will find it useful.

Best Regards,
Chris Dragan
 ------------2OosYj3m03XUMioL1tdrdy Content-Disposition: attachment; filename=boost-jam-3.1.9-dependency.patch
Content-Type: application/octet-stream; name=boost-jam-3.1.9-dependency.patch
Content-Transfer-Encoding: Base64

[Attachment content not displayed.] ------------2OosYj3m03XUMioL1tdrdy--

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at