Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make Add .MAKE.META.BAILIWICK - to identify the scop...



details:   https://anonhg.NetBSD.org/src/rev/3e5a5fab4864
branches:  trunk
changeset: 764790:3e5a5fab4864
user:      sjg <sjg%NetBSD.org@localhost>
date:      Wed May 04 20:38:31 2011 +0000

description:
Add .MAKE.META.BAILIWICK - to identify the scope of make's control.
meta_oodate: if a file that was written or linked within our bailiwick,
but outside of .OBJDIR is missing, add it to missingFiles.
If we get to the end of the .meta file without seeing it [re]moved,
then consider the target out-of-date.

diffstat:

 usr.bin/make/main.c |    8 +-
 usr.bin/make/make.1 |   12 ++++-
 usr.bin/make/make.h |    3 +-
 usr.bin/make/meta.c |  110 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 124 insertions(+), 9 deletions(-)

diffs (248 lines):

diff -r 66ca9d88f277 -r 3e5a5fab4864 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Wed May 04 12:27:03 2011 +0000
+++ b/usr.bin/make/main.c       Wed May 04 20:38:31 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.196 2011/02/20 23:12:09 joerg Exp $ */
+/*     $NetBSD: main.c,v 1.197 2011/05/04 20:38:31 sjg Exp $   */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.196 2011/02/20 23:12:09 joerg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.197 2011/05/04 20:38:31 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.196 2011/02/20 23:12:09 joerg Exp $");
+__RCSID("$NetBSD: main.c,v 1.197 2011/05/04 20:38:31 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -687,7 +687,7 @@
        return (ReadMakefile(p, q) == 0);
 }
 
-static int
+int
 str2Lst_Append(Lst lp, char *str, const char *sep)
 {
     char *cp;
diff -r 66ca9d88f277 -r 3e5a5fab4864 usr.bin/make/make.1
--- a/usr.bin/make/make.1       Wed May 04 12:27:03 2011 +0000
+++ b/usr.bin/make/make.1       Wed May 04 20:38:31 2011 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: make.1,v 1.188 2011/04/11 06:56:50 wiz Exp $
+.\"    $NetBSD: make.1,v 1.189 2011/05/04 20:38:32 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"    from: @(#)make.1        8.4 (Berkeley) 3/19/94
 .\"
-.Dd April 10, 2011
+.Dd May 4, 2011
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -800,6 +800,14 @@
 See also
 .Ic .NOMETA_CMP .
 .El
+.It Va .MAKE.META.BAILIWICK
+In "meta" mode, provides a list of prefixes which
+match the directories controlled by
+.Nm .
+If a file that was generated outside of
+.Va .OBJDIR
+but within said bailiwick is missing,
+the current target is considered out-of-date.
 .It Va .MAKE.META.CREATED
 In "meta" mode, this variable contains a list of all the meta files
 updated.
diff -r 66ca9d88f277 -r 3e5a5fab4864 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Wed May 04 12:27:03 2011 +0000
+++ b/usr.bin/make/make.h       Wed May 04 20:38:31 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.85 2011/02/20 23:12:09 joerg Exp $  */
+/*     $NetBSD: make.h,v 1.86 2011/05/04 20:38:32 sjg Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -463,6 +463,7 @@
 void Main_ExportMAKEFLAGS(Boolean);
 Boolean Main_SetObjdir(const char *);
 int mkTempFile(const char *, char **);
+int str2Lst_Append(Lst, char *, const char *);
 
 #ifdef __GNUC__
 #define UNCONST(ptr)   ({              \
diff -r 66ca9d88f277 -r 3e5a5fab4864 usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Wed May 04 12:27:03 2011 +0000
+++ b/usr.bin/make/meta.c       Wed May 04 20:38:31 2011 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.16 2011/03/31 06:50:43 sjg Exp $ */
+/*      $NetBSD: meta.c,v 1.17 2011/05/04 20:38:32 sjg Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -55,6 +55,7 @@
 #endif
 
 static BuildMon Mybm;                  /* for compat */
+static Lst metaBailiwick;                      /* our scope of control */
 
 Boolean useMeta = FALSE;
 static Boolean useFilemon = FALSE;
@@ -574,6 +575,14 @@
        return;
     once = 1;
     memset(&Mybm, 0, sizeof(Mybm));
+    /*
+     * We consider ourselves master of all within ${.MAKE.META.BAILIWICK}
+     */
+    metaBailiwick = Lst_Init(FALSE);
+    cp = Var_Subst(NULL, "${.MAKE.META.BAILIWICK:O:u:tA}", VAR_GLOBAL, 0);
+    if (cp) {
+       str2Lst_Append(metaBailiwick, cp, NULL);
+    }
 }
 
 /*
@@ -773,6 +782,26 @@
     return 0;
 }
 
+static int
+prefix_match(void *p, void *q)
+{
+    const char *prefix = p;
+    const char *path = q;
+    size_t n = strlen(prefix);
+
+    return (0 == strncmp(path, prefix, n));
+}
+
+static int
+string_match(const void *p, const void *q)
+{
+    const char *p1 = p;
+    const char *p2 = q;
+
+    return strcmp(p1, p2);
+}
+
+
 /*
  * When running with 'meta' functionality, a target can be out-of-date
  * if any of the references in it's meta data file is more recent.
@@ -796,10 +825,13 @@
     static size_t tmplen = 0;
     FILE *fp;
     Boolean ignoreOODATE = FALSE;
-
+    Lst missingFiles;
+    
     if (oodate)
        return oodate;          /* we're done */
 
+    missingFiles = Lst_Init(FALSE);
+
     /*
      * We need to check if the target is out-of-date. This includes
      * checking if the expanded command has changed. This in turn
@@ -962,6 +994,73 @@
                    strlcpy(latestdir, p, sizeof(latestdir));
                    break;
 
+               case 'M':               /* renaMe */
+                   if (Lst_IsEmpty(missingFiles))
+                       break;
+                   /* 'L' and 'M' put single quotes around the args */
+                   if (*p == '\'') {
+                       char *ep;
+
+                       p++;
+                       if ((ep = strchr(p, '\'')))
+                           *ep = '\0';
+                   }
+                   /* FALLTHROUGH */
+               case 'D':               /* unlink */
+                   if (*p == '/' && !Lst_IsEmpty(missingFiles)) {
+                       /* remove p from the missingFiles list if present */
+                       if ((ln = Lst_Find(missingFiles, p, string_match)) != NULL) {
+                           char *tp = Lst_Datum(ln);
+                           Lst_Remove(missingFiles, ln);
+                           free(tp);
+                       }
+                   }
+                   break;
+               case 'L':               /* Link */
+                   /* we want the target */
+                   if (strsep(&p, " ") == NULL)
+                       continue;
+                   /* 'L' and 'M' put single quotes around the args */
+                   if (*p == '\'') {
+                       char *ep;
+
+                       p++;
+                       if ((ep = strchr(p, '\'')))
+                           *ep = '\0';
+                   }
+                   /* FALLTHROUGH */
+               case 'W':               /* Write */
+                   /*
+                    * If a file we generated within our bailiwick
+                    * but outside of .OBJDIR is missing,
+                    * we need to do it again. 
+                    */
+                   /* ignore non-absolute paths */
+                   if (*p != '/')
+                       break;
+
+                   if (Lst_IsEmpty(metaBailiwick))
+                       break;
+
+                   /* ignore cwd - normal dependencies handle those */
+                   if (strncmp(p, cwd, cwdlen) == 0)
+                       break;
+
+                   if (!Lst_ForEach(metaBailiwick, prefix_match, p))
+                       break;
+
+                   /* tmpdir might be within */
+                   if (tmplen > 0 && strncmp(p, tmpdir, tmplen) == 0)
+                       break;
+
+                   /* ignore anything containing the string "tmp" */
+                   if ((strstr("tmp", p)))
+                       break;
+
+                   if (stat(p, &fs) < 0) {
+                       Lst_AtEnd(missingFiles, bmake_strdup(p));
+                   }
+                   break;
                case 'R':               /* Read */
                case 'E':               /* Exec */
                    /*
@@ -1131,6 +1230,13 @@
        }
 
        fclose(fp);
+       if (!Lst_IsEmpty(missingFiles)) {
+           if (DEBUG(META))
+               fprintf(debug_file, "%s: missing files: %s...\n",
+                       fname, (char *)Lst_Datum(Lst_First(missingFiles)));
+           oodate = TRUE;
+           Lst_Destroy(missingFiles, (FreeProc *)free);
+       }
     }
     if (oodate && ignoreOODATE) {
        /*



Home | Main Index | Thread Index | Old Index