仅使用单个目标在 waf 中复制多个文件
Copying multiple files in waf using only a single target
waf 书显示我可以创建一个将复制文件的任务生成器:
def build(ctx):
ctx(source='wscript', target='foo.txt', rule='cp ${SRC} ${TGT}')
这将产生一个目标,显示为 waf configure list
,名为 foo.txt
。这样我就可以做这样的事情:
waf configure build --targets=foo.txt
一切都很好。
但是,假设我想复制,比如 200 个文件,全部填充构建目录中的一个目录,我们称该目录为 examples
.
如果我对 200 个文件中的每一个重复此操作,我将有 200 个目标,因此当我键入 waf configure list
时将获得 200 个目标并且 waf configure list
将变得几乎无用,因为输出爆炸
但我真的希望将这 200 个文件的复制作为一个目标,这样我就可以做类似 waf configure build --targets=examples
的事情。我该怎么做???
使用buildcopy
工具:
import buildcopy
...
def build(ctx):
ctx(name = 'copystuff',
features = 'buildcopy',
buildcopy_source = ctx.path.ant_glob('examples/**'))
这将递归地将 examples
目录树复制到 build
目录。只介绍了一个目标copystuff
。
顺便说一句,如果你想复制一个文件:
ctx(features = 'subst',
source = '...', target = '...',
is_copy = True)
比调用系统的cp
命令要好得多。
waf 书显示我可以创建一个将复制文件的任务生成器:
def build(ctx):
ctx(source='wscript', target='foo.txt', rule='cp ${SRC} ${TGT}')
这将产生一个目标,显示为 waf configure list
,名为 foo.txt
。这样我就可以做这样的事情:
waf configure build --targets=foo.txt
一切都很好。
但是,假设我想复制,比如 200 个文件,全部填充构建目录中的一个目录,我们称该目录为 examples
.
如果我对 200 个文件中的每一个重复此操作,我将有 200 个目标,因此当我键入 waf configure list
时将获得 200 个目标并且 waf configure list
将变得几乎无用,因为输出爆炸
但我真的希望将这 200 个文件的复制作为一个目标,这样我就可以做类似 waf configure build --targets=examples
的事情。我该怎么做???
使用buildcopy
工具:
import buildcopy
...
def build(ctx):
ctx(name = 'copystuff',
features = 'buildcopy',
buildcopy_source = ctx.path.ant_glob('examples/**'))
这将递归地将 examples
目录树复制到 build
目录。只介绍了一个目标copystuff
。
顺便说一句,如果你想复制一个文件:
ctx(features = 'subst',
source = '...', target = '...',
is_copy = True)
比调用系统的cp
命令要好得多。