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
depfilesuffix = @env.expand_varref("${DEPFILESUFFIX}", vars)
@vars["_DEPFILE"] =
if @vars[:direct]
@env.get_build_fname(target, depfilesuffix, self.class)
if @vars[:direct] || !@target.start_with?("#{@env.build_root}/")
@env.get_build_fname(@target, depfilesuffix, self.class)
else
"#{target}#{depfilesuffix}"
"#{@target}#{depfilesuffix}"
end
@cache.mkdir_p(File.dirname(@vars["_DEPFILE"]))
command = @env.build_command(@command_template, @vars)

View File

@ -1484,6 +1484,16 @@ EOF
expect(File.exist?("simple.o")).to be_truthy
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
it "prints a message when the target does not exist" do
test_dir("simple")