我怎样写一个自定义编译器WAF文件? [英] How do I write a waf file for a custom compiler?
问题描述
我生病的仰视中进行的魔法符号,并决定尝试 WAF 一>
I got sick of looking up the magic symbols in make and decided to try waf.
我试图使用口径使电子书和我想创建一个WScript的是发生在一个文件中,运行的一些参数,包括该文件的程序,并产生一个输出。如果输入文件大于输出新WAF应该只建立。
I'm trying to use calibre to make ebooks and I'd like to create a wscript that takes in a file, runs a program with some arguments that include that file, and produces an output. Waf should only build if the input file is newer than the output.
在化妆,我会写一个makefile是这样的:
In make, I'd write a makefile like this:
%.epub: %.recipe
ebook-convert $ .epub --test -vv --debug-pipeline debug
其中,%是文件的基本名称和$一个符号输出文件名(basename.epub)魔法符号。
Where % is a magic symbol for the basename of the file and $ a symbol for the output filename (basename.epub).
我可以打电话给使soverflow.epub
,它将运行在soverflow.recipe电子书-转换。如果.recipe没有上次编译改变,它不会做任何事情。
I could call make soverflow.epub
and it would run ebook-convert on soverflow.recipe. If the .recipe hadn't changed since the last build, it wouldn't do anything.
如何能做到在WAF类似的事情?
How can I do something similar in waf?
(WAF为什么呢?因为它使用的是我已经知道了。如果这是真的很容易在scons的使用真正的语言,这是一个很好的答案了。)
(Why waf? Because it uses a real language that I already know. If this is really easy to use in scons, that's a good answer too.)
推荐答案
我想出如何使一个基本的WScript的文件,但我不知道如何建立在命令行中指定的目标。
I figured out how to make a basic wscript file, but I don't know how to build targets specified on the command-line.
WAF的书对任务发电机一节。在<一个href=\"http://docs.waf.google$c$c.com/git/book_16/single.html#_name_and_extension_based_file_processing\"相对=nofollow的名称和基于扩展名的文件处理部分给出了LUA,我适应一个例子:
The Waf Book has a section on Task generators. The Name and extension-based file processing section gives an example for lua that I adapted:
from waflib import TaskGen
TaskGen.declare_chain(
rule = 'ebook-convert ${SRC} .epub --test -vv --debug-pipeline debug',
ext_in = '.recipe',
ext_out = '.epub'
)
top = '.'
out = 'build'
def configure(conf):
pass
def build(bld):
bld(source='soverflow.recipe')
它甚至会自动提供一个清洁的步骤,删除EPUB。
It even automatically provides a clean step that removes the epub.
这篇关于我怎样写一个自定义编译器WAF文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!