Josh Holtrop 119f3c9f0f Do not rebuild targets when they are up to date
Store dependencies and file checksums in a cache file
2013-06-23 23:21:02 -04:00

35 lines
824 B
Ruby

module Rscons
class CC < Builder
VARIABLE_DEFAULTS = {
'CC' => 'gcc',
'CFLAGS' => ['-c'],
'CPPFLAGS' => [],
'OBJSUFFIX' => '.o',
'CEXTS' => ['.c'],
}
def self.makes_object_file?(env, fname)
env['CEXTS'].find do |cext|
fname =~ /#{cext}$/
end
end
def run(env, target, source)
raise "String expected, not #{source.inspect}" unless source.is_a?(String)
o_file = "#{env.stem(source)}#{env['OBJSUFFIX']}"
unless Cache.open.up_to_date?(target, [source])
command = [
env['CC'],
*env['CPPFLAGS'],
*env['CFLAGS'],
'-o', o_file,
source
]
env.execute("CC #{o_file}", command)
Cache.open.register_build(target, [source])
end
o_file
end
end
end