# -*- mode: ruby; coding: utf-8 -*- namespace :lib do name = NAME outname = "lib#{name}.a" out = File.join LIBDIR, outname erbs = convertions glob("**/*.erb"), {".erb" => ""} headers = glob("include/**/*.h") | erbs.values.grep(/\.h$/) srcs = glob("src/**/*.cpp") | erbs.values.grep(/\.cpp$/) objs = convertions srcs, {".cpp" => ".o"} tmps = objs.values | erbs.values task :build => out task :compile => objs.values task :erb => erbs.values task :clean do sh %( rm -rf #{tmps.join " "} #{out} ) end file out => objs.values do sh %( #{AR} #{ARFLAGS} #{out} #{objs.values.join " "} ) end objs.each do |(src, obj)| incdirs = INCDIRS.map{|s| " -I#{s}"}.join file obj => [src] + erbs.values do sh %( #{CC} -c #{CFLAGS} #{incdirs} -o #{obj} #{src} ) end end erbs.each do |(erb, out)| file out => [erb] + RBS do print "#{erb}: compiling to #{out}..." compile erb, out puts "ok" end end end# :lib