make: extract OP_NOTARGET into separate function

No binary change, except for line numbers in assertions.
This commit is contained in:
rillig 2021-12-28 14:06:42 +00:00
parent 6225e78e6c
commit 62a0c54367
3 changed files with 18 additions and 13 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.h,v 1.279 2021/12/27 18:26:22 rillig Exp $ */
/* $NetBSD: make.h,v 1.280 2021/12/28 14:06:42 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -360,8 +360,6 @@ typedef enum GNodeType {
OP_DEPS_FOUND = 1 << 24,
/* Node found while expanding .ALLSRC */
OP_MARK = 1 << 23,
OP_NOTARGET = OP_NOTMAIN | OP_USE | OP_EXEC | OP_TRANSFORM
} GNodeType;
typedef struct GNodeFlags {
@ -815,6 +813,14 @@ GNode_IsError(const GNode *gn)
return gn->made == ERROR || gn->made == ABORTED;
}
MAKE_INLINE bool MAKE_ATTR_USE
GNode_IsMainCandidate(const GNode *gn)
{
/* XXX: What about OP_USEBEFORE? */
return (gn->type & (OP_NOTMAIN | OP_USE | OP_EXEC | OP_TRANSFORM)) ==
0;
}
MAKE_INLINE const char * MAKE_ATTR_USE
GNode_VarTarget(GNode *gn) { return GNode_ValueDirect(gn, TARGET); }
MAKE_INLINE const char * MAKE_ATTR_USE

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.588 2021/12/28 01:27:37 rillig Exp $ */
/* $NetBSD: parse.c,v 1.589 2021/12/28 14:06:42 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -109,7 +109,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: parse.c,v 1.588 2021/12/28 01:27:37 rillig Exp $");
MAKE_RCSID("$NetBSD: parse.c,v 1.589 2021/12/28 14:06:42 rillig Exp $");
/* types and constants */
@ -154,8 +154,7 @@ typedef enum ParseSpecial {
SP_INCLUDES, /* .INCLUDES; not mentioned in the manual page */
SP_INTERRUPT, /* .INTERRUPT */
SP_LIBS, /* .LIBS; not mentioned in the manual page */
/* .MAIN and we don't have anything user-specified to make */
SP_MAIN,
SP_MAIN, /* .MAIN and no user-specified targets to make */
SP_META, /* .META */
SP_MFLAGS, /* .MFLAGS or .MAKEFLAGS */
SP_NOMETA, /* .NOMETA */
@ -187,8 +186,8 @@ typedef ListNode SearchPathListNode;
/* result data */
/*
* The main target to create. This is the first target on the first
* dependency line in the first makefile.
* The main target to create. This is the first target defined in any of the
* makefiles.
*/
static GNode *mainNode;
@ -981,7 +980,7 @@ FindMainTarget(void)
for (ln = targets->first; ln != NULL; ln = ln->next) {
GNode *gn = ln->datum;
if (!(gn->type & OP_NOTARGET)) {
if (GNode_IsMainCandidate(gn)) {
DEBUG1(MAKE, "Setting main node to \"%s\"\n", gn->name);
mainNode = gn;
Targ_SetMain(gn);

View File

@ -1,4 +1,4 @@
/* $NetBSD: suff.c,v 1.360 2021/12/15 12:58:01 rillig Exp $ */
/* $NetBSD: suff.c,v 1.361 2021/12/28 14:06:42 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -115,7 +115,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
MAKE_RCSID("$NetBSD: suff.c,v 1.360 2021/12/15 12:58:01 rillig Exp $");
MAKE_RCSID("$NetBSD: suff.c,v 1.361 2021/12/28 14:06:42 rillig Exp $");
typedef List SuffixList;
typedef ListNode SuffixListNode;
@ -741,7 +741,7 @@ UpdateTarget(GNode *target, GNode **inout_main, Suffix *suff,
char *ptr;
if (*inout_main == NULL && *inout_removedMain &&
!(target->type & OP_NOTARGET)) {
GNode_IsMainCandidate(target)) {
DEBUG1(MAKE, "Setting main node to \"%s\"\n", target->name);
*inout_main = target;
Targ_SetMain(target);