Reputation: 30514
I am building a project with Waf. It has several third-party dependencies, and I would like to build each dependency from my main wscript
. My project is organized like this:
/boost/
/gtest/
/source/
/waf
/wscript
/wscript_boost
/wscript_gtest
Each "dependency" wscript_*
has commands defined, just like my main wscript
.
def options(opt): pass
def configure(conf): pass
def build(bld): pass
If I had put the dependency wscript
files in the dependency folders, I could just call opt.recurse('boost gtest')
, but I don't want to mix my files with third-party files.
Is there any way for my wscript
to call into wscript_boost
and wscript_gtest
?
Upvotes: 3
Views: 1343
Reputation: 15180
The way to do that is usually to put a wscript into each subdirectory and to use recurse :
/boost/
/boost/wscript
/gtest/wscript
/source/
/waf
/wscript
And use recurse :
def build(bld):
# ...
bld.recurse("boost")
bld.recurse("gtest")
# ...
Upvotes: 0
Reputation: 390
I don't think it is possible in the current Waf implementation (waflib.Context.Context.recurse
uses a global WSCRIPT_FILE
variable).
Though ugly, it is possible to hack this at the beginning of your main wscript
:
import waflib.Context
original_recurse = waflib.Context.Context.recurse
def new_recurse(ctx,*args, **kwargs):
original_wscript_file = waflib.Context.WSCRIPT_FILE
try:
waflib.Context.WSCRIPT_FILE = (original_wscript_file +
kwargs.pop('suffix', ''))
original_recurse(ctx, *args, **kwargs)
finally:
waflib.Context.WSCRIPT_FILE = original_wscript_file
waflib.Context.Context.recurse = new_recurse
Your main wscript
would the be something like:
def configure(cfg):
cfg.recurse(suffix='_boost')
cfg.recurse(suffix='_gtest')
Note that there are some side effects, as WSCRIPT_FILE
is suffixed when you are inside the wscript_boost
file.
You can also submit an issue to the waf project.
Upvotes: 2