add support for building D sources (defaulting to gdc)

This commit is contained in:
Josh Holtrop 2013-10-29 16:17:51 -04:00
parent 31abeed3d5
commit c23bb8c5e0
2 changed files with 20 additions and 6 deletions

View File

@ -28,6 +28,12 @@ module Rscons
'CXXSUFFIX' => '.cc', 'CXXSUFFIX' => '.cc',
'CXXDEPGEN' => ['-MMD', '-MF', '$_DEPFILE'], 'CXXDEPGEN' => ['-MMD', '-MF', '$_DEPFILE'],
'CXXCOM' =>['$CXX', '-c', '-o', '$_TARGET', '$CXXDEPGEN', '-I$[CPPPATH]', '$CPPFLAGS', '$CXXFLAGS', '$_SOURCES'], 'CXXCOM' =>['$CXX', '-c', '-o', '$_TARGET', '$CXXDEPGEN', '-I$[CPPPATH]', '$CPPFLAGS', '$CXXFLAGS', '$_SOURCES'],
'DC' => 'gdc',
'DFLAGS' => [],
'DSUFFIX' => '.d',
'D_IMPORT_PATH' => [],
'DCCOM' => ['$DC', '-c', '-o', '$_TARGET', '-I$[D_IMPORT_PATH]', '$DFLAGS', '$_SOURCES'],
} }
end end
@ -35,7 +41,8 @@ module Rscons
target.has_suffix?(env['OBJSUFFIX']) and ( target.has_suffix?(env['OBJSUFFIX']) and (
source.has_suffix?(env['ASSUFFIX']) or source.has_suffix?(env['ASSUFFIX']) or
source.has_suffix?(env['CSUFFIX']) or source.has_suffix?(env['CSUFFIX']) or
source.has_suffix?(env['CXXSUFFIX'])) source.has_suffix?(env['CXXSUFFIX']) or
source.has_suffix?(env['DSUFFIX']))
end end
def run(target, sources, cache, env, vars = {}) def run(target, sources, cache, env, vars = {})
@ -50,6 +57,8 @@ module Rscons
'CC' 'CC'
elsif sources.first.has_suffix?(env['CXXSUFFIX']) elsif sources.first.has_suffix?(env['CXXSUFFIX'])
'CXX' 'CXX'
elsif sources.first.has_suffix?(env['DSUFFIX'])
'DC'
else else
raise "Error: unknown input file type: #{sources.first.inspect}" raise "Error: unknown input file type: #{sources.first.inspect}"
end end

View File

@ -18,14 +18,19 @@ module Rscons
# build sources to linkable objects # build sources to linkable objects
objects = env.build_sources(sources, [env['OBJSUFFIX'], env['LIBSUFFIX']].flatten, cache, vars) objects = env.build_sources(sources, [env['OBJSUFFIX'], env['LIBSUFFIX']].flatten, cache, vars)
if objects if objects
use_cxx = sources.map do |s| ld = if env["LD"]
s.has_suffix?(env['CXXSUFFIX']) env["LD"]
end.any? elsif sources.find {|s| s.has_suffix?(env["DSUFFIX"])}
ld_alt = use_cxx ? env['CXX'] : env['CC'] env["DC"]
elsif sources.find {|s| s.has_suffix?(env["CXXSUFFIX"])}
env["CXX"]
else
env["CC"]
end
vars = vars.merge({ vars = vars.merge({
'_TARGET' => target, '_TARGET' => target,
'_SOURCES' => objects, '_SOURCES' => objects,
'LD' => env['LD'] || ld_alt, 'LD' => ld,
}) })
command = env.build_command(env['LDCOM'], vars) command = env.build_command(env['LDCOM'], vars)
standard_build("LD #{target}", target, command, objects, env, cache) standard_build("LD #{target}", target, command, objects, env, cache)