Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make: extract OP_NOTARGET into separate function



details:   https://anonhg.NetBSD.org/src/rev/0ba0b2bfa3d1
branches:  trunk
changeset: 1029242:0ba0b2bfa3d1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Dec 28 14:06:42 2021 +0000

description:
make: extract OP_NOTARGET into separate function

No binary change, except for line numbers in assertions.

diffstat:

 usr.bin/make/make.h  |  12 +++++++++---
 usr.bin/make/parse.c |  13 ++++++-------
 usr.bin/make/suff.c  |   6 +++---
 3 files changed, 18 insertions(+), 13 deletions(-)

diffs (108 lines):

diff -r f4a94490f1b7 -r 0ba0b2bfa3d1 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Tue Dec 28 13:41:12 2021 +0000
+++ b/usr.bin/make/make.h       Tue Dec 28 14:06:42 2021 +0000
@@ -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 @@
        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 @@
        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
diff -r f4a94490f1b7 -r 0ba0b2bfa3d1 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Tue Dec 28 13:41:12 2021 +0000
+++ b/usr.bin/make/parse.c      Tue Dec 28 14:06:42 2021 +0000
@@ -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 @@
        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 @@
 /* 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 @@
 
        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);
diff -r f4a94490f1b7 -r 0ba0b2bfa3d1 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Tue Dec 28 13:41:12 2021 +0000
+++ b/usr.bin/make/suff.c       Tue Dec 28 14:06:42 2021 +0000
@@ -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 @@
        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);



Home | Main Index | Thread Index | Old Index