是否有更好/更短的方法来创建这两个可以处理多个文件的任务?
我更希望new_task_generator
而不是神秘的课程。
Files = ["src1.c", "src2.c"]
for File in Files:
bld.new_task_gen(
name = "Proc1_task",
source = File,
target= File + ".p1",
rule ="Proc1.exe ${SRC} > ${TGT}")
for File in Files:
bld.new_task_gen(
name = "Proc2_task",
after = "Proc1_task", # not parallel with Proc1_task
source = File,
target= File + ".p2",
rule ="Proc2.exe ${SRC} > ${TGT}")
Proc1.exe
和Proc2.exe
每次通话只接受一个文件。
答案 0 :(得分:2)
如果您的源文件具有特定的扩展名,如.c,最简单的方法是为此扩展添加一个钩子:
@extension('.c')
def process_my_extension(self, node):
task1 = self.create_task("task1", node, node.change_ext(".p1"))
task2 = self.create_task("task2", node, node.change_ext(".p2"))
task2.set_run_after(task1)
class task1_task(Task.Task):
run_str = "Proc1.exe ${SRC} > ${TGT}"
ext_in = ['.c']
ext_out = ['.p1']
class task2_task(Task.Task):
run_str = "Proc2.exe ${SRC} > ${TGT}"
ext_in = ['.c']
ext_out = ['.p2']
最好是在你的主wscript中加载的特定文件(mytool.py)中执行此操作:
def configure(conf):
conf.load("mytool", tooldir = ".") # load your mytool.py
def build(bld):
bld(
source = ["src1.c", "src2.c", ],
)