pass environment to builder functions instead of as an initialization parameter

This commit is contained in:
josh committed 2013-07-15 21:41:33 -04:00
1 parent bcfeadeebf
commit c9f6bdb2e2
5 files changed
+19 -21

No files matched your search

+6 -6
View File
@@ -13,22 +13,22 @@ module Rscons
}
end
def produces?(target, source)
target.has_suffix?(@env['OBJSUFFIX']) and source.has_suffix?(@env['CSUFFIX'])
def produces?(target, source, env)
target.has_suffix?(env['OBJSUFFIX']) and source.has_suffix?(env['CSUFFIX'])
end
def run(target, sources, cache)
def run(target, sources, cache, env)
vars = {
'TARGET' => target,
'SOURCES' => sources,
'DEPFILE' => target.set_suffix('.mf'),
}
command = @env.build_command(@env['CCCOM'], vars)
command = env.build_command(env['CCCOM'], vars)
unless cache.up_to_date?(target, command, sources)
return false unless @env.execute("CC #{target}", command)
return false unless env.execute("CC #{target}", command)
deps = sources
if File.exists?(vars['DEPFILE'])
deps += @env.parse_makefile_deps(vars['DEPFILE'], target)
deps += env.parse_makefile_deps(vars['DEPFILE'], target)
FileUtils.rm_f(vars['DEPFILE'])
end
cache.register_build(target, command, deps.uniq)
+8 -8
View File
@@ -12,27 +12,27 @@ module Rscons
}
end
def run(target, sources, cache)
def run(target, sources, cache, env)
# convert sources to object file names
sources = sources.map do |source|
if source.has_suffix?([@env['OBJSUFFIX'], @env['LIBSUFFIX']])
if source.has_suffix?([env['OBJSUFFIX'], env['LIBSUFFIX']])
source
else
o_file = @env.get_build_fname(source, @env['OBJSUFFIX', :string])
builder = @env.builders.values.find { |b| b.produces?(o_file, source) }
o_file = env.get_build_fname(source, env['OBJSUFFIX', :string])
builder = env.builders.values.find { |b| b.produces?(o_file, source, env) }
builder or raise "No builder found to convert input source #{source.inspect} to an object file."
builder.run(o_file, [source], cache) or break
builder.run(o_file, [source], cache, env) or break
end
end
if sources
vars = {
'TARGET' => target,
'SOURCES' => sources,
'LD' => @env['LD'] || @env['CC'], # TODO: figure out whether to use CC or CXX
'LD' => env['LD'] || env['CC'], # TODO: figure out whether to use CC or CXX
}
command = @env.build_command(@env['LDCOM'], vars)
command = env.build_command(env['LDCOM'], vars)
unless cache.up_to_date?(target, command, sources)
return false unless @env.execute("LD #{target}", command)
return false unless env.execute("LD #{target}", command)
cache.register_build(target, command, sources)
end
target