Ruby Rake的Python端口
项目描述
这是我能够想到的最直接的Rake克隆。
简而言之
# Trawlfile
@task
def bar():
print "BAR!"
做你所期望的
$ trawl -T bar $ trawl bar ** Execute bar BAR
以及依赖关系
# Trawlfile
@task
def bar():
print "BAR!"
@task([bar])
def foo():
print "FOO!"
也做你所期望的
$ trawl -T bar foo $ trawl bar ** Execute bar BAR! $ trawl foo ** Execute bar BAR! ** Execute foo FOO!
这很酷,但文件呢?
# Trawlfile
@build("myfile.txt", recreate=False)
def run(task):
with open(task.name) as out:
out.write("MUNCTIONAL!")
@build("yup.cfg", ["myfile.txt"])
def more(task):
with open(task.name) as out:
with open(task.source) as src:
out.write(src.read() + "!!!1!")
将创建“myfile.txt”,如果存在则不会覆盖。然后“yup.cfg”只有在“myfile.txt”更改时(根据文件的mtime确定)才会重新构建
$ trawl yup.cfg ** Execute myfile.txt ** Execute yup.cfg $ trawl yup.cfg $
最后一项重要工作是定义规则
@rule('.o', '.c'):
def compile(task):
subprocess.check_call(["gcc", "-o", task.name, "-c", task.source])
objects = FileList("*.c").sub(".c$", ".o")
@build("appname", objects)
def link(task):
subprocess.check_call(["gcc", "-o", task.name] + task.sources)
# Add a helpful handle for running
task("run", ["appname"])
待办事项
还有一些事情需要完成
任务描述
参数支持
测试并向FileList添加方法
添加一个函数以编程方式导入任务