2009-12-28 62 views
1

我有一個應用程序可以建立在2個配置(公司1或公司2)之一,並在調試或釋放模式。使用rake處理多個配置矩陣的最佳方法?

Company1 Release 
    All builds done with the Release compiler flag 
    Build and output core dll files to build directory 
    Build and output Company1Plugin.dll to build directory 
    Copy tools\templates\log4net.config to build directory 
    Copy tools\templates\Company1.MyApp.exe.config to build directory 
Company1 Debug 
    All builds done with the Debug compiler flag 
    Build and output core dll files to build directory 
    Build and output Company1Plugin.dll to build directory 
    Build and output MyApp.Debug.dll to build directory 
    Copy tools\Growl\log4net.GrowlAppender to build directory 
    Copy tools\templates\debug.log4net.config to build directory 
    Copy tools\templates\debug.Company1.MyApp.exe.config to build directory 
Company2 Release 
    All builds done with the Release compiler flag 
    Build and output core dll files to build directory 
    Build and output Company2Plugin.dll to build directory 
    Build and output PrintingUtility.dll to build directory 
    Copy tools\templates\log4net.config to build directory 
    Copy tools\templates\Company2.MyApp.exe.config to build directory 
Company2 Debug 
    All builds done with the Debug compiler flag 
    Build and output core dll files to build directory 
    Build and output Company2Plugin.dll to build directory 
    Build and output PrintingUtility.dll to build directory 
    Build and output MyApp.Debug.dll to build directory 
    Copy tools\Growl\log4net.GrowlAppender to build directory 
    Copy tools\templates\debug.log4net.config to build directory 
    Copy tools\templates\debug.Company2.MyApp.exe.config to build directory 

我有點損失如何在我的rake文件中對這種依賴關係矩陣進行最佳建模。 我想能夠簡單地做:

rake company1 #(release is the default) 
rake company1 release 
rake company2 debug 

,但不能完全弄清楚如何做到這一點。

很明顯,我有一個build_and_output_core任務,一切都依賴於,但那又如何?我可以讓公司1和公司2的任務簡單地設置一些變量,關於應該做什麼,但是什麼觸發了實際的複製活動?

我剛剛開始使用耙和紅寶石,所以任何一般建議表示讚賞。

回答

1

我會用相同的代碼在兩個命名空間,如下面的代碼。如果公司數量超過10家公司,我會開始考慮不製作名稱空間。

def do_stuff(company, mode) 
    # do stuff 
end 

namespace :company1 do 

task :build_debug do 
    do_stuff("company1", :debug) 
end 

task :build_release do 
    do_stuff("company1", :release) 
end 

task :bd => :build_debug 
task :br => :build_release 

end #namespace company1 


namespace :company2 do 

task :build_debug do 
    do_stuff("company2", :debug) 
end 

task :build_release do 
    do_stuff("company2", :release) 
end 

task :bd => :build_debug 
task :br => :build_release 

end #namespace company2 
相關問題