fill in CC, Program, Environment.process() to get simple builds working
This commit is contained in:
1 parent
5634b8856d
commit
760f698963
6 files changed
+151
-10
No files matched your search
@@ -1,19 +1,38 @@
|
||||
module Rscons
|
||||
class Program < Builder
|
||||
def default_variables
|
||||
def default_variables(env)
|
||||
{
|
||||
'CC' => 'gcc',
|
||||
'CFLAGS' => [],
|
||||
'CPPFLAGS' => [],
|
||||
'LD' => nil,
|
||||
'OBJSUFFIX' => '.o',
|
||||
'CSUFFIX' => '.c',
|
||||
'CCDEPGEN' => ['-MMD', '-MF', '$DEPFILE'],
|
||||
'CCCOM' => ['$CC', '-c', '-o', '$TARGET', '$CCDEPGEN', '$CPPFLAGS', '$CFLAGS', '$SOURCES']
|
||||
'LIBSUFFIX' => '.a',
|
||||
'LDFLAGS' => [],
|
||||
'LIBPATHS' => [],
|
||||
'LIBS' => [],
|
||||
'LDCOM' => ['$LD', '-o', '$TARGET', '$LDFLAGS', '$SOURCES', '-L$[LIBPATHS]', '-l$[LIBS]']
|
||||
}
|
||||
end
|
||||
|
||||
def produces?(target, source)
|
||||
target.has_suffix?(@env['OBJSUFFIX']) and source.has_suffix?(@env['CSUFFIX'])
|
||||
def run(target, sources, cache)
|
||||
# convert sources to object file names
|
||||
sources = sources.map do |source|
|
||||
if source.has_suffix?([@env['OBJSUFFIX'], @env['LIBSUFFIX']])
|
||||
source
|
||||
else
|
||||
o_file = source.set_suffix(@env['OBJSUFFIX', :string])
|
||||
builder = @env.builders.values.find { |b| b.produces?(o_file, source) }
|
||||
builder or raise "No builder found to convert input source #{source.inspect} to an object file."
|
||||
builder.run(o_file, [source], cache)
|
||||
end
|
||||
end
|
||||
unless cache.up_to_date?(target, sources)
|
||||
vars = {
|
||||
'TARGET' => target,
|
||||
'SOURCES' => sources,
|
||||
'LD' => @env['LD'] || @env['CC'], # TODO: figure out whether to use CC or CXX
|
||||
}
|
||||
@env.execute("LD #{target}", @env['LDCOM'], vars)
|
||||
end
|
||||
target
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user