37 lines
871 B
Ruby

module Rscons
class CC < Builder
VARIABLE_DEFAULTS = {
'CC' => 'gcc',
'CFLAGS' => ['-c'],
'CPPFLAGS' => [],
'OBJSUFFIX' => '.o',
'CEXTS' => ['.c'],
}
def self.produces?(env, suffix)
suffix == env['OBJSUFFIX']
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
]
vars = {
'TARGET' => o_file,
'SOURCES' => source,
}
env.execute("CC #{o_file}", command, vars)
Cache.open.register_build(target, [source])
end
o_file
end
end
end