use Builder instance variables as much as possible in #finalize

This commit is contained in:
Josh Holtrop 2019-02-16 17:53:21 -05:00
parent 33504f586b
commit 016bf5eac7
3 changed files with 15 additions and 21 deletions

View File

@ -93,8 +93,6 @@ module Rscons
end.first end.first
command = @env.build_command("${#{com_prefix}CMD}", @vars) command = @env.build_command("${#{com_prefix}CMD}", @vars)
@env.produces(@target, @vars["_DEPFILE"]) @env.produces(@target, @vars["_DEPFILE"])
# Store vars back into options so new keys are accessible in #finalize.
options[:vars] = vars
standard_threaded_build("#{com_prefix} #{@target}", @target, command, @sources, @env, @cache) standard_threaded_build("#{com_prefix} #{@target}", @target, command, @sources, @env, @cache)
end end
@ -106,12 +104,12 @@ module Rscons
# Name of the target file on success or nil on failure. # Name of the target file on success or nil on failure.
def finalize(options) def finalize(options)
if options[:command_status] if options[:command_status]
target, deps, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars) deps = @sources
if File.exists?(vars['_DEPFILE']) if File.exists?(@vars['_DEPFILE'])
deps += Util.parse_makefile_deps(vars['_DEPFILE']) deps += Util.parse_makefile_deps(@vars['_DEPFILE'])
end end
cache.register_build(target, options[:tc].command, deps.uniq, env) @cache.register_build(@target, options[:tc].command, deps.uniq, @env)
target @target
end end
end end

View File

@ -33,8 +33,6 @@ module Rscons
@vars["_DEPFILE"] = Rscons.set_suffix(target, env.expand_varref("${DEPFILESUFFIX}", vars)) @vars["_DEPFILE"] = Rscons.set_suffix(target, env.expand_varref("${DEPFILESUFFIX}", vars))
command = @env.build_command("${CPP_CMD}", @vars) command = @env.build_command("${CPP_CMD}", @vars)
@env.produces(@target, @vars["_DEPFILE"]) @env.produces(@target, @vars["_DEPFILE"])
# Store vars back into options so new keys are accessible in #finalize.
options[:vars] = vars
standard_threaded_build("#{name} #{@target}", @target, command, @sources, @env, @cache) standard_threaded_build("#{name} #{@target}", @target, command, @sources, @env, @cache)
end end
@ -46,12 +44,12 @@ module Rscons
# Name of the target file on success or nil on failure. # Name of the target file on success or nil on failure.
def finalize(options) def finalize(options)
if options[:command_status] if options[:command_status]
target, deps, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars) deps = @sources
if File.exists?(vars['_DEPFILE']) if File.exists?(@vars['_DEPFILE'])
deps += Util.parse_makefile_deps(vars['_DEPFILE']) deps += Util.parse_makefile_deps(@vars['_DEPFILE'])
end end
cache.register_build(target, options[:tc].command, deps.uniq, env) @cache.register_build(@target, options[:tc].command, deps.uniq, @env)
target @target
end end
end end

View File

@ -78,8 +78,6 @@ module Rscons
end.first end.first
command = @env.build_command("${#{com_prefix}CMD}", @vars) command = @env.build_command("${#{com_prefix}CMD}", @vars)
@env.produces(@target, @vars["_DEPFILE"]) @env.produces(@target, @vars["_DEPFILE"])
# Store vars back into options so new keys are accessible in #finalize.
options[:vars] = @vars
standard_threaded_build("#{com_prefix} #{@target}", @target, command, @sources, @env, @cache) standard_threaded_build("#{com_prefix} #{@target}", @target, command, @sources, @env, @cache)
end end
@ -91,12 +89,12 @@ module Rscons
# Name of the target file on success or nil on failure. # Name of the target file on success or nil on failure.
def finalize(options) def finalize(options)
if options[:command_status] if options[:command_status]
target, deps, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars) deps = @sources
if File.exists?(vars['_DEPFILE']) if File.exists?(@vars['_DEPFILE'])
deps += Util.parse_makefile_deps(vars['_DEPFILE']) deps += Util.parse_makefile_deps(@vars['_DEPFILE'])
end end
cache.register_build(target, options[:tc].command, deps.uniq, env) @cache.register_build(@target, options[:tc].command, deps.uniq, @env)
target @target
end end
end end