make(1): negate NoExecute to GNode_ShouldExecute

This commit is contained in:
rillig 2020-11-01 17:47:26 +00:00
parent 0056a7c168
commit 40014b1e5a
4 changed files with 19 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat.c,v 1.172 2020/10/31 18:20:00 rillig Exp $ */ /* $NetBSD: compat.c,v 1.173 2020/11/01 17:47:26 rillig Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California. * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -96,7 +96,7 @@
#include "pathnames.h" #include "pathnames.h"
/* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: compat.c,v 1.172 2020/10/31 18:20:00 rillig Exp $"); MAKE_RCSID("$NetBSD: compat.c,v 1.173 2020/11/01 17:47:26 rillig Exp $");
static GNode *curTarg = NULL; static GNode *curTarg = NULL;
static pid_t compatChild; static pid_t compatChild;
@ -274,7 +274,7 @@ Compat_RunCommand(const char *cmdp, GNode *gn)
* Print the command before echoing if we're not supposed to be quiet for * Print the command before echoing if we're not supposed to be quiet for
* this one. We also print the command if -n given. * this one. We also print the command if -n given.
*/ */
if (!silent || NoExecute(gn)) { if (!silent || !GNode_ShouldExecute(gn)) {
printf("%s\n", cmd); printf("%s\n", cmd);
fflush(stdout); fflush(stdout);
} }
@ -283,7 +283,7 @@ Compat_RunCommand(const char *cmdp, GNode *gn)
* If we're not supposed to execute any commands, this is as far as * If we're not supposed to execute any commands, this is as far as
* we go... * we go...
*/ */
if (!doIt && NoExecute(gn)) { if (!doIt && !GNode_ShouldExecute(gn)) {
return 0; return 0;
} }
DEBUG1(JOB, "Execute: '%s'\n", cmd); DEBUG1(JOB, "Execute: '%s'\n", cmd);
@ -548,7 +548,7 @@ Compat_Make(GNode *gn, GNode *pgn)
if (!opts.touchFlag || (gn->type & OP_MAKE)) { if (!opts.touchFlag || (gn->type & OP_MAKE)) {
curTarg = gn; curTarg = gn;
#ifdef USE_META #ifdef USE_META
if (useMeta && !NoExecute(gn)) { if (useMeta && GNode_ShouldExecute(gn)) {
meta_job_start(NULL, gn); meta_job_start(NULL, gn);
} }
#endif #endif
@ -561,7 +561,7 @@ Compat_Make(GNode *gn, GNode *pgn)
gn->made = ERROR; gn->made = ERROR;
} }
#ifdef USE_META #ifdef USE_META
if (useMeta && !NoExecute(gn)) { if (useMeta && GNode_ShouldExecute(gn)) {
if (meta_job_finish(NULL) != 0) if (meta_job_finish(NULL) != 0)
gn->made = ERROR; gn->made = ERROR;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.299 2020/11/01 17:07:03 rillig Exp $ */ /* $NetBSD: job.c,v 1.300 2020/11/01 17:47:26 rillig Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California. * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -143,7 +143,7 @@
#include "trace.h" #include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: job.c,v 1.299 2020/11/01 17:07:03 rillig Exp $"); MAKE_RCSID("$NetBSD: job.c,v 1.300 2020/11/01 17:47:26 rillig Exp $");
/* A shell defines how the commands are run. All commands for a target are /* A shell defines how the commands are run. All commands for a target are
* written into a single file, which is then given to the shell to execute * written into a single file, which is then given to the shell to execute
@ -731,7 +731,7 @@ JobPrintCommand(Job *job, char *cmd)
char *cmdStart; /* Start of expanded command */ char *cmdStart; /* Start of expanded command */
char *escCmd = NULL; /* Command with quotes/backticks escaped */ char *escCmd = NULL; /* Command with quotes/backticks escaped */
noSpecials = NoExecute(job->node); noSpecials = !GNode_ShouldExecute(job->node);
#define DBPRINTF(fmt, arg) if (DEBUG(JOB)) { \ #define DBPRINTF(fmt, arg) if (DEBUG(JOB)) { \
debug_printf(fmt, arg); \ debug_printf(fmt, arg); \
@ -1142,12 +1142,12 @@ Job_Touch(GNode *gn, Boolean silent)
return; return;
} }
if (!silent || NoExecute(gn)) { if (!silent || !GNode_ShouldExecute(gn)) {
(void)fprintf(stdout, "touch %s\n", gn->name); (void)fprintf(stdout, "touch %s\n", gn->name);
(void)fflush(stdout); (void)fflush(stdout);
} }
if (NoExecute(gn)) { if (!GNode_ShouldExecute(gn)) {
return; return;
} }
@ -1600,7 +1600,7 @@ JobStart(GNode *gn, int flags)
} }
free(tfile); free(tfile);
} else if (NoExecute(gn)) { } else if (!GNode_ShouldExecute(gn)) {
/* /*
* Not executing anything -- just print all the commands to stdout * Not executing anything -- just print all the commands to stdout
* in one fell swoop. This will still set up job->tailCmds correctly. * in one fell swoop. This will still set up job->tailCmds correctly.

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.c,v 1.185 2020/10/31 18:41:07 rillig Exp $ */ /* $NetBSD: make.c,v 1.186 2020/11/01 17:47:26 rillig Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1993 * Copyright (c) 1988, 1989, 1990, 1993
@ -107,7 +107,7 @@
#include "job.h" #include "job.h"
/* "@(#)make.c 8.1 (Berkeley) 6/6/93" */ /* "@(#)make.c 8.1 (Berkeley) 6/6/93" */
MAKE_RCSID("$NetBSD: make.c,v 1.185 2020/10/31 18:41:07 rillig Exp $"); MAKE_RCSID("$NetBSD: make.c,v 1.186 2020/11/01 17:47:26 rillig Exp $");
/* Sequence # to detect recursion. */ /* Sequence # to detect recursion. */
static unsigned int checked = 1; static unsigned int checked = 1;
@ -178,9 +178,9 @@ GNode_FprintDetails(FILE *f, const char *prefix, const GNode *gn,
} }
Boolean Boolean
NoExecute(GNode *gn) GNode_ShouldExecute(GNode *gn)
{ {
return (gn->type & OP_MAKE) ? opts.noRecursiveExecute : opts.noExecute; return !((gn->type & OP_MAKE) ? opts.noRecursiveExecute : opts.noExecute);
} }
/* Update the youngest child of the node, according to the given child. */ /* Update the youngest child of the node, according to the given child. */
@ -547,7 +547,7 @@ Make_Recheck(GNode *gn)
* the target is made now. Otherwise archives with ... rules * the target is made now. Otherwise archives with ... rules
* don't work! * don't work!
*/ */
if (NoExecute(gn) || (gn->type & OP_SAVE_CMDS) || if (!GNode_ShouldExecute(gn) || (gn->type & OP_SAVE_CMDS) ||
(mtime == 0 && !(gn->type & OP_WAIT))) { (mtime == 0 && !(gn->type & OP_WAIT))) {
DEBUG2(MAKE, " recheck(%s): update time from %s to now\n", DEBUG2(MAKE, " recheck(%s): update time from %s to now\n",
gn->name, Targ_FmtTime(gn->mtime)); gn->name, Targ_FmtTime(gn->mtime));

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.h,v 1.178 2020/10/31 11:54:33 rillig Exp $ */ /* $NetBSD: make.h,v 1.179 2020/11/01 17:47:26 rillig Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1993 * Copyright (c) 1988, 1989, 1990, 1993
@ -629,7 +629,7 @@ Boolean Main_SetObjdir(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
int mkTempFile(const char *, char **); int mkTempFile(const char *, char **);
int str2Lst_Append(StringList *, char *, const char *); int str2Lst_Append(StringList *, char *, const char *);
void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *); void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *);
Boolean NoExecute(GNode *gn); Boolean GNode_ShouldExecute(GNode *gn);
/* See if the node was seen on the left-hand side of a dependency operator. */ /* See if the node was seen on the left-hand side of a dependency operator. */
static MAKE_ATTR_UNUSED Boolean static MAKE_ATTR_UNUSED Boolean