32 lines
692 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']}"
command = [
env['CC'],
*env['CPPFLAGS'],
*env['CFLAGS'],
'-o', o_file,
source
]
env.execute("CC #{o_file}", command)
o_file
end
end
end