Skip to content

Commit 5942117

Browse files
authored
Avoid generating phony dependencies for files that don't exist (#1708)
1 parent e7a3b9d commit 5942117

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/asm/fstack.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,20 @@ void fstk_SetPreIncludeFile(std::string const &path) {
126126
// LCOV_EXCL_STOP
127127
}
128128

129+
static bool isValidFilePath(std::string const &path) {
130+
struct stat statBuf;
131+
return stat(path.c_str(), &statBuf) == 0 && !S_ISDIR(statBuf.st_mode); // Reject directories
132+
}
133+
129134
static void printDep(std::string const &path) {
130135
if (dependFile) {
131136
fprintf(dependFile, "%s: %s\n", targetFileName.c_str(), path.c_str());
132-
if (generatePhonyDeps) {
137+
if (generatePhonyDeps && isValidFilePath(path)) {
133138
fprintf(dependFile, "%s:\n", path.c_str());
134139
}
135140
}
136141
}
137142

138-
static bool isValidFilePath(std::string const &path) {
139-
struct stat statBuf;
140-
return stat(path.c_str(), &statBuf) == 0 && !S_ISDIR(statBuf.st_mode); // Reject directories
141-
}
142-
143143
std::optional<std::string> fstk_FindFile(std::string const &path) {
144144
for (std::string &incPath : includePaths) {
145145
if (std::string fullPath = incPath + path; isValidFilePath(fullPath)) {

0 commit comments

Comments
 (0)