From 9f9b7f0bf4b1da8008427f99af7061971c540d6a Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 1 Jan 2019 21:17:28 -0500 Subject: [PATCH] preserve .mf dependency files - close #58 --- lib/rscons/builders/object.rb | 2 +- lib/rscons/builders/preprocess.rb | 2 +- lib/rscons/builders/shared_object.rb | 2 +- lib/rscons/environment.rb | 6 ++++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/rscons/builders/object.rb b/lib/rscons/builders/object.rb index 663bad1..f6ca90e 100644 --- a/lib/rscons/builders/object.rb +++ b/lib/rscons/builders/object.rb @@ -93,6 +93,7 @@ module Rscons v.nil? and raise "Error: unknown input file type: #{sources.first.inspect}" end.first 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. options[:vars] = vars 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) if File.exists?(vars['_DEPFILE']) deps += Environment.parse_makefile_deps(vars['_DEPFILE']) - FileUtils.rm_f(vars['_DEPFILE']) end cache.register_build(target, options[:tc].command, deps.uniq, env) target diff --git a/lib/rscons/builders/preprocess.rb b/lib/rscons/builders/preprocess.rb index a51dc33..f3fd943 100644 --- a/lib/rscons/builders/preprocess.rb +++ b/lib/rscons/builders/preprocess.rb @@ -33,6 +33,7 @@ module Rscons "_SOURCES" => sources, "_DEPFILE" => Rscons.set_suffix(target, env.expand_varref("${DEPFILESUFFIX}", 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. options[:vars] = vars 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) if File.exists?(vars['_DEPFILE']) deps += Environment.parse_makefile_deps(vars['_DEPFILE']) - FileUtils.rm_f(vars['_DEPFILE']) end cache.register_build(target, options[:tc].command, deps.uniq, env) target diff --git a/lib/rscons/builders/shared_object.rb b/lib/rscons/builders/shared_object.rb index 2c1cdff..8c864ee 100644 --- a/lib/rscons/builders/shared_object.rb +++ b/lib/rscons/builders/shared_object.rb @@ -78,6 +78,7 @@ module Rscons v.nil? and raise "Error: unknown input file type: #{sources.first.inspect}" end.first 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. options[:vars] = vars 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) if File.exists?(vars['_DEPFILE']) deps += Environment.parse_makefile_deps(vars['_DEPFILE']) - FileUtils.rm_f(vars['_DEPFILE']) end cache.register_build(target, options[:tc].command, deps.uniq, env) target diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index 3deaf19..634f87b 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -594,6 +594,12 @@ module Rscons rv = builder.run(build_operation) 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) # Store the build operation so the post-build hooks can be called # with it when the threaded command completes.