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: with the option -de in jobs mode, output ...



details:   https://anonhg.NetBSD.org/src/rev/b35c0097e547
branches:  trunk
changeset: 1026532:b35c0097e547
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 28 00:02:07 2021 +0000

description:
make: with the option -de in jobs mode, output expanded commands

This helps tracking down the actual cause of build failures in build
systems like NetBSD's build.sh that use highly abstracted commands that
are mainly defined in terms of variables.

diffstat:

 usr.bin/make/job.c                                |  22 ++++++++++++++++------
 usr.bin/make/unit-tests/opt-debug-errors-jobs.exp |   3 +++
 2 files changed, 19 insertions(+), 6 deletions(-)

diffs (63 lines):

diff -r 462c62a268fd -r b35c0097e547 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sat Nov 27 23:56:11 2021 +0000
+++ b/usr.bin/make/job.c        Sun Nov 28 00:02:07 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.436 2021/10/24 18:45:46 sjg Exp $    */
+/*     $NetBSD: job.c,v 1.437 2021/11/28 00:02:07 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -142,7 +142,7 @@
 #include "trace.h"
 
 /*     "@(#)job.c      8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.436 2021/10/24 18:45:46 sjg Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.437 2021/11/28 00:02:07 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -1068,10 +1068,20 @@
        if (!DEBUG(ERROR))
                return;
 
-       debug_printf("\n*** Failed target: %s\n*** Failed commands:\n",
-           job->node->name);
-       for (ln = job->node->commands.first; ln != NULL; ln = ln->next)
-               debug_printf("\t%s\n", (const char *)ln->datum);
+       debug_printf("\n");
+       debug_printf("*** Failed target: %s\n", job->node->name);
+       debug_printf("*** Failed commands:\n");
+       for (ln = job->node->commands.first; ln != NULL; ln = ln->next) {
+               const char *unexpanded = (const char *)ln->datum;
+               debug_printf("\t%s\n", unexpanded);
+
+               if (strchr(unexpanded, '$') != NULL) {
+                       char *expanded;
+                       (void)Var_Subst((const char *)ln->datum, job->node,
+                           VARE_WANTRES, &expanded);
+                       debug_printf("\t=> %s\n", expanded);
+               }
+       }
 }
 
 static void
diff -r 462c62a268fd -r b35c0097e547 usr.bin/make/unit-tests/opt-debug-errors-jobs.exp
--- a/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp Sat Nov 27 23:56:11 2021 +0000
+++ b/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp Sun Nov 28 00:02:07 2021 +0000
@@ -24,6 +24,8 @@
 *** Failed target: fail-newline
 *** Failed commands:
        echo 'line1${.newline}line2'; false
+       => echo 'line1
+line2'; false
 *** [fail-newline] Error code 1
 
 make: stopped in unit-tests
@@ -49,6 +51,7 @@
 *** Failed target: fail-vars
 *** Failed commands:
        @${COMPILE_C} ${COMPILE_C_FLAGS}
+       => @false c-compiler flag1 -macro="several words"
 *** [fail-vars] Error code 1
 
 make: stopped in unit-tests



Home | Main Index | Thread Index | Old Index