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): add test for the global variable 'targ...



details:   https://anonhg.NetBSD.org/src/rev/583379247b90
branches:  trunk
changeset: 938788:583379247b90
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Sep 14 18:21:26 2020 +0000

description:
make(1): add test for the global variable 'targets' in parse.c

diffstat:

 usr.bin/make/parse.c               |  10 ++++++----
 usr.bin/make/unit-tests/deptgt.exp |   5 ++++-
 usr.bin/make/unit-tests/deptgt.mk  |  19 ++++++++++++++++++-
 3 files changed, 28 insertions(+), 6 deletions(-)

diffs (80 lines):

diff -r d83fa8d2331e -r 583379247b90 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Mon Sep 14 17:47:05 2020 +0000
+++ b/usr.bin/make/parse.c      Mon Sep 14 18:21:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.317 2020/09/14 17:47:05 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.318 2020/09/14 18:21:26 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.317 2020/09/14 17:47:05 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.318 2020/09/14 18:21:26 rillig Exp $");
 
 /* types and constants */
 
@@ -214,7 +214,9 @@
 
 /* eval state */
 
-/* targets we're working on */
+/* During parsing, the targets from the previous dependency line.
+ *
+ * See unit-tests/deptgt.mk, keyword "parse.c:targets". */
 static Lst targets;
 
 #ifdef CLEANUP
@@ -3034,7 +3036,7 @@
            line = Var_Subst(line, VAR_CMD, VARE_UNDEFERR|VARE_WANTRES);
 
            /*
-            * Need a non-circular list for the target nodes
+            * Need a list for the target nodes
             */
            if (targets != NULL)
                Lst_Free(targets);
diff -r d83fa8d2331e -r 583379247b90 usr.bin/make/unit-tests/deptgt.exp
--- a/usr.bin/make/unit-tests/deptgt.exp        Mon Sep 14 17:47:05 2020 +0000
+++ b/usr.bin/make/unit-tests/deptgt.exp        Mon Sep 14 18:21:26 2020 +0000
@@ -1,2 +1,5 @@
 make: "deptgt.mk" line 10: warning: Extra target ignored
-exit status 0
+make: "deptgt.mk" line 27: Unassociated shell command ": command3"
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r d83fa8d2331e -r 583379247b90 usr.bin/make/unit-tests/deptgt.mk
--- a/usr.bin/make/unit-tests/deptgt.mk Mon Sep 14 17:47:05 2020 +0000
+++ b/usr.bin/make/unit-tests/deptgt.mk Mon Sep 14 18:21:26 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt.mk,v 1.3 2020/09/14 17:43:36 rillig Exp $
+# $NetBSD: deptgt.mk,v 1.4 2020/09/14 18:21:26 rillig Exp $
 #
 # Tests for special targets like .BEGIN or .SUFFIXES in dependency
 # declarations.
@@ -9,5 +9,22 @@
 # dependency line: That doesn't work, and make immediately rejects it.
 .SUFFIXES .PHONY: .c.o
 
+# Keyword "parse.c:targets"
+#
+# The following lines demonstrate how 'target' is set and reset during
+# parsing of dependencies.  To see it in action, set breakpoints in:
+#
+#      ParseDoDependency       at the beginning
+#      ParseFinishLine         at "targets = NULL"
+#      Parse_File              at "Lst_Free(targets)"
+#      Parse_File              at "targets = Lst_Init()"
+#      Parse_File              at "!inLine"
+#
+target1 target2: sources
+       : command1
+       : command2
+VAR=value
+       : command3
+
 all:
        @:;



Home | Main Index | Thread Index | Old Index