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 meta.c which implements "meta" mode for make.
details: https://anonhg.NetBSD.org/src/rev/6aa7b050a15b
branches: trunk
changeset: 757685:6aa7b050a15b
user: sjg <sjg%NetBSD.org@localhost>
date: Mon Sep 13 15:36:57 2010 +0000
description:
Add meta.c which implements "meta" mode for make.
In this mode, a .meta file is created for each target, capturing
the expanded commands used, any command output, and if filemon(9)
is available, a record of system calls which are of interest.
Not enabled unless USE_META=yes is set when building make.
Also, if FILEMON_H exists, meta.c will be compiled to use filemon(9).
diffstat:
usr.bin/make/Makefile | 13 +-
usr.bin/make/compat.c | 43 ++-
usr.bin/make/job.c | 32 +-
usr.bin/make/job.h | 11 +-
usr.bin/make/main.c | 13 +-
usr.bin/make/make.1 | 73 +++-
usr.bin/make/make.c | 12 +-
usr.bin/make/make.h | 7 +-
usr.bin/make/meta.c | 955 ++++++++++++++++++++++++++++++++++++++++++++++++++
usr.bin/make/meta.h | 52 ++
usr.bin/make/parse.c | 12 +-
11 files changed, 1201 insertions(+), 22 deletions(-)
diffs (truncated from 1547 to 300 lines):
diff -r 50a1865d8db3 -r 6aa7b050a15b usr.bin/make/Makefile
--- a/usr.bin/make/Makefile Mon Sep 13 08:43:06 2010 +0000
+++ b/usr.bin/make/Makefile Mon Sep 13 15:36:57 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.50 2010/04/22 19:15:23 sjg Exp $
+# $NetBSD: Makefile,v 1.51 2010/09/13 15:36:57 sjg Exp $
# @(#)Makefile 5.2 (Berkeley) 12/28/90
PROG= make
@@ -13,6 +13,17 @@
lstMember.c lstNext.c lstOpen.c lstRemove.c lstReplace.c lstSucc.c
SRCS += lstPrev.c
+# let people experiment for a bit
+USE_META ?= no
+.if ${USE_META:tl} != "no"
+SRCS+= meta.c
+CPPFLAGS+= -DUSE_META
+FILEMON_H ?= ${.CURDIR:H:H}/sys/dev/filemon/filemon.h
+.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h"
+COPTS.meta.c += -DHAVE_FILEMON_H -I${FILEMON_H:H}
+.endif
+.endif
+
.PATH: ${.CURDIR}/lst.lib
.if make(install)
SUBDIR= PSD.doc
diff -r 50a1865d8db3 -r 6aa7b050a15b usr.bin/make/compat.c
--- a/usr.bin/make/compat.c Mon Sep 13 08:43:06 2010 +0000
+++ b/usr.bin/make/compat.c Mon Sep 13 15:36:57 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.80 2010/08/07 06:44:08 sjg Exp $ */
+/* $NetBSD: compat.c,v 1.81 2010/09/13 15:36:57 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: compat.c,v 1.80 2010/08/07 06:44:08 sjg Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.81 2010/09/13 15:36:57 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: compat.c,v 1.80 2010/08/07 06:44:08 sjg Exp $");
+__RCSID("$NetBSD: compat.c,v 1.81 2010/09/13 15:36:57 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -352,6 +352,12 @@
local = TRUE;
+#ifdef USE_META
+ if (useMeta) {
+ meta_compat_start();
+ }
+#endif
+
/*
* Fork and execute the single command. If the fork fails, we abort.
*/
@@ -362,6 +368,11 @@
if (cpid == 0) {
Check_Cwd(av);
Var_ExportVars();
+#ifdef USE_META
+ if (useMeta) {
+ meta_compat_child();
+ }
+#endif
if (local)
(void)execvp(av[0], (char *const *)UNCONST(av));
else
@@ -375,6 +386,12 @@
free(bp);
Lst_Replace(cmdNode, NULL);
+#ifdef USE_META
+ if (useMeta) {
+ meta_compat_parent();
+ }
+#endif
+
/*
* The child is off and running. Now all we can do is wait...
*/
@@ -393,6 +410,11 @@
status = WSTOPSIG(reason); /* stopped */
} else if (WIFEXITED(reason)) {
status = WEXITSTATUS(reason); /* exited */
+#if defined(USE_META) && defined(USE_FILEMON_ONCE)
+ if (useMeta) {
+ meta_cmd_finish(NULL);
+ }
+#endif
if (status != 0) {
if (DEBUG(ERROR)) {
fprintf(debug_file, "\n*** Failed target: %s\n*** Failed command: ",
@@ -419,6 +441,11 @@
if (!WIFEXITED(reason) || (status != 0)) {
if (errCheck) {
+#ifdef USE_META
+ if (useMeta) {
+ meta_job_error(NULL, gn, 0, status);
+ }
+#endif
gn->made = ERROR;
if (keepgoing) {
/*
@@ -551,6 +578,11 @@
*/
if (!touchFlag || (gn->type & OP_MAKE)) {
curTarg = gn;
+#ifdef USE_META
+ if (useMeta && !NoExecute(gn)) {
+ meta_job_start(NULL, gn);
+ }
+#endif
Lst_ForEach(gn->commands, CompatRunCommand, gn);
curTarg = NULL;
} else {
@@ -559,6 +591,11 @@
} else {
gn->made = ERROR;
}
+#ifdef USE_META
+ if (useMeta && !NoExecute(gn)) {
+ meta_job_finish(NULL);
+ }
+#endif
if (gn->made != ERROR) {
/*
diff -r 50a1865d8db3 -r 6aa7b050a15b usr.bin/make/job.c
--- a/usr.bin/make/job.c Mon Sep 13 08:43:06 2010 +0000
+++ b/usr.bin/make/job.c Mon Sep 13 15:36:57 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.154 2010/08/07 21:28:40 sjg Exp $ */
+/* $NetBSD: job.c,v 1.155 2010/09/13 15:36:57 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: job.c,v 1.154 2010/08/07 21:28:40 sjg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.155 2010/09/13 15:36:57 sjg 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.154 2010/08/07 21:28:40 sjg Exp $");
+__RCSID("$NetBSD: job.c,v 1.155 2010/09/13 15:36:57 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -960,6 +960,12 @@
{
Boolean done, return_job_token;
+#ifdef USE_META
+ if (useMeta) {
+ meta_job_finish(job);
+ }
+#endif
+
if (DEBUG(JOB)) {
fprintf(debug_file, "Jobfinish: %d [%s], status %d\n",
job->pid, job->node->name, status);
@@ -1017,6 +1023,11 @@
MESSAGE(stdout, job->node);
lastNode = job->node;
}
+#ifdef USE_META
+ if (useMeta) {
+ meta_job_error(job, job->node, job->flags, WEXITSTATUS(status));
+ }
+#endif
(void)printf("*** [%s] Error code %d%s\n",
job->node->name,
WEXITSTATUS(status),
@@ -1311,6 +1322,11 @@
/* Child */
sigset_t tmask;
+#ifdef USE_META
+ if (useMeta) {
+ meta_job_child(job);
+ }
+#endif
/*
* Reset all signal handlers; this is necessary because we also
* need to unblock signals before we exec(2).
@@ -1574,6 +1590,11 @@
*/
noExec = FALSE;
+#ifdef USE_META
+ if (useMeta) {
+ meta_job_start(job, gn);
+ }
+#endif
/*
* We can do all the commands at once. hooray for sanity
*/
@@ -1846,6 +1867,11 @@
MESSAGE(stdout, job->node);
lastNode = job->node;
}
+#ifdef USE_META
+ if (useMeta) {
+ meta_job_output(job, cp, gotNL ? "\n" : "");
+ }
+#endif
(void)fprintf(stdout, "%s%s", cp, gotNL ? "\n" : "");
(void)fflush(stdout);
}
diff -r 50a1865d8db3 -r 6aa7b050a15b usr.bin/make/job.h
--- a/usr.bin/make/job.h Mon Sep 13 08:43:06 2010 +0000
+++ b/usr.bin/make/job.h Mon Sep 13 15:36:57 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.h,v 1.39 2009/04/11 09:41:18 apb Exp $ */
+/* $NetBSD: job.h,v 1.40 2010/09/13 15:36:57 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -135,6 +135,11 @@
*/
struct pollfd;
+
+#ifdef USE_META
+# include "meta.h"
+#endif
+
#define JOB_BUFSIZE 1024
typedef struct Job {
int pid; /* The child's process ID */
@@ -165,6 +170,10 @@
/* Buffer for storing the output of the
* job, line by line */
int curPos; /* Current position in op_outBuf */
+
+#ifdef USE_META
+ struct BuildMon bm;
+#endif
} Job;
#define inPipe jobPipe[0]
diff -r 50a1865d8db3 -r 6aa7b050a15b usr.bin/make/main.c
--- a/usr.bin/make/main.c Mon Sep 13 08:43:06 2010 +0000
+++ b/usr.bin/make/main.c Mon Sep 13 15:36:57 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.189 2010/08/07 06:44:08 sjg Exp $ */
+/* $NetBSD: main.c,v 1.190 2010/09/13 15:36:57 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.189 2010/08/07 06:44:08 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.190 2010/09/13 15:36:57 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.189 2010/08/07 06:44:08 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.190 2010/09/13 15:36:57 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -242,6 +242,9 @@
case 'l':
debug |= DEBUG_LOUD;
break;
+ case 'M':
+ debug |= DEBUG_META;
+ break;
case 'm':
debug |= DEBUG_MAKE;
break;
@@ -732,6 +735,10 @@
compatMake = TRUE;
forceJobs = FALSE;
}
+#if USE_META
Home |
Main Index |
Thread Index |
Old Index