Builder.produces? checks both target and source file names

This commit is contained in:
Josh Holtrop 2013-06-27 21:02:50 -04:00
parent 44d57881c2
commit 46c50049aa
3 changed files with 7 additions and 6 deletions

View File

@ -1,6 +1,6 @@
module Rscons module Rscons
class Builder class Builder
def self.produces?(env, suffix) def self.produces?(env, target, source)
false false
end end
end end

View File

@ -6,13 +6,13 @@ module Rscons
'CFLAGS' => [], 'CFLAGS' => [],
'CPPFLAGS' => [], 'CPPFLAGS' => [],
'OBJSUFFIX' => '.o', 'OBJSUFFIX' => '.o',
'CEXTS' => ['.c'], 'CSUFFIX' => ['.c'],
'CCCOM' => ['$CC', '-c', '-o', '$TARGET', '$CPPFLAGS', '$CFLAGS', '$SOURCES'] 'CCCOM' => ['$CC', '-c', '-o', '$TARGET', '$CPPFLAGS', '$CFLAGS', '$SOURCES']
} }
end end
def self.produces?(env, suffix) def self.produces?(env, target, source)
suffix == env['OBJSUFFIX'] target =~ /#{env['OBJSUFFIX']}$/ and env['CSUFFIX'].find {|ext| source =~ /#{ext}$/}
end end
def run(env, target, source) def run(env, target, source)

View File

@ -19,10 +19,11 @@ module Rscons
if source =~ /#{env['OBJSUFFIX']}$/ or source =~ /#{env['LIBSUFFIX']}$/ if source =~ /#{env['OBJSUFFIX']}$/ or source =~ /#{env['LIBSUFFIX']}$/
source source
else else
builder_class = env.builders.values.find { |klass| klass.produces?(env, env['OBJSUFFIX']) } o_file = env.stem(source) + env['OBJSUFFIX']
builder_class = env.builders.values.find { |klass| klass.produces?(env, o_file, source) }
if builder_class if builder_class
builder = builder_class.new builder = builder_class.new
builder.run(env, env.stem(source) + env['OBJSUFFIX'], source) builder.run(env, o_file, source)
else else
raise "No builder found to convert input source #{source.inspect} to an object file." raise "No builder found to convert input source #{source.inspect} to an object file."
end end