Reputation: 33
I'm trying to figure out how to encapsulate the entire waf deployment process into a single waf function
Tradition waf deployment process:
waf distclean configure build
Put that into a wscript function that allows me to call all three of those waf options:
waf deploy
The function inside the wscript:
def deploy(bld):
""" Performs waf distclean, configure and build
Args:
bld: The waf build context object
"""
#somehow call waf distclean, configure and build
requirements: I can't do this with a shell alias; this has to be within the wscript and in python;
I've checked https://waf.io and can't find a way to call waf configure :(
Upvotes: 1
Views: 755
Reputation: 754
(I know that this question is quite dated; however, this is question is still one of the top suggestions to this matter.)
Unfortunately you cannot achieve this using 'distclean' as this command also deletes the local waflib download by ./waf
.
(Note: I am not entirely sure about this one; waf's power surprises me every day)
However, you can go for the plain 'clean':
def deploy(ctx):
from waflib import Build
cctx = Build.CleanContext()
cctx.execute()
This seems to work just fine. While we're at it:
If plan to build multiple configurations/variants/environments (i.e. Debug vs Release), you can use this little gem:
def build_all(ctx):
from waflib import Build
deb = Build.BuildContext()
deb.variant = 'debug' # Assuming, that 'debug' is an environment you set up in configure()
deb.execute()
rel = Build.BuildContext()
rel.variant = 'release' # Analogous assumption as for debug.
rel.execute()
Upvotes: 0
Reputation: 1405
Another solution is to use Options from the waflib
:
def configure(conf):
print("Hello from configure")
def build(bld):
print("Hello from build")
def deploy(bld):
from waflib import Options
commands_after = Options.commands
Options.commands = ['distclean', 'configure', 'build']
Options.commands += commands_after
Upvotes: 1
Reputation: 33
not the most elegant of solutions, but I'm just encapsulating the waf deployment process into a function deploy:
def deploy(bld):
import os
os.system('waf distclean configure build_docs custom_func')
Upvotes: -1