問題:
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?