pass extra variables into Environment.execute()

This commit is contained in:
Josh Holtrop 2013-06-26 21:32:08 -04:00
parent 116406c74d
commit 0f3a6accd7
3 changed files with 13 additions and 4 deletions

View File

@ -23,7 +23,11 @@ module Rscons
'-o', o_file,
source
]
env.execute("CC #{o_file}", command)
vars = {
'TARGET' => o_file,
'SOURCES' => source,
}
env.execute("CC #{o_file}", command, vars)
Cache.open.register_build(target, [source])
end
o_file

View File

@ -34,7 +34,11 @@ module Rscons
*env['LIBPATHS'].map {|lp| "-L#{lp}"},
*env['LIBS'].map {|lib| "-l#{lib}"}
]
env.execute("LINK #{target}", command)
vars = {
'TARGET' => target,
'SOURCES' => sources,
}
env.execute("LINK #{target}", command, vars)
Cache.open.register_build(target, sources)
end
target

View File

@ -47,7 +47,8 @@ module Rscons
@build_dirs[src_dir] = build_dir
end
def execute(short_desc, command)
def execute(short_desc, command, extra_vars)
merged_variables = @variables.merge(extra_vars)
expand_varref = proc do |varref|
if varref.is_a?(Array)
varref.map do |ent|
@ -56,7 +57,7 @@ module Rscons
else
if varref[0] == '$'
varname = varref[1, varref.size]
varval = self[varname]
varval = merged_variables[varname]
if varval
expand_varref.call(varval)
else