| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: dir.c,v 1.208 2020/11/14 19:24:24 rillig Exp $ */ | | 1 | /* $NetBSD: dir.c,v 1.209 2020/11/14 19:36:31 rillig Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. | | 4 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Adam de Boor. | | 8 | * Adam de Boor. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -124,27 +124,27 @@ | | | @@ -124,27 +124,27 @@ |
124 | */ | | 124 | */ |
125 | | | 125 | |
126 | #include <sys/types.h> | | 126 | #include <sys/types.h> |
127 | #include <sys/stat.h> | | 127 | #include <sys/stat.h> |
128 | | | 128 | |
129 | #include <dirent.h> | | 129 | #include <dirent.h> |
130 | #include <errno.h> | | 130 | #include <errno.h> |
131 | | | 131 | |
132 | #include "make.h" | | 132 | #include "make.h" |
133 | #include "dir.h" | | 133 | #include "dir.h" |
134 | #include "job.h" | | 134 | #include "job.h" |
135 | | | 135 | |
136 | /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ | | 136 | /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ |
137 | MAKE_RCSID("$NetBSD: dir.c,v 1.208 2020/11/14 19:24:24 rillig Exp $"); | | 137 | MAKE_RCSID("$NetBSD: dir.c,v 1.209 2020/11/14 19:36:31 rillig Exp $"); |
138 | | | 138 | |
139 | #define DIR_DEBUG0(text) DEBUG0(DIR, text) | | 139 | #define DIR_DEBUG0(text) DEBUG0(DIR, text) |
140 | #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) | | 140 | #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) |
141 | #define DIR_DEBUG2(fmt, arg1, arg2) DEBUG2(DIR, fmt, arg1, arg2) | | 141 | #define DIR_DEBUG2(fmt, arg1, arg2) DEBUG2(DIR, fmt, arg1, arg2) |
142 | | | 142 | |
143 | /* A search path is a list of CachedDir structures. A CachedDir has in it the | | 143 | /* A search path is a list of CachedDir structures. A CachedDir has in it the |
144 | * name of the directory and the names of all the files in the directory. | | 144 | * name of the directory and the names of all the files in the directory. |
145 | * This is used to cut down on the number of system calls necessary to find | | 145 | * This is used to cut down on the number of system calls necessary to find |
146 | * implicit dependents and their like. Since these searches are made before | | 146 | * implicit dependents and their like. Since these searches are made before |
147 | * any actions are taken, we need not worry about the directory changing due | | 147 | * any actions are taken, we need not worry about the directory changing due |
148 | * to creation commands. If this hampers the style of some makefiles, they | | 148 | * to creation commands. If this hampers the style of some makefiles, they |
149 | * must be changed. | | 149 | * must be changed. |
150 | * | | 150 | * |
| @@ -1269,27 +1269,26 @@ Dir_FindHereOrAbove(const char *here, co | | | @@ -1269,27 +1269,26 @@ Dir_FindHereOrAbove(const char *here, co |
1269 | free(dirbase); | | 1269 | free(dirbase); |
1270 | return NULL; | | 1270 | return NULL; |
1271 | } | | 1271 | } |
1272 | | | 1272 | |
1273 | /* Search gn along dirSearchPath and store its modification time in gn->mtime. | | 1273 | /* Search gn along dirSearchPath and store its modification time in gn->mtime. |
1274 | * If no file is found, store 0 instead. | | 1274 | * If no file is found, store 0 instead. |
1275 | * | | 1275 | * |
1276 | * The found file is stored in gn->path, unless the node already had a path. */ | | 1276 | * The found file is stored in gn->path, unless the node already had a path. */ |
1277 | void | | 1277 | void |
1278 | Dir_UpdateMTime(GNode *gn, Boolean recheck) | | 1278 | Dir_UpdateMTime(GNode *gn, Boolean recheck) |
1279 | { | | 1279 | { |
1280 | char *fullName; | | 1280 | char *fullName; |
1281 | struct cached_stat cst; | | 1281 | struct cached_stat cst; |
1282 | CachedStatsFlags flags; | | | |
1283 | | | 1282 | |
1284 | if (gn->type & OP_ARCHV) { | | 1283 | if (gn->type & OP_ARCHV) { |
1285 | Arch_UpdateMTime(gn); | | 1284 | Arch_UpdateMTime(gn); |
1286 | return; | | 1285 | return; |
1287 | } | | 1286 | } |
1288 | | | 1287 | |
1289 | if (gn->type & OP_PHONY) { | | 1288 | if (gn->type & OP_PHONY) { |
1290 | gn->mtime = 0; | | 1289 | gn->mtime = 0; |
1291 | return; | | 1290 | return; |
1292 | } | | 1291 | } |
1293 | | | 1292 | |
1294 | if (gn->path == NULL) { | | 1293 | if (gn->path == NULL) { |
1295 | if (gn->type & OP_NOPATH) | | 1294 | if (gn->type & OP_NOPATH) |
| @@ -1324,28 +1323,27 @@ Dir_UpdateMTime(GNode *gn, Boolean reche | | | @@ -1324,28 +1323,27 @@ Dir_UpdateMTime(GNode *gn, Boolean reche |
1324 | } | | 1323 | } |
1325 | } | | 1324 | } |
1326 | } | | 1325 | } |
1327 | DIR_DEBUG2("Found '%s' as '%s'\n", | | 1326 | DIR_DEBUG2("Found '%s' as '%s'\n", |
1328 | gn->name, fullName ? fullName : "(not found)"); | | 1327 | gn->name, fullName ? fullName : "(not found)"); |
1329 | } | | 1328 | } |
1330 | } else { | | 1329 | } else { |
1331 | fullName = gn->path; | | 1330 | fullName = gn->path; |
1332 | } | | 1331 | } |
1333 | | | 1332 | |
1334 | if (fullName == NULL) | | 1333 | if (fullName == NULL) |
1335 | fullName = bmake_strdup(gn->name); | | 1334 | fullName = bmake_strdup(gn->name); |
1336 | | | 1335 | |
1337 | flags = recheck ? CST_UPDATE : CST_NONE; | | 1336 | if (cached_stats(fullName, &cst, recheck ? CST_UPDATE : CST_NONE) < 0) { |
1338 | if (cached_stats(fullName, &cst, flags) < 0) { | | | |
1339 | if (gn->type & OP_MEMBER) { | | 1337 | if (gn->type & OP_MEMBER) { |
1340 | if (fullName != gn->path) | | 1338 | if (fullName != gn->path) |
1341 | free(fullName); | | 1339 | free(fullName); |
1342 | Arch_UpdateMemberMTime(gn); | | 1340 | Arch_UpdateMemberMTime(gn); |
1343 | return; | | 1341 | return; |
1344 | } | | 1342 | } |
1345 | | | 1343 | |
1346 | cst.cst_mtime = 0; | | 1344 | cst.cst_mtime = 0; |
1347 | } | | 1345 | } |
1348 | | | 1346 | |
1349 | if (fullName != NULL && gn->path == NULL) | | 1347 | if (fullName != NULL && gn->path == NULL) |
1350 | gn->path = fullName; | | 1348 | gn->path = fullName; |
1351 | | | 1349 | |