gpt4 book ai didi

c - Waf:创建自定义并行任务

转载 作者:太空宇宙 更新时间:2023-11-04 02:50:45 25 4
gpt4 key购买 nike

在 Waf 中,我如何创建多个可以并行运行的自定义任务(使用 --jobs=JOBS)?

Sources = ["C:\\src1.c", "C:\\Mod1\src2.c", ... 30pcs] # one per call
Incl_Paths = ["Mod1". "Mod1"] # list all of them in all call
INCL_ST = "-I%s" # how to format an include path in an argument
Ext_out = "_loc" # output file extension

目标:

C:\\LOC.exe -IMod1 -IMod2 C:\\src1.c > build\\src1.c_loc        //or better src1_loc
C:\\LOC.exe -IMod1 -IMod2 C:\\Mod1\src2.c > build\\src2.c_loc //or better src2_loc
...

我无法让它工作

def build(bld):
for i in Sources:
bld.new_task_gen(
source = i,
rule='C:\\LOC.exe ${INCL_ST:Incl_Paths} ${SRC} > ' + i + Ext_out,
)

我也无法提取exe

# find_program(self, filename, path_list=[], var=None, environ=None, exts=''):

cfg.find_program("C:\\LOC.exe", var='LOC')

更改自:

rule='C:\\LOC.exe ...'

收件人:

  rule='${LOC} ...'

最佳答案

像这样的东西应该适用于 waf 1.7:

from waflib.Task import Task
from waflib.TaskGen import extension

Ext_out = "_loc" # output file extension

def configure(conf):
# loc.exe must be in the system path for this to work
conf.find_program(
'loc',
var = "LOC",
)
conf.env.Incl_Paths = ["Mod1", "Mod1"]
conf.env.INCL_ST = "-I%s"

@extension('.c')
def process_loc(self, node):
out_node = node.change_ext(Ext_out)
tsk = self.create_task('loc')
tsk.set_inputs(node)
tsk.set_outputs(out_node)

class loc_task(Task):
ext_in = ['.c']
ext_out = ['_loc']
run_str = "${LOC} ${INCL_ST:Incl_Paths} ${SRC} > ${TGT}"


def build(bld):
bld(source = ["src1.c", "src2.c"])

好吧,它在 linux faking loc 上对我有用 ...

关于c - Waf:创建自定义并行任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22466329/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com