【问题标题】:Best way to handle multiple configuration matrix with rake?用 rake 处理多个配置矩阵的最佳方法?
【发布时间】:2009-12-28 22:36:33
【问题描述】:

我有一个应用程序可以在 2 种配置(Company1 或 Company2)中的一种中构建,并且可以处于调试或发布模式。

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 任务,一切都依赖于它,但那又如何呢?我可以让 company1 和 company2 任务简单地设置一些变量来说明应该做什么,然后是什么触发了实际的复制活动?

我刚刚开始使用 rake 和 ruby​​,所以任何一般性建议都值得赞赏。

【问题讨论】:

    标签: build-process rake


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-14
      • 1970-01-01
      • 2014-08-13
      相关资源
      最近更新 更多