summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2008-12-29 10:26:02 +0000
committerobrien <obrien@FreeBSD.org>2008-12-29 10:26:02 +0000
commit489c6b7af54b6bdfecf46c055927d2452f709060 (patch)
treec6e64510fb221bf014c31a9eca386fd987b8428f
parent5d8be9f4c70013a263eed7a02eff028099f7bbad (diff)
downloadFreeBSD-src-489c6b7af54b6bdfecf46c055927d2452f709060.zip
FreeBSD-src-489c6b7af54b6bdfecf46c055927d2452f709060.tar.gz
1. Add the ability to tweak the token output before targets in job mode.
E.g., .MAKE.JOB.PREFIX=${.newline}---[${.MAKE.PID}] would produce ---[1234] target --- 2. Added ${.newline} as a simple means of being able to include '\n' in the assignment of .MAKE.JOB.PREFIX Obtained from: NetBSD
-rw-r--r--usr.bin/make/job.c19
-rw-r--r--usr.bin/make/job.h1
-rw-r--r--usr.bin/make/main.c10
-rw-r--r--usr.bin/make/make.127
-rw-r--r--usr.bin/make/make.h2
-rw-r--r--usr.bin/make/parse.c2
6 files changed, 57 insertions, 4 deletions
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index 7cc575e..5bd5456 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -321,10 +321,11 @@ static GNode *lastNode; /* The node for which output was most recently
static const char *targFmt; /* Format string to use to head output from a
* job when it's not the most-recent job heard
* from */
+static char *targPrefix = NULL; /* What we print at the start of targFmt */
-#define TARG_FMT "--- %s ---\n" /* Default format */
+#define TARG_FMT "%s %s ---\n" /* Default format */
#define MESSAGE(fp, gn) \
- fprintf(fp, targFmt, gn->name);
+ fprintf(fp, targFmt, targPrefix, gn->name);
/*
* When JobStart attempts to run a job but isn't allowed to
@@ -2283,6 +2284,18 @@ Job_Make(GNode *gn)
JobStart(gn, 0, NULL);
}
+void
+Job_SetPrefix(void)
+{
+
+ if (targPrefix) {
+ free(targPrefix);
+ } else if (!Var_Exists(MAKE_JOB_PREFIX, VAR_GLOBAL)) {
+ Var_SetGlobal(MAKE_JOB_PREFIX, "---");
+ }
+ targPrefix = Var_Subst("${" MAKE_JOB_PREFIX "}", VAR_GLOBAL, 0)->buf;
+}
+
/**
* Job_Init
* Initialize the process module, given a maximum number of jobs.
@@ -2350,7 +2363,7 @@ Job_Init(int maxproc)
lastNode = NULL;
- if ((maxJobs == 1 && fifoFd < 0) || beVerbose == 0) {
+ if (maxJobs == 1 && fifoFd < 0) {
/*
* If only one job can run at a time, there's no need for a
* banner, no is there?
diff --git a/usr.bin/make/job.h b/usr.bin/make/job.h
index 57c99de..31e1cb7 100644
--- a/usr.bin/make/job.h
+++ b/usr.bin/make/job.h
@@ -67,6 +67,7 @@ Boolean Job_Empty(void);
void Job_Finish(void);
void Job_Wait(void);
void Job_AbortAll(void);
+void Job_SetPrefix(void);
void Proc_Init(void);
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 7ba0bae..d2aae55 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -1029,6 +1029,16 @@ main(int argc, char **argv)
#ifdef MAKE_VERSION
Var_SetGlobal("MAKE_VERSION", MAKE_VERSION);
#endif
+ Var_SetGlobal(".newline", "\n"); /* handy for :@ loops */
+ {
+ char tmp[64];
+
+ snprintf(tmp, sizeof(tmp), "%u", getpid());
+ Var_SetGlobal(".MAKE.PID", tmp);
+ snprintf(tmp, sizeof(tmp), "%u", getppid());
+ Var_SetGlobal(".MAKE.PPID", tmp);
+ }
+ Job_SetPrefix();
/*
* First snag things out of the MAKEFLAGS environment
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index cd9d913..27cbc9f 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -32,7 +32,7 @@
.\" @(#)make.1 8.8 (Berkeley) 6/13/95
.\" $FreeBSD$
.\"
-.Dd December 26, 2008
+.Dd December 29, 2008
.Dt MAKE 1
.Os
.Sh NAME
@@ -763,6 +763,31 @@ contains all the options from the
environment variable plus any options specified on
.Nm Ns 's
command line.
+.It Va .MAKE.PID
+The process-id of
+.Nm .
+.It Va .MAKE.PPID
+The parent process-id of
+.Nm .
+.It Va .MAKE.JOB.PREFIX
+If
+.Nm
+is run with
+.Fl j Fl v
+then output for each target is prefixed with a token
+.Ql --- target ---
+the first part of which can be controlled via
+.Va .MAKE.JOB.PREFIX .
+.br
+For example:
+.Li .MAKE.JOB.PREFIX=${.newline}---${MAKE:T}[${.MAKE.PID}]
+would produce tokens like
+.Ql ---make[1234] target ---
+or
+.Li .MAKE.JOB.PREFIX=---pid[${.MAKE.PID}],ppid[${.MAKE.PPID}]
+would produce tokens like
+.Ql ---pid[56789],ppid[1234] target ---
+making it easier to track the degree of parallelism being achieved.
.It Va .TARGETS
List of targets
.Nm
diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h
index 2386cd7..6e2813d 100644
--- a/usr.bin/make/make.h
+++ b/usr.bin/make/make.h
@@ -49,6 +49,8 @@
#include "util.h"
+#define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX"
+
struct GNode;
struct Lst;
struct Buffer;
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index 47e6db6..2c65164 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -1533,6 +1533,8 @@ Parse_DoVar(char *line, GNode *ctxt)
*/
Var_Set(line, cp, ctxt);
}
+ if (strcmp(line, MAKE_JOB_PREFIX) == 0)
+ Job_SetPrefix();
}
/*-
OpenPOWER on IntegriCloud