From 1cca20587de5c2c60bc10b5f4ce08dbe1b7a9623 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Fri, 11 Oct 2024 19:45:25 +0200 Subject: [PATCH] Fix deleting files with dependency files --- Makefile | 4 +--- tools/scaninc/scaninc.cpp | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 5eaf4cf0bca3..ee36562b1389 100644 --- a/Makefile +++ b/Makefile @@ -315,10 +315,9 @@ else @echo -e ".text\n\t.align\t2, 0\n" >> $3.s $$(AS) $$(ASFLAGS) -o $$@ $3.s endif +ifneq ($(NODEP),1) $1.d: $2 $(SCANINC) -M $1.d $(INCLUDE_SCANINC_ARGS) -I tools/agbcc/include $2 -ifneq ($(NODEP),1) -$1.o: $1.d -include $1.d endif endef @@ -346,7 +345,6 @@ endef define ASM_SCANINC ifneq ($(NODEP),1) -$1.o: $1.d $1.d: $2 $(SCANINC) -M $1.d $(INCLUDE_SCANINC_ARGS) -I "" $2 -include $1.d diff --git a/tools/scaninc/scaninc.cpp b/tools/scaninc/scaninc.cpp index c1b7987a5a4c..d470a3f163e3 100644 --- a/tools/scaninc/scaninc.cpp +++ b/tools/scaninc/scaninc.cpp @@ -157,19 +157,29 @@ int main(int argc, char **argv) // Print a make rule for the object file size_t ext_pos = make_outfile.find_last_of("."); auto object_file = make_outfile.substr(0, ext_pos + 1) + "o"; - output << object_file.c_str() << ": "; + output << object_file.c_str() << ":"; for (const std::string &path : dependencies) { - output << path << " "; + output << " " << path; } + output << '\n'; // Dependency list rule. // Although these rules are identical, they need to be separate, else make will trigger the rule again after the file is created for the first time. - output << "\n" << make_outfile.c_str() << ": "; + output << make_outfile.c_str() << ":"; for (const std::string &path : dependencies_includes) { - output << path << " "; + output << " " << path; } + output << '\n'; + + // Dummy rules + // If a dependency is deleted, make will try to make it, instead of rescanning the dependencies before trying to do that. + for (const std::string &path : dependencies) + { + output << path << ":\n"; + } + output.flush(); output.close(); }