Skip to content

Commit

Permalink
Fixed Makefile dependency bug. Added makefile dependency reading perf…
Browse files Browse the repository at this point in the history
…ormance patch.

git-svn-id: svn+ssh://rubyforge.org/var/svn/rake/trunk@670 5af023f1-ac1a-0410-98d6-829a145c37ef
  • Loading branch information
jimweirich committed Aug 11, 2008
1 parent 9d6c5b8 commit b90c0d0
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 16 deletions.
1 change: 1 addition & 0 deletions .#dep.patch
11 changes: 9 additions & 2 deletions CHANGES
Expand Up @@ -18,7 +18,7 @@
Emanuel Inderm�hle)

* Switched from getoptlong to optparse (patches supplied by Edwin
Pratomo (edpratomo@yahoo.co.id))
Pratomo)

* The -T option will now attempt to dynamically sense the size of the
terminal. RAKE_COLUMNS will override any dynamic sensing.
Expand All @@ -35,7 +35,14 @@
easier for the tempate to pick up the template from the environment.

* Changed from using Mutex to Monitor. Evidently Mutex causes thread
join errors when Ruby is compiled with -disable-pthreads.
join errors when Ruby is compiled with -disable-pthreads. (Patch
supplied by Ittay Dror)

* Fixed bug in makefile parser that had problems with extra spaces in
file task names. (Patch supplied by Ittay Dror)

* Added a performance patch for reading large makefile dependency
files. (Patch supplied by Ittay Dror)

== Version 0.8.1

Expand Down
23 changes: 23 additions & 0 deletions dep.patch
@@ -0,0 +1,23 @@
--- rake/loaders/makefile.rb.orig 2008-07-22 19:01:11.000000000 +0300
+++ rake/loaders/makefile.rb 2008-07-22 19:27:03.000000000 +0300
@@ -9,16 +9,10 @@
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
+ lines = mf.read
+ lines.gsub!(/\\\n/, ' ')
+ lines.split("\n").each do |line|
+ process_line line
end
end
process_line(buffer) if buffer != ''
18 changes: 6 additions & 12 deletions lib/rake/loaders/makefile.rb
Expand Up @@ -7,21 +7,14 @@ 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
lines = mf.read
lines.gsub!(/#[^\n]*\n/m, "")
lines.gsub!(/\\\n/, ' ')
lines.split("\n").each do |line|
process_line(line)
end
end
process_line(buffer) if buffer != ''
end

private
Expand All @@ -30,6 +23,7 @@ def load(fn)
def process_line(line)
file_task, args = line.split(':')
return if args.nil?
file_task.strip!
dependents = args.split
file file_task => dependents
end
Expand Down
3 changes: 2 additions & 1 deletion test/data/sample.mf
Expand Up @@ -4,6 +4,7 @@ b: b1 b2 b3 \
b4 b5 b6\
# Mid: Comment
b7
a: a5 a6 a7

a : a5 a6 a7
c: c1
d: d1 d2 \
2 changes: 1 addition & 1 deletion test/test_makefile_loader.rb
Expand Up @@ -7,7 +7,7 @@
class TestMakefileLoader < Test::Unit::TestCase
include Rake

def test_create
def test_parse
Task.clear
loader = Rake::MakefileLoader.new
loader.load("test/data/sample.mf")
Expand Down

0 comments on commit b90c0d0

Please sign in to comment.