Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make When a source file moves, make will ignore the ...



details:   https://anonhg.NetBSD.org/src/rev/81752e2c2950
branches:  trunk
changeset: 759058:81752e2c2950
user:      sjg <sjg%NetBSD.org@localhost>
date:      Sat Nov 27 05:02:35 2010 +0000

description:
When a source file moves, make will ignore the stale dependency,
but if the file in question is one that needs to be compiled (.c or .cc),
it still hands the bogus name to the compiler.

If Dir_MTime() cannot find such a file (gn->iParents is not empty),
see if the basename can be found via .PATH, and if so set gn->path to
the found file.   This prevents the stale path being given to the
compiler.

In meta_oodate(), if a referenced file no longer exists, consider the
target out-of-date.

Also, if meta_oodate() decides a target is out-of-date, and it
it uses .OODATE in its commands, we need .OODATE recomputed.
Undo our call to Make_DoAllVar() so that the call from Make_OODate()
will do the right thing.

diffstat:

 usr.bin/make/dir.c  |  31 ++++++++++++++++++++++++++++---
 usr.bin/make/meta.c |  28 +++++++++++++++++++++-------
 2 files changed, 49 insertions(+), 10 deletions(-)

diffs (118 lines):

diff -r 550c38623ef2 -r 81752e2c2950 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Sat Nov 27 00:42:58 2010 +0000
+++ b/usr.bin/make/dir.c        Sat Nov 27 05:02:35 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.61 2009/01/24 10:59:09 dsl Exp $     */
+/*     $NetBSD: dir.c,v 1.62 2010/11/27 05:02:35 sjg Exp $     */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.61 2009/01/24 10:59:09 dsl Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.62 2010/11/27 05:02:35 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c      8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.61 2009/01/24 10:59:09 dsl Exp $");
+__RCSID("$NetBSD: dir.c,v 1.62 2010/11/27 05:02:35 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1434,6 +1434,31 @@
            fullName = NULL;
        else {
            fullName = Dir_FindFile(gn->name, Suff_FindPath(gn));
+           if (fullName == NULL && gn->flags & FROM_DEPEND &&
+               !Lst_IsEmpty(gn->iParents)) {
+               char *cp;
+
+               cp = strrchr(gn->name, '/');
+               if (cp) {
+                   /*
+                    * This is an implied source, and it may have moved,
+                    * see if we can find it via the current .PATH
+                    */
+                   cp++;
+                       
+                   fullName = Dir_FindFile(cp, Suff_FindPath(gn));
+                   if (fullName) {
+                       /*
+                        * Put the found file in gn->path
+                        * so that we give that to the compiler.
+                        */
+                       gn->path = bmake_strdup(fullName);
+                       fprintf(stdout,
+                               "%s: ignoring stale %s for %s, found %s\n",
+                               progname, makeDependfile, gn->name, fullName);
+                   }
+               }
+           }
            if (DEBUG(DIR))
                fprintf(debug_file, "Found '%s' as '%s'\n",
                        gn->name, fullName ? fullName : "(not found)" );
diff -r 550c38623ef2 -r 81752e2c2950 usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Sat Nov 27 00:42:58 2010 +0000
+++ b/usr.bin/make/meta.c       Sat Nov 27 05:02:35 2010 +0000
@@ -707,6 +707,9 @@
     FILE *fp;
     Boolean ignoreOODATE = FALSE;
 
+    if (oodate)
+       return oodate;          /* we're done */
+
     /*
      * We need to check if the target is out-of-date. This includes
      * checking if the expanded command has changed. This in turn
@@ -715,9 +718,6 @@
      */
     Make_DoAllVar(gn);
 
-    if (oodate)
-       return oodate;          /* we're done */
-
     if (getcwd(latestdir, sizeof(latestdir)) == NULL)
        err(1, "Could not get current working directory");
 
@@ -809,11 +809,16 @@
                        p = fname1;
                    }
 
-                   if (stat(p, &fs) == 0 &&
-                       !S_ISDIR(fs.st_mode) &&
-                       fs.st_mtime > gn->mtime) {
+                   if (stat(p, &fs) == 0) {
+                       if (!S_ISDIR(fs.st_mode) &&
+                           fs.st_mtime > gn->mtime) {
+                           if (DEBUG(META))
+                               fprintf(debug_file, "%s: %d: file '%s' is newer than the target...\n", fname, lineno, p);
+                           oodate = TRUE;
+                       }
+                   } else if (errno == ENOENT) {
                        if (DEBUG(META))
-                           fprintf(debug_file, "%s: %d: file '%s' is newer than the target...\n", fname, lineno, p);
+                           fprintf(debug_file, "%s: %d: file '%s' may have moved?...\n", fname, lineno, p);
                        oodate = TRUE;
                    }
                    break;
@@ -904,6 +909,15 @@
 
        fclose(fp);
     }
+    if (oodate && ignoreOODATE) {
+       /*
+        * Target uses .OODATE, so we need to re-compute it.
+        * We need to clean up what Make_DoAllVar() did.
+        */
+       Var_Delete(ALLSRC, gn);
+       Var_Delete(OODATE, gn);
+       gn->flags &= ~DONE_ALLSRC;
+    }
     return oodate;
 }
 



Home | Main Index | Thread Index | Old Index