Boost logo

Boost-Build :

From: David Abrahams (dave_at_[hidden])
Date: 2003-03-05 11:53:41

Ali Azarbayejani <ali_at_[hidden]> writes:

> Thanks for your quick reply...
> Vladimir Prus wrote:
>> >
>> > 1 - Project IDs, Subprojects, Project Trees: Is it true in
>> > Bjam/Boost.Build that sub-projects must be subdirectories?
>> In Boost.Build V1, this is not possible. In V2, there situation is different:
>> 1 if you have Jamfile in subdir, then it's subproject, which inherits parent's
>> attributes and so on.
> OK, this is convenient...fine. It is useful if you can subscribe to
> the structural constraint that your project is entirely self-contained
> in a single heirarchy.

That's just the Boost.Build definition of "project". It doesn't mean
you can't have your project use projects in other directory
hierarchies. The only thing you can't do is automatically impose
defaults on those other projects in the same way that a project's
subprojects will inherit its defaults.

However, many build properties are propagated from targets to their
dependencies, so it will often have a similar effect when bulding
targets in your project.

> But, personally, I wouldn't mind being explicit even in this case. A
> more consistent and flexible policy would be that a super-project
> specifies IDs of all its subprojects, whether they are subdirectories
> or not...they should be allowed to be physically located as sibling
> directories or "distant cousin" directories as well. (see example
> below)

It's more flexible, but also more verbose, and easy to make mistakes
with. IMO not worth the hassle. Boost.Build should be easy to use.

>> 2. However, if subdir also contains file called project-root.jam, it's
>> entirely standalone entity. For example, you can grab entire Boost
>> source tree, add it to directory "boost" at the top of your project, and
>> use it.
> Yes, I see. However, this is what I would like to avoid...relocating
> projects.

You don't need to.

> Say I already have Boost source tree somewhere else, and
> I'm using it as a subproject in another project.

Why would you use it as a subproject?

> I would like to simply point at it and say "use packages/boost",

In which file would you like to be able to do that?

> WITHOUT adding the source tree to the top of my project. Here is an
> example illustration.

You can already do:

use-project /boost : /home/work/packages/boost ;

from any other project, or, I think, from your site-config.jam or user-config.jam.

> home
> +- work
> +- packages
> | +- boost
> | +- Makefile/Jamfile
> | +- ...
> |
> +- myroot
> | +- exe
> | +- myexe
> | +- Makefile/Jamfile
> | +- ...
> |
> +- anotherroot
> +- lib
> +- alibrary
> +- Makefile/Jamfile
> There are three projects here.
> (1) Project "packages/boost" (self-contained)
> (2) Project "anotherroot/lib/alibrary" (self-contained, a useful
> library)
> (3) Project "myroot/exe/myexe" (depends on "anotherroot/lib/alibrary"
> and
> "packages/boost")
> (Note that there could be other projects which use "packages/boost" or
> "anotherroot/lib/alibrary", so it's undesirable to create copies of
> them for each project that uses them.)
> They come from three different repositories. I would like just to
> check them out "as is", not try to arrange them in a heirarchy. Can
> you understand the usefulness of this for code-sharing and re-use in a
> diverse development organization?

I think we've considered all these issues and accomodated them
already, if I understand you correctly.

>> Jamrules does not exist in V2, and boost-build.jam serves quite different
>> purpose --- allows to find the build system without any environment
>> variables.
>> Can you explain what is wrong with project-root.jam?
> Can you explain why it is necessary? Why aren't the directives found
> in project-root.jam simply in the Jamfile (of the root project)?

At least two reasons:

1. The subproject jamfile would otherwise need to explicitly identify
the location of its project root, which is tedious, verbose, and

2. When you build from a subdirectory of the project root, the build
system shouldn't have to read the Jamfile in the project root

> (Note that I'm not clear on the difference between project-root.jam
> and boost-build.jam...

boost-build.jam is used to locate the directory of the Boost build
system sources. It's separate from project-root.jam because that may
be more convenient. For example, if you do all your development work
in subdirectories of /home/ali/develop, you can put a boost-build.jam
there and never have to identify the build system directory again.

> I think in both versions of Boost.Build there is some .jam file that
> is required to be found upward of each Jamfile.

Not neccessarily upward. It could be in the same directory. For very
simple lightweight projects we should probably give users a way to do
it with one file in BBv2.

> I suppose each Jamfile could have a corresponding project-root.jam,
> but as you can see in the above example, there is no "project root"
> in this case...the "work" directory is not part of any of the three
> separate code trees.)

Each of the three code trees is a different project, then.

Dave Abrahams
Boost Consulting

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