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(1): fix .ERROR_TARGET in compat -k mode (s...



details:   https://anonhg.NetBSD.org/src/rev/d54eca40afc3
branches:  trunk
changeset: 957879:d54eca40afc3
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Dec 13 19:33:53 2020 +0000

description:
make(1): fix .ERROR_TARGET in compat -k mode (since 2010-04-07)

diffstat:

 usr.bin/make/compat.c                    |  30 +++++++++++-------------------
 usr.bin/make/unit-tests/compat-error.exp |   2 +-
 usr.bin/make/unit-tests/compat-error.mk  |   8 ++++++--
 3 files changed, 18 insertions(+), 22 deletions(-)

diffs (102 lines):

diff -r 53be8917fef3 -r d54eca40afc3 usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Sun Dec 13 19:22:02 2020 +0000
+++ b/usr.bin/make/compat.c     Sun Dec 13 19:33:53 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.214 2020/12/13 18:57:44 rillig Exp $      */
+/*     $NetBSD: compat.c,v 1.215 2020/12/13 19:33:53 rillig Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*     "@(#)compat.c   8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.214 2020/12/13 18:57:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.215 2020/12/13 19:33:53 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -706,8 +706,7 @@
 void
 Compat_Run(GNodeList *targs)
 {
-       GNode *gn = NULL;       /* Current root target */
-       Boolean seenError;
+       GNode *errorNode = NULL;
 
        if (!shellName)
                Shell_Init();
@@ -728,9 +727,8 @@
         */
        Make_ExpandUse(targs);
 
-       seenError = FALSE;
        while (!Lst_IsEmpty(targs)) {
-               gn = Lst_Dequeue(targs);
+               GNode *gn = Lst_Dequeue(targs);
                Compat_Make(gn, gn);
 
                if (gn->made == UPTODATE) {
@@ -739,26 +737,20 @@
                        printf("`%s' not remade because of errors.\n",
                               gn->name);
                }
-               if (GNode_IsError(gn)) {
-                       seenError = TRUE;
-                       /* XXX: In case of error, set the error node. */
-               }
+               if (GNode_IsError(gn) && errorNode == NULL)
+                       errorNode = gn;
        }
 
        /* If the user has defined a .END target, run its commands. */
-       if (!seenError) {
+       if (errorNode == NULL) {
                GNode *endNode = Targ_GetEndNode();
                Compat_Make(endNode, endNode);
-               seenError = GNode_IsError(endNode);
-               /* XXX: In case of error, set the error node. */
+               if (GNode_IsError(endNode))
+                       errorNode = endNode;
        }
 
-       if (seenError) {
-               /*
-                * XXX: Instead of gn, it makes more sense to report the
-                * first error node.
-                */
-               PrintOnError(gn, "\nStop.");
+       if (errorNode != NULL) {
+               PrintOnError(errorNode, "\nStop.");
                exit(1);
        }
 }
diff -r 53be8917fef3 -r d54eca40afc3 usr.bin/make/unit-tests/compat-error.exp
--- a/usr.bin/make/unit-tests/compat-error.exp  Sun Dec 13 19:22:02 2020 +0000
+++ b/usr.bin/make/unit-tests/compat-error.exp  Sun Dec 13 19:33:53 2020 +0000
@@ -10,6 +10,6 @@
 
 Stop.
 make: stopped in unit-tests
-.ERROR target: <success3>
+.ERROR target: <fail1>
 .ERROR command: <>
 exit status 1
diff -r 53be8917fef3 -r d54eca40afc3 usr.bin/make/unit-tests/compat-error.mk
--- a/usr.bin/make/unit-tests/compat-error.mk   Sun Dec 13 19:22:02 2020 +0000
+++ b/usr.bin/make/unit-tests/compat-error.mk   Sun Dec 13 19:33:53 2020 +0000
@@ -1,8 +1,12 @@
-# $NetBSD: compat-error.mk,v 1.2 2020/12/13 19:08:20 rillig Exp $
+# $NetBSD: compat-error.mk,v 1.3 2020/12/13 19:33:53 rillig Exp $
 #
 # Test detailed error handling in compat mode.
 #
-# XXX: As of 2020-12-13, .ERROR_TARGET is success3, which is wrong.
+# Until 2020-12-13, .ERROR_TARGET was success3, which was wrong.
+# Since compat.c 1.215 from 2020-12-13, it is 'fail1', which is the first
+# failed top-level target.  XXX: Even better would be if .ERROR_TARGET were
+# the smallest target that caused the build to fail, even if it were a
+# sub-sub-sub-dependency of a top-level target.
 #
 # XXX: As of 2020-12-13, .ERROR_CMD is empty, which is wrong.
 #



Home | Main Index | Thread Index | Old Index