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 a .STALE special target that gets invoked w...
details: https://anonhg.NetBSD.org/src/rev/adff47b620b0
branches: trunk
changeset: 785245:adff47b620b0
user: christos <christos%NetBSD.org@localhost>
date: Tue Mar 05 22:01:43 2013 +0000
description:
Add a .STALE special target that gets invoked when dependency files contain
stail entries.
diffstat:
usr.bin/make/dir.c | 16 +++++----
usr.bin/make/job.c | 56 +++++++++++++++++++++++---------
usr.bin/make/job.h | 3 +-
usr.bin/make/make.1 | 8 +++-
usr.bin/make/parse.c | 87 +++++++++++++++++++++++++++------------------------
5 files changed, 103 insertions(+), 67 deletions(-)
diffs (truncated from 341 to 300 lines):
diff -r 82fc76705f7f -r adff47b620b0 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Tue Mar 05 21:59:01 2013 +0000
+++ b/usr.bin/make/dir.c Tue Mar 05 22:01:43 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.66 2013/03/05 02:04:10 christos Exp $ */
+/* $NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos 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.66 2013/03/05 02:04:10 christos Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos 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.66 2013/03/05 02:04:10 christos Exp $");
+__RCSID("$NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -145,6 +145,7 @@
#include "make.h"
#include "hash.h"
#include "dir.h"
+#include "job.h"
/*
* A search path consists of a Lst of Path structures. A Path structure
@@ -1463,10 +1464,11 @@
* so that we give that to the compiler.
*/
gn->path = bmake_strdup(fullName);
- fprintf(stdout,
- "%s: %s, %d: ignoring stale %s for %s, found %s\n",
- progname, gn->fname, gn->lineno,
- makeDependfile, gn->name, fullName);
+ if (!Job_RunTarget(".STALE", gn->fname))
+ fprintf(stdout,
+ "%s: %s, %d: ignoring stale %s for %s, "
+ "found %s\n", progname, gn->fname, gn->lineno,
+ makeDependfile, gn->name, fullName);
}
}
}
diff -r 82fc76705f7f -r adff47b620b0 usr.bin/make/job.c
--- a/usr.bin/make/job.c Tue Mar 05 21:59:01 2013 +0000
+++ b/usr.bin/make/job.c Tue Mar 05 22:01:43 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.171 2013/03/05 02:04:10 christos Exp $ */
+/* $NetBSD: job.c,v 1.172 2013/03/05 22:01:43 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.171 2013/03/05 02:04:10 christos Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.172 2013/03/05 22:01:43 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: job.c,v 1.171 2013/03/05 02:04:10 christos Exp $");
+__RCSID("$NetBSD: job.c,v 1.172 2013/03/05 22:01:43 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -1232,8 +1232,10 @@
static const char msg[] = ": don't know how to make";
if (gn->flags & FROM_DEPEND) {
- fprintf(stdout, "%s: %s, %d: ignoring stale %s for %s\n",
- progname, gn->fname, gn->lineno, makeDependfile, gn->name);
+ if (!Job_RunTarget(".STALE", gn->fname))
+ fprintf(stdout, "%s: %s, %d: ignoring stale %s for %s\n",
+ progname, gn->fname, gn->lineno, makeDependfile,
+ gn->name);
return TRUE;
}
@@ -2177,8 +2179,6 @@
void
Job_Init(void)
{
- GNode *begin; /* node for commands to do at the very start */
-
/* Allocate space for all the job info */
job_table = bmake_malloc(maxJobs * sizeof *job_table);
memset(job_table, 0, maxJobs * sizeof *job_table);
@@ -2254,15 +2254,7 @@
ADDSIG(SIGCONT, JobContinueSig)
#undef ADDSIG
- begin = Targ_FindNode(".BEGIN", TARG_NOCREATE);
-
- if (begin != NULL) {
- JobRun(begin);
- if (begin->made == ERROR) {
- PrintOnError(begin, "\n\nStop.");
- exit(1);
- }
- }
+ (void)Job_RunTarget(".BEGIN", NULL);
postCommands = Targ_FindNode(".END", TARG_CREATE);
}
@@ -2928,6 +2920,38 @@
return TRUE;
}
+/*-
+ *-----------------------------------------------------------------------
+ * Job_RunTarget --
+ * Run the named target if found. If a filename is specified, then
+ * set that to the sources.
+ *
+ * Results:
+ * None
+ *
+ * Side Effects:
+ * exits if the target fails.
+ *
+ *-----------------------------------------------------------------------
+ */
+Boolean
+Job_RunTarget(const char *target, const char *fname) {
+ GNode *gn = Targ_FindNode(target, TARG_NOCREATE);
+
+ if (gn == NULL)
+ return FALSE;
+
+ if (fname)
+ Var_Set(ALLSRC, fname, gn, 0);
+
+ JobRun(gn);
+ if (gn->made == ERROR) {
+ PrintOnError(gn, "\n\nStop.");
+ exit(1);
+ }
+ return TRUE;
+}
+
#ifdef USE_SELECT
int
emul_poll(struct pollfd *fd, int nfd, int timeout)
diff -r 82fc76705f7f -r adff47b620b0 usr.bin/make/job.h
--- a/usr.bin/make/job.h Tue Mar 05 21:59:01 2013 +0000
+++ b/usr.bin/make/job.h Tue Mar 05 22:01:43 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.h,v 1.40 2010/09/13 15:36:57 sjg Exp $ */
+/* $NetBSD: job.h,v 1.41 2013/03/05 22:01:44 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -268,5 +268,6 @@
Boolean Job_TokenWithdraw(void);
void Job_ServerStart(int, int, int);
void Job_SetPrefix(void);
+Boolean Job_RunTarget(const char *, const char *);
#endif /* _JOB_H_ */
diff -r 82fc76705f7f -r adff47b620b0 usr.bin/make/make.1
--- a/usr.bin/make/make.1 Tue Mar 05 21:59:01 2013 +0000
+++ b/usr.bin/make/make.1 Tue Mar 05 22:01:43 2013 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.210 2013/01/27 18:52:01 sjg Exp $
+.\" $NetBSD: make.1,v 1.211 2013/03/05 22:01:44 christos 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 January 23, 2013
+.Dd March 5, 2013
.Dt MAKE 1
.Os
.Sh NAME
@@ -2008,6 +2008,10 @@
.Ic .SILENT
attribute is applied to every
command in the file.
+.It Ic .STALE
+This target gets run when a dependency file contains stale entries, having
+.Va .ALLSRC
+set to the name of that dependency file.
.It Ic .SUFFIXES
Each source specifies a suffix to
.Nm .
diff -r 82fc76705f7f -r adff47b620b0 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Tue Mar 05 21:59:01 2013 +0000
+++ b/usr.bin/make/parse.c Tue Mar 05 22:01:43 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.186 2013/03/05 02:04:11 christos Exp $ */
+/* $NetBSD: parse.c,v 1.187 2013/03/05 22:01:44 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.186 2013/03/05 02:04:11 christos Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.187 2013/03/05 22:01:44 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: parse.c,v 1.186 2013/03/05 02:04:11 christos Exp $");
+__RCSID("$NetBSD: parse.c,v 1.187 2013/03/05 22:01:44 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -210,6 +210,7 @@
ExShell, /* .SHELL */
Silent, /* .SILENT */
SingleShell, /* .SINGLESHELL */
+ Stale, /* .STALE */
Suffixes, /* .SUFFIXES */
Wait, /* .WAIT */
Attribute /* Generic attribute */
@@ -333,6 +334,7 @@
{ ".SHELL", ExShell, 0 },
{ ".SILENT", Silent, OP_SILENT },
{ ".SINGLESHELL", SingleShell, 0 },
+{ ".STALE", Stale, 0 },
{ ".SUFFIXES", Suffixes, 0 },
{ ".USE", Attribute, OP_USE },
{ ".USEBEFORE", Attribute, OP_USEBEFORE },
@@ -1292,6 +1294,7 @@
* apply the .DEFAULT commands.
* .PHONY The list of targets
* .NOPATH Don't search for file in the path
+ * .STALE
* .BEGIN
* .END
* .ERROR
@@ -1302,44 +1305,45 @@
* .ORDER Must set initial predecessor to NULL
*/
switch (specType) {
- case ExPath:
- if (paths == NULL) {
- paths = Lst_Init(FALSE);
- }
- (void)Lst_AtEnd(paths, dirSearchPath);
- break;
- case Main:
- if (!Lst_IsEmpty(create)) {
- specType = Not;
- }
- break;
- case Begin:
- case End:
- case dotError:
- case Interrupt:
- gn = Targ_FindNode(line, TARG_CREATE);
- if (doing_depend)
- ParseMark(gn);
- gn->type |= OP_NOTMAIN|OP_SPECIAL;
- (void)Lst_AtEnd(targets, gn);
- break;
- case Default:
- gn = Targ_NewGN(".DEFAULT");
- gn->type |= (OP_NOTMAIN|OP_TRANSFORM);
- (void)Lst_AtEnd(targets, gn);
- DEFAULT = gn;
- break;
- case NotParallel:
- maxJobs = 1;
- break;
- case SingleShell:
- compatMake = TRUE;
- break;
- case Order:
- predecessor = NULL;
- break;
- default:
- break;
+ case ExPath:
+ if (paths == NULL) {
+ paths = Lst_Init(FALSE);
+ }
+ (void)Lst_AtEnd(paths, dirSearchPath);
+ break;
+ case Main:
+ if (!Lst_IsEmpty(create)) {
+ specType = Not;
Home |
Main Index |
Thread Index |
Old Index