我正在尝试弄清楚如何将整个waf部署过程封装到一个waf函数中
传统网站管家部署流程:
waf distclean configure build将其放入wscript函数中,该函数允许我调用所有这三个waf选项:
waf deploywscript中的函数:
def deploy(bld):
""" Performs waf distclean, configure and build
Args:
bld: The waf build context object
"""
#somehow call waf distclean, configure and build要求:我不能用shell别名来做这件事;它必须在wscript和python中;
我检查了https://waf.io,找不到调用waf configure的方法:(
发布于 2018-10-08 23:33:48
另一种解决方案是使用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发布于 2020-06-18 22:38:49
(我知道这个问题很过时;但是,这个问题仍然是对这个问题的最高建议之一。)
不幸的是,你不能使用'distclean‘来实现这一点,因为这个命令也会删除./waf下载的本地waflib。
(注:这个我不太确定,网站管家的威力每天都会给我惊喜)
然而,你可以选择简单的“干净”:
def deploy(ctx):
from waflib import Build
cctx = Build.CleanContext()
cctx.execute()这似乎工作得很好。当我们这样做的时候:
如果计划构建多个配置/变量/环境(即Debug vs Release),您可以使用以下小工具:
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()发布于 2016-10-10 12:17:44
不是最优雅的解决方案,但我只是将waf部署过程封装到一个功能部署中:
def deploy(bld):
import os
os.system('waf distclean configure build_docs custom_func')https://stackoverflow.com/questions/39948702
复制相似问题