summaryrefslogtreecommitdiff
path: root/lib/rake/loaders/makefile.rb
diff options
context:
space:
mode:
authorjim <jim@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-21 03:22:43 +0000
committerjim <jim@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-21 03:22:43 +0000
commit79f9b6c2cbfbd1231815e7323cedfd769f99c64b (patch)
tree21888e10d241e2d60f3904fe18ed030489663b2f /lib/rake/loaders/makefile.rb
parent9fbc6596ccf089a26ec7c38e2837b667790edbf6 (diff)
Added Rake 0.8.0
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rake/loaders/makefile.rb')
-rw-r--r--lib/rake/loaders/makefile.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/rake/loaders/makefile.rb b/lib/rake/loaders/makefile.rb
new file mode 100644
index 00000000000..f66eb3b35f7
--- /dev/null
+++ b/lib/rake/loaders/makefile.rb
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+
+module Rake
+
+ # Makefile loader to be used with the import file loader.
+ class MakefileLoader
+
+ # Load the makefile dependencies in +fn+.
+ def load(fn)
+ buffer = ''
+ open(fn) do |mf|
+ mf.each do |line|
+ next if line =~ /^\s*#/
+ buffer << line
+ if buffer =~ /\\$/
+ buffer.sub!(/\\\n/, ' ')
+ state = :append
+ else
+ process_line(buffer)
+ buffer = ''
+ end
+ end
+ end
+ process_line(buffer) if buffer != ''
+ end
+
+ private
+
+ # Process one logical line of makefile data.
+ def process_line(line)
+ file_task, args = line.split(':')
+ return if args.nil?
+ dependents = args.split
+ file file_task => dependents
+ end
+ end
+
+ # Install the handler
+ Rake.application.add_loader('mf', MakefileLoader.new)
+end