fix parsing Makefile dependencies when they spanned multiple lines

This commit is contained in:
josh committed 2013-08-05 14:27:57 -04:00
1 parent 3f33336fff
commit 75977981c0
2 files changed
+29 -4

No files matched your search

+5 -4
View File
@@ -212,10 +212,11 @@ module Rscons
if line =~ /^(.*)\\\s*$/ if line =~ /^(.*)\\\s*$/
buildup += ' ' + $1 buildup += ' ' + $1
else else
if line =~ /^(.*): (.*)$/ buildup += ' ' + line
target, tdeps = $1.strip, $2 if buildup =~ /^(.*): (.*)$/
if target == target mf_target, mf_deps = $1.strip, $2
deps += tdeps.split(' ').map(&:strip) if mf_target == target
deps += mf_deps.split(' ').map(&:strip)
end end
end end
buildup = '' buildup = ''
+24
View File
@@ -0,0 +1,24 @@
module Rscons
describe Environment do
describe '.parse_makefile_deps' do
it 'handles dependencies on one line' do
File.should_receive(:read).with('makefile').and_return(<<EOS)
module.o: source.cc
EOS
env = Environment.new
env.parse_makefile_deps('makefile', 'module.o').should == ['source.cc']
end
it 'handles dependencies split across many lines' do
File.should_receive(:read).with('makefile').and_return(<<EOS)
module.o: module.c \\
module.h \\
other.h
EOS
env = Environment.new
env.parse_makefile_deps('makefile', 'module.o').should == [
'module.c', 'module.h', 'other.h']
end
end
end
end