Boost logo

Boost-Build :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-11-21 03:04:34

Hi Chris,

> The proposed patch fixes header dependency scanning in Jam.
> 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
> #define SOMETHING
> 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:
> Fortunately, Boost Jam passes an undocumented, third argument to HdrRule -
> bound file name of the includer.

Not so "fortunately" -- it was added explicitly to handle the case of ""
includes that you bring up. That is, to handle *efficiently*.

> 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.

This patch is wrong, sorry. Say you have file a.cpp that contains:

#include <a.h>

- there's file a.h in INCLUDES
- there's file a.h in current directory
- current directory is not in INCLUDES

Then, <a.h> refers to file in INCLUDES, not in current directory. With your
patch, a.h in the current directory will be used.

In Boost.Build V2, this problem is solved by separately handling "" and <>
includes, take a look at "c-scanner" class in v2/tools/builtin.jam
And, we also have an automated test for this! It might be better if you reuse
that logic, or just use V2.

- Volodya

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