Module Name: src
Committed By: rillig
Date: Wed Dec 20 09:03:09 UTC 2023
Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: var-scope-local.exp var-scope-local.mk
vardebug.exp varname-dot-shell.exp varname-dot-suffixes.exp
varname-dot-suffixes.mk varname-empty.exp
Log Message:
make: use consistent debug messages style when ignoring variables
When a variable is not modified or not deleted, clearly say so and state
the reason. Use the same style of debug messages everywhere, putting
the word 'ignoring' at the front. Previously, that word sticked out to
the right, but only in some cases.
To generate a diff of this commit:
cvs rdiff -u -r1.1085 -r1.1086 src/usr.bin/make/var.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-scope-local.exp \
src/usr.bin/make/unit-tests/varname-dot-suffixes.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/var-scope-local.mk
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/unit-tests/vardebug.exp
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/varname-dot-shell.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varname-dot-suffixes.mk
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varname-empty.exp
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/var.c
diff -u src/usr.bin/make/var.c:1.1085 src/usr.bin/make/var.c:1.1086
--- src/usr.bin/make/var.c:1.1085 Wed Dec 20 08:50:10 2023
+++ src/usr.bin/make/var.c Wed Dec 20 09:03:08 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.1085 2023/12/20 08:50:10 rillig Exp $ */
+/* $NetBSD: var.c,v 1.1086 2023/12/20 09:03:08 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1085 2023/12/20 08:50:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1086 2023/12/20 09:03:08 rillig Exp $");
/*
* Variables are defined using one of the VAR=value assignments. Their
@@ -929,15 +929,17 @@ Var_SetWithFlags(GNode *scope, const cha
assert(val != NULL);
if (name[0] == '\0') {
- DEBUG0(VAR, "SetVar: variable name is empty - ignored\n");
+ DEBUG3(VAR,
+ "%s: ignoring '%s = %s' as the variable name is empty\n",
+ scope->name, name, val);
return;
}
if (scope == SCOPE_GLOBAL && ExistsInCmdline(name)) {
DEBUG3(VAR,
- "%s: ignoring '%s' = '%s' "
+ "%s: ignoring '%s = %s' "
"due to a command line variable of the same name\n",
- SCOPE_GLOBAL->name, name, val);
+ scope->name, name, val);
return;
}
@@ -960,14 +962,16 @@ Var_SetWithFlags(GNode *scope, const cha
}
if (strcmp(name, ".SUFFIXES") == 0) {
/* special: treat as read-only */
- DEBUG3(VAR, "%s: %s = %s ignored (read-only)\n",
+ DEBUG3(VAR,
+ "%s: ignoring '%s = %s' as it is read-only\n",
scope->name, name, val);
return;
}
v = VarAdd(name, val, scope, flags);
} else {
if (v->readOnly && !(flags & VAR_SET_READONLY)) {
- DEBUG3(VAR, "%s: %s = %s ignored (read-only)\n",
+ DEBUG3(VAR,
+ "%s: ignoring '%s = %s' as it is read-only\n",
scope->name, name, val);
return;
}
@@ -1036,10 +1040,10 @@ Var_SetExpand(GNode *scope, const char *
Var_Expand(&varname, scope, VARE_WANTRES);
if (varname.str[0] == '\0') {
- DEBUG2(VAR,
- "Var_SetExpand: variable name \"%s\" expands "
- "to empty string, with value \"%s\" - ignored\n",
- unexpanded_name, val);
+ DEBUG4(VAR,
+ "%s: ignoring '%s = %s' "
+ "as the variable name '%s' expands to empty\n",
+ scope->name, varname.str, val, unexpanded_name);
} else
Var_SetWithFlags(scope, varname.str, val, VAR_SET_NONE);
@@ -1080,8 +1084,8 @@ Var_Append(GNode *scope, const char *nam
if (v == NULL) {
Var_SetWithFlags(scope, name, val, VAR_SET_NONE);
} else if (v->readOnly) {
- DEBUG1(VAR, "Ignoring append to %s since it is read-only\n",
- name);
+ DEBUG3(VAR, "%s: ignoring '%s += %s' as it is read-only\n",
+ scope->name, name, val);
} else if (scope == SCOPE_CMDLINE || !v->fromCmd) {
Buf_AddByte(&v->val, ' ');
Buf_AddStr(&v->val, val);
@@ -1130,10 +1134,10 @@ Var_AppendExpand(GNode *scope, const cha
Var_Expand(&xname, scope, VARE_WANTRES);
if (xname.str != name && xname.str[0] == '\0')
- DEBUG2(VAR,
- "Var_AppendExpand: variable name \"%s\" expands "
- "to empty string, with value \"%s\" - ignored\n",
- name, val);
+ DEBUG4(VAR,
+ "%s: ignoring '%s += %s' "
+ "as the variable name '%s' expands to empty\n",
+ scope->name, xname.str, val, name);
else
Var_Append(scope, xname.str, val);
Index: src/usr.bin/make/unit-tests/var-scope-local.exp
diff -u src/usr.bin/make/unit-tests/var-scope-local.exp:1.6 src/usr.bin/make/unit-tests/var-scope-local.exp:1.7
--- src/usr.bin/make/unit-tests/var-scope-local.exp:1.6 Sat Apr 29 10:16:24 2023
+++ src/usr.bin/make/unit-tests/var-scope-local.exp Wed Dec 20 09:03:09 2023
@@ -1,8 +1,8 @@
Global: .ALLTARGETS = all target-rule.ext dir/subdir/target-rule.ext target-rule.ir-gen-from dir/subdir/target-rule-dir.ir-gen-from inference-rule.ir-to dir/subdir/inference-rule.ir-to inference-rule.ir-from dir/subdir/inference-rule.ir-from inference-rule-chain.ir-to dir/subdir/inference-rule-chain.ir-to inference-rule-chain.ir-gen-from dir/subdir/inference-rule-chain.ir-gen-from one
Global: .ALLTARGETS = all target-rule.ext dir/subdir/target-rule.ext target-rule.ir-gen-from dir/subdir/target-rule-dir.ir-gen-from inference-rule.ir-to dir/subdir/inference-rule.ir-to inference-rule.ir-from dir/subdir/inference-rule.ir-from inference-rule-chain.ir-to dir/subdir/inference-rule-chain.ir-to inference-rule-chain.ir-gen-from dir/subdir/inference-rule-chain.ir-gen-from one two
Var_Parse: ${.MAKE.TARGET_LOCAL_VARIABLES} (eval)
-Var_SetExpand: variable name "" expands to empty string, with value "three" - ignored
-Var_SetExpand: variable name "" expands to empty string, with value "three" - ignored
+one: ignoring ' = three' as the variable name '' expands to empty
+two: ignoring ' = three' as the variable name '' expands to empty
Global: one two = # (empty)
Global: one two = three
Global: .MAKEFLAGS = -r -k -d v -d
Index: src/usr.bin/make/unit-tests/varname-dot-suffixes.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-suffixes.exp:1.6 src/usr.bin/make/unit-tests/varname-dot-suffixes.exp:1.7
--- src/usr.bin/make/unit-tests/varname-dot-suffixes.exp:1.6 Wed Dec 20 08:50:10 2023
+++ src/usr.bin/make/unit-tests/varname-dot-suffixes.exp Wed Dec 20 09:03:09 2023
@@ -1,20 +1,20 @@
Global: ignoring delete '.SUFFIXES' as it is not found
Global: .MAKEFLAGS = -r -k -d v -d
Global: .MAKEFLAGS = -r -k -d v -d 0
-Global: .SUFFIXES = set ignored (read-only)
-Global: .SUFFIXES = append ignored (read-only)
+Global: ignoring '.SUFFIXES = set' as it is read-only
+Global: ignoring '.SUFFIXES = append' as it is read-only
Global: _ = # (empty)
Var_Parse: ${.SUFFIXES::=assign} (eval-keep-dollar-and-undefined)
Evaluating modifier ${.SUFFIXES::...} on value ".c .o .1 .err .tar.gz" (eval-keep-dollar-and-undefined, regular)
Modifier part: "assign"
-Global: .SUFFIXES = assign ignored (read-only)
+Global: ignoring '.SUFFIXES = assign' as it is read-only
Result of ${.SUFFIXES::=assign} is "" (eval-keep-dollar-and-undefined, regular)
Global: _ = # (empty)
Var_Parse: ${preserve:L:_=.SUFFIXES} (eval-keep-dollar-and-undefined)
Evaluating modifier ${preserve:L} on value "" (eval-keep-dollar-and-undefined, undefined)
Result of ${preserve:L} is "preserve" (eval-keep-dollar-and-undefined, defined)
Evaluating modifier ${preserve:_...} on value "preserve" (eval-keep-dollar-and-undefined, defined)
-Global: .SUFFIXES = preserve ignored (read-only)
+Global: ignoring '.SUFFIXES = preserve' as it is read-only
Result of ${preserve:_=.SUFFIXES} is "preserve" (eval-keep-dollar-and-undefined, defined)
Global: _ = preserve
Global: .MAKEFLAGS = -r -k -d v -d 0 -d v -d
@@ -26,10 +26,10 @@ Evaluating modifier ${1 2:@...} on value
Modifier part: ".SUFFIXES"
Modifier part: "${.SUFFIXES}"
ModifyWords: split "1 2" into 2 words
-Command: .SUFFIXES = 1 ignored (read-only)
+Command: ignoring '.SUFFIXES = 1' as it is read-only
Var_Parse: ${.SUFFIXES} (eval-defined)
ModifyWord_Loop: in "1", replace ".SUFFIXES" with "${.SUFFIXES}" to ".c .o .1 .err .tar.gz"
-Command: .SUFFIXES = 2 ignored (read-only)
+Command: ignoring '.SUFFIXES = 2' as it is read-only
Var_Parse: ${.SUFFIXES} (eval-defined)
ModifyWord_Loop: in "2", replace ".SUFFIXES" with "${.SUFFIXES}" to ".c .o .1 .err .tar.gz"
Command: ignoring delete '.SUFFIXES' as it is not found
Index: src/usr.bin/make/unit-tests/var-scope-local.mk
diff -u src/usr.bin/make/unit-tests/var-scope-local.mk:1.8 src/usr.bin/make/unit-tests/var-scope-local.mk:1.9
--- src/usr.bin/make/unit-tests/var-scope-local.mk:1.8 Sun Nov 19 21:47:52 2023
+++ src/usr.bin/make/unit-tests/var-scope-local.mk Wed Dec 20 09:03:09 2023
@@ -1,4 +1,4 @@
-# $NetBSD: var-scope-local.mk,v 1.8 2023/11/19 21:47:52 rillig Exp $
+# $NetBSD: var-scope-local.mk,v 1.9 2023/12/20 09:03:09 rillig Exp $
#
# Tests for target-local variables, such as ${.TARGET} or $@. These variables
# are relatively short-lived as they are created just before making the
@@ -146,8 +146,8 @@ dir/subdir/inference-rule-chain.ir-gen-f
#
# The empty variable name is expanded twice, once for 'one' and once for
# 'two'.
-# expect: Var_SetExpand: variable name "" expands to empty string, with value "three" - ignored
-# expect: Var_SetExpand: variable name "" expands to empty string, with value "three" - ignored
+# expect: one: ignoring ' = three' as the variable name '' expands to empty
+# expect: two: ignoring ' = three' as the variable name '' expands to empty
one two:=three
# If the two targets to the left are generated by an expression, the
# line is parsed as a variable assignment since its left-hand side is a single
Index: src/usr.bin/make/unit-tests/vardebug.exp
diff -u src/usr.bin/make/unit-tests/vardebug.exp:1.32 src/usr.bin/make/unit-tests/vardebug.exp:1.33
--- src/usr.bin/make/unit-tests/vardebug.exp:1.32 Wed Dec 20 08:50:10 2023
+++ src/usr.bin/make/unit-tests/vardebug.exp Wed Dec 20 09:03:09 2023
@@ -5,9 +5,9 @@ Global: VAR = added
Global: VAR = overwritten
Global: delete VAR
Global: ignoring delete 'VAR' as it is not found
-Var_SetExpand: variable name "${:U}" expands to empty string, with value "empty name" - ignored
-Var_AppendExpand: variable name "${:U}" expands to empty string, with value "empty name" - ignored
-Global: ignoring 'FROM_CMDLINE' = 'overwritten' due to a command line variable of the same name
+Global: ignoring ' = empty name' as the variable name '${:U}' expands to empty
+Global: ignoring ' += empty name' as the variable name '${:U}' expands to empty
+Global: ignoring 'FROM_CMDLINE = overwritten' due to a command line variable of the same name
Global: VAR = 1
Global: VAR = 1 2
Global: VAR = 1 2 3
@@ -61,7 +61,7 @@ Var_Parse: ${UNDEFINED} (eval-defined)
make: "vardebug.mk" line 56: Malformed conditional (${UNDEFINED})
Global: ignoring delete '.SHELL' as it is not found
Command: .SHELL = </path/to/shell>
-Command: .SHELL = overwritten ignored (read-only)
+Command: ignoring '.SHELL = overwritten' as it is read-only
Global: .MAKEFLAGS = -r -k -d v -d
Global: .MAKEFLAGS = -r -k -d v -d 0
make: Fatal errors encountered -- cannot continue
Index: src/usr.bin/make/unit-tests/varname-dot-shell.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.19 src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.20
--- src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.19 Wed Dec 20 08:50:10 2023
+++ src/usr.bin/make/unit-tests/varname-dot-shell.exp Wed Dec 20 09:03:09 2023
@@ -5,14 +5,14 @@ Global: ignoring delete '.SHELL' as it i
Command: .SHELL = (details omitted)
Global: ORIG_SHELL = (details omitted)
Parsing line 12: .SHELL= overwritten
-Global: ignoring '.SHELL' = 'overwritten' due to a command line variable of the same name
+Global: ignoring '.SHELL = overwritten' due to a command line variable of the same name
CondParser_Eval: ${.SHELL} != ${ORIG_SHELL}
Var_Parse: ${.SHELL} != ${ORIG_SHELL} (eval-defined)
Var_Parse: ${ORIG_SHELL} (eval-defined)
Comparing "(details omitted)" != "(details omitted)"
Parsing line 19: .MAKEFLAGS: .SHELL+=appended
ParseDependency(.MAKEFLAGS: .SHELL+=appended)
-Ignoring append to .SHELL since it is read-only
+Command: ignoring '.SHELL += appended' as it is read-only
CondParser_Eval: ${.SHELL} != ${ORIG_SHELL}
Var_Parse: ${.SHELL} != ${ORIG_SHELL} (eval-defined)
Var_Parse: ${ORIG_SHELL} (eval-defined)
@@ -20,7 +20,7 @@ Comparing "(details omitted)" != "(detai
Parsing line 27: .undef .SHELL
Global: ignoring delete '.SHELL' as it is not found
Parsing line 28: .SHELL= newly overwritten
-Global: ignoring '.SHELL' = 'newly overwritten' due to a command line variable of the same name
+Global: ignoring '.SHELL = newly overwritten' due to a command line variable of the same name
CondParser_Eval: ${.SHELL} != ${ORIG_SHELL}
Var_Parse: ${.SHELL} != ${ORIG_SHELL} (eval-defined)
Var_Parse: ${ORIG_SHELL} (eval-defined)
Index: src/usr.bin/make/unit-tests/varname-dot-suffixes.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-suffixes.mk:1.4 src/usr.bin/make/unit-tests/varname-dot-suffixes.mk:1.5
--- src/usr.bin/make/unit-tests/varname-dot-suffixes.mk:1.4 Wed Dec 20 08:50:10 2023
+++ src/usr.bin/make/unit-tests/varname-dot-suffixes.mk Wed Dec 20 09:03:09 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varname-dot-suffixes.mk,v 1.4 2023/12/20 08:50:10 rillig Exp $
+# $NetBSD: varname-dot-suffixes.mk,v 1.5 2023/12/20 09:03:09 rillig Exp $
#
# Tests for the special "variable" .SUFFIXES, which lists the suffixes that
# have been registered for use in suffix transformation rules. Suffixes are
@@ -61,13 +61,13 @@
# The list of suffixes can only be modified using dependency declarations, any
# attempt at setting the variable named '.SUFFIXES' is rejected.
.MAKEFLAGS: -dv
-# expect: Global: .SUFFIXES = set ignored (read-only)
+# expect: Global: ignoring '.SUFFIXES = set' as it is read-only
.SUFFIXES= set
-# expect: Global: .SUFFIXES = append ignored (read-only)
+# expect: Global: ignoring '.SUFFIXES = append' as it is read-only
.SUFFIXES+= append
-# expect: Global: .SUFFIXES = assign ignored (read-only)
+# expect: Global: ignoring '.SUFFIXES = assign' as it is read-only
_:= ${.SUFFIXES::=assign}
-# expect: Global: .SUFFIXES = preserve ignored (read-only)
+# expect: Global: ignoring '.SUFFIXES = preserve' as it is read-only
_:= ${preserve:L:_=.SUFFIXES}
.MAKEFLAGS: -d0
@@ -94,8 +94,8 @@ _:= ${preserve:L:_=.SUFFIXES}
# the name would be '.SUFFIXES.', furthermore the name of the iteration
# variable is typically in singular form.
.MAKEFLAGS: -dv
-# expect: Command: .SUFFIXES = 1 ignored (read-only)
-# expect: Command: .SUFFIXES = 2 ignored (read-only)
+# expect: Command: ignoring '.SUFFIXES = 1' as it is read-only
+# expect: Command: ignoring '.SUFFIXES = 2' as it is read-only
# expect: Command: ignoring delete '.SUFFIXES' as it is not found
.if ${1 2:L:@.SUFFIXES@${.SUFFIXES}@} != ".c .o .1 .err .tar.gz .c .o .1 .err .tar.gz"
. error
Index: src/usr.bin/make/unit-tests/varname-empty.exp
diff -u src/usr.bin/make/unit-tests/varname-empty.exp:1.21 src/usr.bin/make/unit-tests/varname-empty.exp:1.22
--- src/usr.bin/make/unit-tests/varname-empty.exp:1.21 Wed Dec 20 08:50:10 2023
+++ src/usr.bin/make/unit-tests/varname-empty.exp Wed Dec 20 09:03:09 2023
@@ -1,5 +1,5 @@
-Var_SetExpand: variable name "${:U}" expands to empty string, with value "cmdline-u" - ignored
-Var_SetExpand: variable name "" expands to empty string, with value "cmdline-plain" - ignored
+Command: ignoring ' = cmdline-u' as the variable name '${:U}' expands to empty
+Command: ignoring ' = cmdline-plain' as the variable name '' expands to empty
Global: .CURDIR = <curdir>
Var_Parse: ${MAKE_OBJDIR_CHECK_WRITABLE} (eval)
Global: .TARGETS = # (empty)
@@ -8,15 +8,15 @@ Global: .MAKE.MAKEFILES = varname-empty.
Global: .PARSEFILE = varname-empty.mk
Global: ignoring delete '.INCLUDEDFROMDIR' as it is not found
Global: ignoring delete '.INCLUDEDFROMFILE' as it is not found
-Var_SetExpand: variable name "" expands to empty string, with value "default" - ignored
-Var_SetExpand: variable name "" expands to empty string, with value "assigned" - ignored
-SetVar: variable name is empty - ignored
-Var_SetExpand: variable name "" expands to empty string, with value "" - ignored
-Var_SetExpand: variable name "" expands to empty string, with value "subst" - ignored
+Global: ignoring ' = default' as the variable name '' expands to empty
+Global: ignoring ' = assigned' as the variable name '' expands to empty
+Global: ignoring ' = appended' as the variable name is empty
+Global: ignoring ' = ' as the variable name '' expands to empty
+Global: ignoring ' = subst' as the variable name '' expands to empty
Capturing the output of command "echo 'shell-output'"
-Var_SetExpand: variable name "" expands to empty string, with value "shell-output" - ignored
-Var_SetExpand: variable name "${:U}" expands to empty string, with value "assigned indirectly" - ignored
-Var_AppendExpand: variable name "${:U}" expands to empty string, with value "appended indirectly" - ignored
+Global: ignoring ' = shell-output' as the variable name '' expands to empty
+Global: ignoring ' = assigned indirectly' as the variable name '${:U}' expands to empty
+Global: ignoring ' += appended indirectly' as the variable name '${:U}' expands to empty
Global: .MAKEFLAGS = -r -d v -d
Global: .MAKEFLAGS = -r -d v -d 0
out: fallback