问题:
I have a Rakefile that compiles the project in two ways, according to the global variable $build_type
, which can be :debug
or :release
(the results go in separate directories):我有一个 Rakefile,它根据全局变量$build_type
以两种方式编译项目,它可以是:debug
或:release
(结果在单独的目录中):
task :build => [:some_other_tasks] do
end
I wish to create a task that compiles the project with both configurations in turn, something like this:我希望创建一个任务,依次使用两种配置编译项目,如下所示:
task :build_all do
[ :debug, :release ].each do |t|
$build_type = t
# call task :build with all the tasks it depends on (?)
end
end
Is there a way to call a task as if it were a method?有没有办法像调用方法一样调用任务? Or how can I achieve anything similar?或者我怎样才能实现类似的目标?
解决方案:
参考一: https://stackoom.com/question/2QLg参考二: How to run Rake tasks from within Rake tasks?