[TEST] make -j patch [take 2]
Ruslan Ermilov
ru at freebsd.org
Fri Nov 12 03:17:39 PST 2004
On Fri, Nov 12, 2004 at 11:24:12AM +0100, Harti Brandt wrote:
> It would actually give me _more_ control over make's behaviour. I could,
> for example, build the tool with -j4, but run the tool with -j2. Suppose
> that is a long running regression test that I don't want to occupy my
> 4 processor machine, but I want the tool for the test to build fast.
>
Here's the patch that changes the -j behavior the way I want it:
- if a sub-make is given an explicit -jX argument (either on a
command line or through a special .MAKEFLAGS target in makefile),
it will forget about its current job group membership,
- if -jX is given implicitly through the MAKEFLAGS environment
variable then a sub-make will respect MAKE_JOBS_FIFO and will
join the job group.
Of course, like you say, there's always a possibility to unset
MAKE_JOBS_FIFO before launching a sub-make.
Cheers,
--
Ruslan Ermilov
ru at FreeBSD.org
FreeBSD committer
-------------- next part --------------
Index: main.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/make/main.c,v
retrieving revision 1.96
diff -u -p -r1.96 main.c
--- main.c 12 Nov 2004 08:58:07 -0000 1.96
+++ main.c 12 Nov 2004 11:03:56 -0000
@@ -119,7 +119,7 @@ Boolean checkEnvFirst; /* -e flag */
Lst envFirstVars; /* (-E) vars to override from env */
Boolean jobsRunning; /* TRUE if the jobs might be running */
-static void MainParseArgs(int, char **);
+static void MainParseArgs(int, int, char **);
char * chdir_verify_path(char *, char *);
static int ReadMakefile(void *, void *);
static void usage(void);
@@ -157,7 +157,7 @@ MFLAGS_append(char *flag, char *arg)
* given
*/
static void
-MainParseArgs(int argc, char **argv)
+MainParseArgs(int override, int argc, char **argv)
{
char *p;
int c;
@@ -280,6 +280,8 @@ rearg: while((c = getopt(argc, argv, OPT
usage();
}
MFLAGS_append("-j", optarg);
+ if (override)
+ unsetenv("MAKE_JOBS_FIFO");
break;
}
case 'k':
@@ -366,7 +368,7 @@ rearg: while((c = getopt(argc, argv, OPT
* Only those that come from the various arguments.
*/
void
-Main_ParseArgLine(char *line)
+Main_ParseArgLine(int override, char *line)
{
char **argv; /* Manufactured argument vector */
int argc; /* Number of arguments in argv */
@@ -379,7 +381,7 @@ Main_ParseArgLine(char *line)
return;
argv = brk_string(line, &argc, TRUE);
- MainParseArgs(argc, argv);
+ MainParseArgs(override, argc, argv);
}
char *
@@ -612,12 +614,12 @@ main(int argc, char **argv)
* in a different format).
*/
#ifdef POSIX
- Main_ParseArgLine(getenv("MAKEFLAGS"));
+ Main_ParseArgLine(0, getenv("MAKEFLAGS"));
#else
- Main_ParseArgLine(getenv("MAKE"));
+ Main_ParseArgLine(0, getenv("MAKE"));
#endif
- MainParseArgs(argc, argv);
+ MainParseArgs(1, argc, argv);
/*
* Find where we are...
Index: nonints.h
===================================================================
RCS file: /home/ncvs/src/usr.bin/make/nonints.h,v
retrieving revision 1.23
diff -u -p -r1.23 nonints.h
--- nonints.h 12 Aug 2004 11:49:55 -0000 1.23
+++ nonints.h 12 Nov 2004 09:43:10 -0000
@@ -63,7 +63,7 @@ int For_Eval(char *);
void For_Run(int);
/* main.c */
-void Main_ParseArgLine(char *);
+void Main_ParseArgLine(int, char *);
char *Cmd_Exec(char *, char **);
void Debug(const char *, ...);
void Error(const char *, ...);
Index: parse.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/make/parse.c,v
retrieving revision 1.57
diff -u -p -r1.57 parse.c
--- parse.c 22 Jul 2004 11:12:01 -0000 1.57
+++ parse.c 12 Nov 2004 09:43:23 -0000
@@ -1048,7 +1048,7 @@ ParseDoDependency (char *line)
* set the initial character to a null-character so the loop to
* get sources won't get anything
*/
- Main_ParseArgLine (line);
+ Main_ParseArgLine (1, line);
*line = '\0';
} else if (specType == ExShell) {
if (Job_ParseShell (line) != SUCCESS) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20041112/ca2767cc/attachment.bin
More information about the freebsd-current
mailing list