Module Name:    src
Committed By:   rillig
Date:           Sat Oct  3 13:06:56 UTC 2020

Modified Files:
        src/usr.bin/make: main.c
        src/usr.bin/make/unit-tests: opt-debug.exp opt-debug.mk

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.361 -r1.362 src/usr.bin/make/main.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-debug.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-debug.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.361 src/usr.bin/make/main.c:1.362
--- src/usr.bin/make/main.c:1.361	Thu Oct  1 23:52:51 2020
+++ src/usr.bin/make/main.c	Sat Oct  3 13:06:56 2020
@@ -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 @@ parse_debug_options(const char *argvalue
 
 	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;

Index: src/usr.bin/make/unit-tests/opt-debug.exp
diff -u src/usr.bin/make/unit-tests/opt-debug.exp:1.1 src/usr.bin/make/unit-tests/opt-debug.exp:1.2
--- src/usr.bin/make/unit-tests/opt-debug.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/opt-debug.exp	Sat Oct  3 13:06:56 2020
@@ -1 +1,4 @@
+Global:VAR = value
+Global:.MAKEFLAGS =  -r -k -d v -d
+Global:.MAKEFLAGS =  -r -k -d v -d 0
 exit status 0

Index: src/usr.bin/make/unit-tests/opt-debug.mk
diff -u src/usr.bin/make/unit-tests/opt-debug.mk:1.2 src/usr.bin/make/unit-tests/opt-debug.mk:1.3
--- src/usr.bin/make/unit-tests/opt-debug.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/opt-debug.mk	Sat Oct  3 13:06:56 2020
@@ -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.
 
-# TODO: Implementation
+# Enable debug logging for the variables (var.c).
+.MAKEFLAGS: -dv
+
+VAR=	value
+
+# Disable all debug logging again.
+.MAKEFLAGS: -d0			# -d0 is available since 2020-10-03
 
 all:
 	@:;

Reply via email to