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): allow to disable debug logging options



details:   https://anonhg.NetBSD.org/src/rev/4a827131f445
branches:  trunk
changeset: 944544:4a827131f445
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 03 13:06:56 2020 +0000

description:
make(1): allow to disable debug logging options

This is only intended for the unit tests, to selectively enable and
disable debug logging as needed.  Previously the tests for debug logging
required complicated postprocessing that was not obvious when looking at
the test .mk file alone, but was specified externally in
unit-tests/Makefile.

This is the simplest possible implementation.  Another variant would
have been to selectively disable individual debug logging options, but
that would have made the code more complicated.

The -dL option is not affected by -d0 since that is not really a debug
option, even if it is implemented as one.

diffstat:

 usr.bin/make/main.c                   |   7 +++++--
 usr.bin/make/unit-tests/opt-debug.exp |   3 +++
 usr.bin/make/unit-tests/opt-debug.mk  |  12 +++++++++---
 3 files changed, 17 insertions(+), 5 deletions(-)

diffs (57 lines):

diff -r 02d55af6288e -r 4a827131f445 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sat Oct 03 12:51:49 2020 +0000
+++ b/usr.bin/make/main.c       Sat Oct 03 13:06:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.361 2020/10/01 23:52:51 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.362 2020/10/03 13:06:56 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #endif
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.361 2020/10/01 23:52:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.362 2020/10/03 13:06:56 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
  The Regents of the University of California.  All rights reserved.");
@@ -270,6 +270,9 @@
 
        for (modules = argvalue; *modules; ++modules) {
                switch (*modules) {
+               case '0':       /* undocumented, only intended for tests */
+                       debug &= DEBUG_LINT;
+                       break;
                case 'A':
                        debug = ~(0|DEBUG_LINT);
                        break;
diff -r 02d55af6288e -r 4a827131f445 usr.bin/make/unit-tests/opt-debug.exp
--- a/usr.bin/make/unit-tests/opt-debug.exp     Sat Oct 03 12:51:49 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-debug.exp     Sat Oct 03 13:06:56 2020 +0000
@@ -1,1 +1,4 @@
+Global:VAR = value
+Global:.MAKEFLAGS =  -r -k -d v -d
+Global:.MAKEFLAGS =  -r -k -d v -d 0
 exit status 0
diff -r 02d55af6288e -r 4a827131f445 usr.bin/make/unit-tests/opt-debug.mk
--- a/usr.bin/make/unit-tests/opt-debug.mk      Sat Oct 03 12:51:49 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-debug.mk      Sat Oct 03 13:06:56 2020 +0000
@@ -1,8 +1,14 @@
-# $NetBSD: opt-debug.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: opt-debug.mk,v 1.3 2020/10/03 13:06:56 rillig Exp $
 #
-# Tests for the -d command line option.
+# Tests for the -d command line option, which controls debug logging.
+
+# Enable debug logging for the variables (var.c).
+.MAKEFLAGS: -dv
 
-# TODO: Implementation
+VAR=   value
+
+# Disable all debug logging again.
+.MAKEFLAGS: -d0                        # -d0 is available since 2020-10-03
 
 all:
        @:;



Home | Main Index | Thread Index | Old Index