Write dependency file to build directory when user invokes Object builder directly - close #135

This commit is contained in:
Josh Holtrop 2021-11-18 20:18:19 -05:00
parent f011b23499
commit 2ee9dda49d
2 changed files with 13 additions and 3 deletions

View File

@ -75,10 +75,10 @@ module Rscons
@vars["_SOURCES"] = @sources @vars["_SOURCES"] = @sources
depfilesuffix = @env.expand_varref("${DEPFILESUFFIX}", vars) depfilesuffix = @env.expand_varref("${DEPFILESUFFIX}", vars)
@vars["_DEPFILE"] = @vars["_DEPFILE"] =
if @vars[:direct] if @vars[:direct] || !@target.start_with?("#{@env.build_root}/")
@env.get_build_fname(target, depfilesuffix, self.class) @env.get_build_fname(@target, depfilesuffix, self.class)
else else
"#{target}#{depfilesuffix}" "#{@target}#{depfilesuffix}"
end end
@cache.mkdir_p(File.dirname(@vars["_DEPFILE"])) @cache.mkdir_p(File.dirname(@vars["_DEPFILE"]))
command = @env.build_command(@command_template, @vars) command = @env.build_command(@command_template, @vars)

View File

@ -1484,6 +1484,16 @@ EOF
expect(File.exist?("simple.o")).to be_truthy expect(File.exist?("simple.o")).to be_truthy
end end
it "writes the dependency file to the build root" do
test_dir "simple"
result = run_rscons(rsconscript: "distclean.rb")
expect(result.stderr).to eq ""
expect(result.stdout).to match /Compiling simple\.c/
expect(File.exist?("simple.o")).to be_truthy
expect(File.exist?("simple.o.mf")).to be_falsey
expect(File.exist?("build/e.1/simple.o.mf")).to be_truthy
end
context "debugging" do context "debugging" do
it "prints a message when the target does not exist" do it "prints a message when the target does not exist" do
test_dir("simple") test_dir("simple")