Skip to content

Instantly share code, notes, and snippets.

Created April 28, 2013 05:52
Show Gist options
  • Save anonymous/154a5a5751a4d90b5ada to your computer and use it in GitHub Desktop.
Save anonymous/154a5a5751a4d90b5ada to your computer and use it in GitHub Desktop.
def btask(*args, &block)
@CONF.each do |conf|
config = BtaskConfiguration.new
block.call(config) unless block.nil?
objs = []
name = "#{args[0].keys[0]}:#{conf}"
config.name = name
puts "#{config.name} = #{name}"
args.each { |arg|
arg.values.each { |deps|
deps.each { |dep|
if Rake::Task.task_defined? dep then
task name => dep
else
puts "#{config.name} = #{name}"
obj = dep.to_s.sub(/\.(?:cxx|c|cpp)$/, '.o')
dir = "obj/#{conf}"
objpath = "#{dir}/#{obj}"
objdir = File.split(objpath)[0]
objs.push objpath
mf = obj.sub(/\.o/, '.mf')
CLEAN.include(mf)
`#{config.depends(mf, objpath, dep)}`
import mf
directory dir
directory objdir
file objpath => [dep, dir, objdir] do |t|
sh config.compile(objpath, t.prerequisites)
end
if args[0].class == Hash then
puts "Defining task #{name}"
CLEAN.include name
puts "DEPS: #{deps}"
Rake::Task.define_task name => [mf, objpath, dir, objdir]
else
puts "TODO: Define #{args[0]}"
end
end
}
}
}
puts "#{config.name} = #{name}"
Rake::Task.define_task name do |t|
puts "#{config.name} = #{name}"
puts "Running task #{name}, which is #{config.name}"
if config.exe? then
sh config.link(name.sub(':', '-'), t.prerequisites[1..-1])
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment