From 5942117ac3f6c9cf04cec2d81b37002c26ef5b2c Mon Sep 17 00:00:00 2001 From: Rangi <35663410+Rangi42@users.noreply.github.com> Date: Sun, 29 Jun 2025 16:42:24 -0400 Subject: [PATCH] Avoid generating phony dependencies for files that don't exist (#1708) --- src/asm/fstack.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/asm/fstack.cpp b/src/asm/fstack.cpp index a855f46f..17e30296 100644 --- a/src/asm/fstack.cpp +++ b/src/asm/fstack.cpp @@ -126,20 +126,20 @@ void fstk_SetPreIncludeFile(std::string const &path) { // LCOV_EXCL_STOP } -static void printDep(std::string const &path) { - if (dependFile) { - fprintf(dependFile, "%s: %s\n", targetFileName.c_str(), path.c_str()); - if (generatePhonyDeps) { - fprintf(dependFile, "%s:\n", path.c_str()); - } - } -} - static bool isValidFilePath(std::string const &path) { struct stat statBuf; return stat(path.c_str(), &statBuf) == 0 && !S_ISDIR(statBuf.st_mode); // Reject directories } +static void printDep(std::string const &path) { + if (dependFile) { + fprintf(dependFile, "%s: %s\n", targetFileName.c_str(), path.c_str()); + if (generatePhonyDeps && isValidFilePath(path)) { + fprintf(dependFile, "%s:\n", path.c_str()); + } + } +} + std::optional fstk_FindFile(std::string const &path) { for (std::string &incPath : includePaths) { if (std::string fullPath = incPath + path; isValidFilePath(fullPath)) {