我正在尝试构建一个静态库,我的名字只能在处理完一些文件后得到。我有这样的事情:
task :lib,:config do |t,args|
# ... do some processing here, get a string representing the
# fullpath of the lib. Imaging libname contains a.lib
file libname => object_files
end
但是,当然,由于在运行任务时我不知道依赖项的名称,因此构建a.lib的代码不会被执行。我试着这样做:
task :lib,:config do |t,args|
# ... do some processing here, get a string representing the
# fullpath of the lib. Imaging libname contains a.lib
file libname => object_files
task :lib => [libname]
end
要将其添加为依赖项,但它不起作用。我现在就这样,它有效:
task :lib,:config do |t,args|
# ... do some processing here, get a string representing the
# fullpath of the lib. Imaging libname contains a.lib
file libname => object_files
Rake.application[libname].invoke
end
但我觉得这太丑了。有没有更好的方法来声明这种依赖?
答案 0 :(得分:3)
我认为这个帖子已经有了最好的答案:How to run Rake tasks from within Rake tasks?
答案 1 :(得分:2)
Rake::Task[libname].invoke
我的眼睛看起来稍微好一点,我认为除了调用.execute或.invoke之外,还有一种方法可以在rake任务中排除rake任务。