summaryrefslogtreecommitdiffhomepage
path: root/tasks/rules.rake
diff options
context:
space:
mode:
authorYuichiro MASUI <[email protected]>2012-12-29 05:37:55 +0900
committerYuichiro MASUI <[email protected]>2013-01-03 02:24:15 +0900
commit7c469c0b9dadd1de09fed18c3e5cc551012c38c1 (patch)
treeb79aa703ef7c528896c4f1be8280d0691314008b /tasks/rules.rake
parenta48fc0d7952ad1f10ae777637269fe6a3f9ad0a2 (diff)
downloadmruby-7c469c0b9dadd1de09fed18c3e5cc551012c38c1.tar.gz
mruby-7c469c0b9dadd1de09fed18c3e5cc551012c38c1.zip
Rebuild CRuby based building script without Makefile
Tested CRuby 1.8.6 and 1.9.3 You can see building configuration in build_config.rb
Diffstat (limited to 'tasks/rules.rake')
-rw-r--r--tasks/rules.rake41
1 files changed, 41 insertions, 0 deletions
diff --git a/tasks/rules.rake b/tasks/rules.rake
new file mode 100644
index 000000000..f53f3bccd
--- /dev/null
+++ b/tasks/rules.rake
@@ -0,0 +1,41 @@
+def get_dependencies(file)
+ file = file.pathmap('%n.d') unless File.extname(file) == '.d'
+ if File.exists?(file)
+ File.read(file).gsub("\\\n ", "").scan(/^\S+:\s+(.+)$/).flatten.map {|s| s.split(' ') }.flatten
+ else
+ []
+ end
+end
+
+MRuby.each_target do |t|
+ obj_matcher = Regexp.new("^#{build_dir}/(.*)\\.o$")
+ {
+ '.c' => proc { |t| compile_c t.name, t.prerequisites.first },
+ '.cpp' => proc { |t| compile_cxx t.name, t.prerequisites.first },
+ '.m' => proc { |t| compile_objc t.name, t.prerequisites.first },
+ '.S' => proc { |t| compile_asm t.name, t.prerequisites.first }
+ }.each do |ext, compile|
+ rule obj_matcher => [
+ proc { |file|
+ file.sub(obj_matcher, "\\1#{ext}")
+ },
+ proc { |file|
+ get_dependencies(file)
+ }] do |t|
+ FileUtils.mkdir_p File.dirname(t.name)
+ compile.call t
+ end
+
+ rule obj_matcher => [
+ proc { |file|
+ file.sub(obj_matcher, "#{build_dir}/\\1#{ext}")
+ },
+ proc { |file|
+ get_dependencies(file)
+ }] do |t|
+ FileUtils.mkdir_p File.dirname(t.name)
+ compile.call t
+ end
+ end
+end
+