سؤال

I have a jam file hierarchy as follows:

Jamroot:

lib foo : <file>/SOME/RANDOM/FILE ;

build-project p1 ;
build-project p2 ;

Jamfile in p1:

lib bar : bar.cpp

Jamfile in p2:

lib bar2 : bar2.cpp ../p1//bar ..//foo ;

So bar2 depends on bar and foo using relative paths.

Is it possible to write a single command in Jamroot so that I can write the following in Jamfile in p2 instead?

lib bar2 : bar2.cpp /p1//bar //foo ;

That would be more convenient as you don't need to think of the relative path anymore. I know there is the use-project command, but 1) I would need to write a use-project for each of the subdirectories, 2) I don't know how to declare the root folder using use-project...

thanks!

هل كانت مفيدة؟

المحلول

1) You can automate use-project declarations with glob and looping:

for p in [ glob */[jJ]amfile ]
{
    use-project /$(p:P) : ./$(p:P) ;
}

:P is for getting the parent directory. More on variable expansion here

2) Assigning a project-id to the current project isn't done with use-project, it's done with project:

project /root ; # common requirements and other useful things can go here if needed (link)

I don't think //foo is a valid syntax for a target reference. Also I don't think you can denote a target in a parent project with some target reference that doesn't contain a non-empty project-id (or path).

Finally you can write this in p2's Jamfile:

lib bar2 : bar2.cpp /p1//bar /root//foo ;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top