|
Boost-Build : |
From: Jurko GospodnetiÄ (jurko.gospodnetic_at_[hidden])
Date: 2008-08-24 14:04:18
Hi Jim.
>>> Actually, I really want the vendor path set by an environment
>>> variable. How can I refer to an environment variable in a target rule,
>> You can read environment variables by using the os.environ rule. For
>> example:
>>
>> import os ;
>> local unga-unga = [ os.environ UNGA_UNGA ] ;
>> ECHO $(unga-unga) ;
>
> This works well. And it is easier to understand than the example in
> the Boost Build docs.
Cool. Glad it helped. Could you perhaps suggest a patch for the docs?
>>> and how can I get the correct extension for the object file?
>>
>> alias vendor-obj : C:/vendor_install/lib/main.obj :
>> <target-os>windows ;
>> alias vendor-obj : /opt/vendor_path/lib/main.o :
>> <target-os>unix ;
>> alias vendor-obj : /opt/vendor_path/lib/main.o :
>> <target-os>linux ;
>>
>> ###############################################
>> #
>> # Main build.
>> #
>> ###############################################
>>
>> exe JimTest : [ glob *.cpp ] [ glob *.c ]
>> ..//MyLib
>> vendor-obj ;
>>
>
> This also works, thanks. I would really like the unga-unga setting and alias
> available to the subprojects. When I add this code to the Jamroot file, the
> subprojects do not inherit the unga-unga setting, nor the vendor-obj alias.
> How can I define these things in the Jamroot file so that subprojects
> pick them up?
Well all the 'global' variables in Boost Jam are actually module
local and each Jamfile has its own module (in addition each class has
its own module as well but that should not concern you at the moment).
Boost Build provides you with the constant rule which may be used to
avoid this. For example, to reuse the unga-unga example (heh, I'm
starting to like the name :-)):
import os ;
constant unga-unga : [ os.environ UNGA_UNGA ] ;
ECHO $(unga-unga) ;
This will define a global (i.e. module local) variable in this
Jamfile's module and add it throughout all of your other project
(Jamfile) modules.
Note that this variable needs to remain constant as each module
actually gets its own copy.
Should you need a non-constant variable that is actually shared
between different modules you will need to place it in a module of your
own (or perhaps the global module) and then always reference it
explicitly from that module. See the docs for more info on this if you
need it or ask here (keywords: module, modules.peek, modules.poke ).
And the alias targets you mention are already available from other
Jamfiles but you need to refer to them using their full name, i.e.
<project>//<target-name>. Some examples:
From a subproject Jamfile:
..//vendor-obj
From a subproject Jamfile two folders down:
../..//vendor-obj
Irrelevant of your folder structure if your main project's name or id
is main-project:
/main-project//vendor-obj
site-config.jam & user-config.jam configuration files are project
files themselves and have names site-config and user-config so you can
refer to targets declared in them like this:
/user-config//some-user-target
/site-config//some-site-target
That last example can be useful for having centrally defined targets
representing libraries available on a specific machine (i.e. site) and
available to all projects.
Again, if you could not find this in the docs, or you found relevant
documentation parts to be too confusing, could you please post a patch?
That would be much appreciated...
Hope this helps.
Best regards,
Jurko GospodnetiÄ
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk