Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Dec 2008 10:26:02 +0000 (UTC)
From:      "David E. O'Brien" <obrien@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r186559 - head/usr.bin/make
Message-ID:  <200812291026.mBTAQ224051640@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: obrien
Date: Mon Dec 29 10:26:02 2008
New Revision: 186559
URL: http://svn.freebsd.org/changeset/base/186559

Log:
  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

Modified:
  head/usr.bin/make/job.c
  head/usr.bin/make/job.h
  head/usr.bin/make/main.c
  head/usr.bin/make/make.1
  head/usr.bin/make/make.h
  head/usr.bin/make/parse.c

Modified: head/usr.bin/make/job.c
==============================================================================
--- head/usr.bin/make/job.c	Mon Dec 29 08:05:49 2008	(r186558)
+++ head/usr.bin/make/job.c	Mon Dec 29 10:26:02 2008	(r186559)
@@ -321,10 +321,11 @@ static GNode	*lastNode;	/* The node for 
 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?

Modified: head/usr.bin/make/job.h
==============================================================================
--- head/usr.bin/make/job.h	Mon Dec 29 08:05:49 2008	(r186558)
+++ head/usr.bin/make/job.h	Mon Dec 29 10:26:02 2008	(r186559)
@@ -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);
 

Modified: head/usr.bin/make/main.c
==============================================================================
--- head/usr.bin/make/main.c	Mon Dec 29 08:05:49 2008	(r186558)
+++ head/usr.bin/make/main.c	Mon Dec 29 10:26:02 2008	(r186559)
@@ -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

Modified: head/usr.bin/make/make.1
==============================================================================
--- head/usr.bin/make/make.1	Mon Dec 29 08:05:49 2008	(r186558)
+++ head/usr.bin/make/make.1	Mon Dec 29 10:26:02 2008	(r186559)
@@ -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

Modified: head/usr.bin/make/make.h
==============================================================================
--- head/usr.bin/make/make.h	Mon Dec 29 08:05:49 2008	(r186558)
+++ head/usr.bin/make/make.h	Mon Dec 29 10:26:02 2008	(r186559)
@@ -49,6 +49,8 @@
 
 #include "util.h"
 
+#define	MAKE_JOB_PREFIX	".MAKE.JOB.PREFIX"
+
 struct GNode;
 struct Lst;
 struct Buffer;

Modified: head/usr.bin/make/parse.c
==============================================================================
--- head/usr.bin/make/parse.c	Mon Dec 29 08:05:49 2008	(r186558)
+++ head/usr.bin/make/parse.c	Mon Dec 29 10:26:02 2008	(r186559)
@@ -1533,6 +1533,8 @@ Parse_DoVar(char *line, GNode *ctxt)
 		 */
 		Var_Set(line, cp, ctxt);
 	}
+	if (strcmp(line, MAKE_JOB_PREFIX) == 0)
+		Job_SetPrefix();
 }
 
 /*-



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812291026.mBTAQ224051640>