views:

36

answers:

1

I have an application that can be built in one of 2 configurations (Company1 or Company2) and in debug or release mode.

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

I'm at a bit of a loss how to best model this matrix of dependencies in my rake file. I would like to be able to simply do:

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

but cant quite figure out how to do this.

Obviously I have a build_and_output_core task that everything depends on, but then what? I can have the company1 and company2 tasks simply set some variables as to what should be done but then what triggers the actual copy activity?

I'm just getting started with both rake and ruby so any general advice is appreciated.

+1  A: 

I would make two namespaces with the same code in, like the following code. If the number of companies grows beyond 10 companies I would start consider not making namespaces.

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
neoneye