fix parsing Makefile dependencies when they spanned multiple lines

This commit is contained in:
Josh Holtrop 2013-08-05 14:27:57 -04:00
parent 3f33336fff
commit 75977981c0
2 changed files with 29 additions and 4 deletions

View File

@ -212,10 +212,11 @@ module Rscons
if line =~ /^(.*)\\\s*$/
buildup += ' ' + $1
else
if line =~ /^(.*): (.*)$/
target, tdeps = $1.strip, $2
if target == target
deps += tdeps.split(' ').map(&:strip)
buildup += ' ' + line
if buildup =~ /^(.*): (.*)$/
mf_target, mf_deps = $1.strip, $2
if mf_target == target
deps += mf_deps.split(' ').map(&:strip)
end
end
buildup = ''

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