preserve .mf dependency files - close #58

This commit is contained in:
Josh Holtrop 2019-01-01 21:17:28 -05:00
parent 918c629435
commit 9f9b7f0bf4
4 changed files with 9 additions and 3 deletions

View File

@ -93,6 +93,7 @@ module Rscons
v.nil? and raise "Error: unknown input file type: #{sources.first.inspect}" v.nil? and raise "Error: unknown input file type: #{sources.first.inspect}"
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'])
# Store vars back into options so new keys are accessible in #finalize. # Store vars back into options so new keys are accessible in #finalize.
options[:vars] = vars 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)
@ -109,7 +110,6 @@ module Rscons
target, deps, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars) target, deps, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
if File.exists?(vars['_DEPFILE']) if File.exists?(vars['_DEPFILE'])
deps += Environment.parse_makefile_deps(vars['_DEPFILE']) deps += Environment.parse_makefile_deps(vars['_DEPFILE'])
FileUtils.rm_f(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

View File

@ -33,6 +33,7 @@ module Rscons
"_SOURCES" => sources, "_SOURCES" => sources,
"_DEPFILE" => Rscons.set_suffix(target, env.expand_varref("${DEPFILESUFFIX}", 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'])
# Store vars back into options so new keys are accessible in #finalize. # Store vars back into options so new keys are accessible in #finalize.
options[:vars] = vars options[:vars] = vars
standard_threaded_build("#{name} #{target}", target, command, sources, env, cache) standard_threaded_build("#{name} #{target}", target, command, sources, env, cache)
@ -49,7 +50,6 @@ module Rscons
target, deps, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars) target, deps, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
if File.exists?(vars['_DEPFILE']) if File.exists?(vars['_DEPFILE'])
deps += Environment.parse_makefile_deps(vars['_DEPFILE']) deps += Environment.parse_makefile_deps(vars['_DEPFILE'])
FileUtils.rm_f(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

View File

@ -78,6 +78,7 @@ module Rscons
v.nil? and raise "Error: unknown input file type: #{sources.first.inspect}" v.nil? and raise "Error: unknown input file type: #{sources.first.inspect}"
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'])
# Store vars back into options so new keys are accessible in #finalize. # Store vars back into options so new keys are accessible in #finalize.
options[:vars] = vars 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)
@ -94,7 +95,6 @@ module Rscons
target, deps, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars) target, deps, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
if File.exists?(vars['_DEPFILE']) if File.exists?(vars['_DEPFILE'])
deps += Environment.parse_makefile_deps(vars['_DEPFILE']) deps += Environment.parse_makefile_deps(vars['_DEPFILE'])
FileUtils.rm_f(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

View File

@ -594,6 +594,12 @@ module Rscons
rv = builder.run(build_operation) rv = builder.run(build_operation)
end end
(@side_effects[build_operation[:target]] || []).each do |side_effect_file|
# Register side-effect files as build targets so that a Cache clean
# operation will remove them.
cache.register_build(side_effect_file, nil, [], self)
end
if rv.is_a?(ThreadedCommand) if rv.is_a?(ThreadedCommand)
# Store the build operation so the post-build hooks can be called # Store the build operation so the post-build hooks can be called
# with it when the threaded command completes. # with it when the threaded command completes.