summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2020-10-23 19:11:30 +0000
committerrillig <rillig@NetBSD.org>2020-10-23 19:11:30 +0000
commit4ef92d866fb9f5b503b061768401b0770dc2a8ff (patch)
tree6d0ee6ea5494a0135faeb2616fef0833fef60472 /usr.bin/make
parentf958c90f7ad307bbb6c0f8fed04389c7fa58faaa (diff)
make(1): add test for the '::' dependency operator
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/make.h12
-rw-r--r--usr.bin/make/unit-tests/Makefile3
-rw-r--r--usr.bin/make/unit-tests/dep-double-colon-indep.exp3
-rw-r--r--usr.bin/make/unit-tests/dep-double-colon-indep.mk32
-rw-r--r--usr.bin/make/unit-tests/dep-wildcards.exp1
5 files changed, 46 insertions, 5 deletions
diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h
index 659f3afe7d2..d37f354ac57 100644
--- a/usr.bin/make/make.h
+++ b/usr.bin/make/make.h
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.164 2020/10/23 18:36:09 rillig Exp $ */
+/* $NetBSD: make.h,v 1.165 2020/10/23 19:11:30 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -191,11 +191,15 @@ typedef enum {
*
* Some of the OP_ constants can be combined, others cannot. */
typedef enum GNodeType {
- /* Execution of commands depends on children (:) */
+ /* The dependency operator ':' is the most common one. The commands of
+ * this node are executed if any child is out-of-date. */
OP_DEPENDS = 1 << 0,
- /* Always execute commands (!) */
+ /* The dependency operator '!' always executes its commands, even if
+ * its children are up-to-date. */
OP_FORCE = 1 << 1,
- /* Execution of commands depends on children per line (::) */
+ /* The dependency operator '::' behaves like ':', except that it allows
+ * multiple dependency groups to be defined. Each of these groups is
+ * executed on its own, independently from the others. */
OP_DOUBLEDEP = 1 << 2,
/* Matches the dependency operators ':', '!' and '::'. */
diff --git a/usr.bin/make/unit-tests/Makefile b/usr.bin/make/unit-tests/Makefile
index b01eaba0b1c..41f31f0ec83 100644
--- a/usr.bin/make/unit-tests/Makefile
+++ b/usr.bin/make/unit-tests/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.171 2020/10/23 14:38:39 rillig Exp $
+# $NetBSD: Makefile,v 1.172 2020/10/23 19:11:30 rillig Exp $
#
# Unit tests for make(1)
#
@@ -75,6 +75,7 @@ TESTS+= dep
TESTS+= dep-colon
TESTS+= dep-colon-bug-cross-file
TESTS+= dep-double-colon
+TESTS+= dep-double-colon-indep
TESTS+= dep-exclam
TESTS+= dep-none
TESTS+= dep-var
diff --git a/usr.bin/make/unit-tests/dep-double-colon-indep.exp b/usr.bin/make/unit-tests/dep-double-colon-indep.exp
new file mode 100644
index 00000000000..b425144754e
--- /dev/null
+++ b/usr.bin/make/unit-tests/dep-double-colon-indep.exp
@@ -0,0 +1,3 @@
+: 'Making 1400 dep-double-colon-1300 from dep-double-colon-1400 oodate dep-double-colon-1400'
+: 'Making 1500 dep-double-colon-1300 from dep-double-colon-1500 oodate dep-double-colon-1500'
+exit status 0
diff --git a/usr.bin/make/unit-tests/dep-double-colon-indep.mk b/usr.bin/make/unit-tests/dep-double-colon-indep.mk
new file mode 100644
index 00000000000..9f004cf88ba
--- /dev/null
+++ b/usr.bin/make/unit-tests/dep-double-colon-indep.mk
@@ -0,0 +1,32 @@
+# $NetBSD: dep-double-colon-indep.mk,v 1.1 2020/10/23 19:11:30 rillig Exp $
+#
+# Tests for the :: operator in dependency declarations, which allows multiple
+# dependency groups with the same target. Each group is evaluated on its own,
+# independent of the other groups.
+#
+# This is useful for targets that are updatable, such as a database or a log
+# file. Be careful with parallel mode though, to avoid lost updates and
+# other inconsistencies.
+#
+# The target 1300 depends on 1200, 1400 and 1500. The target 1200 is older
+# than 1300, therefore nothing is done for it. The other targets are newer
+# than 1300, therefore each of them is made, independently from the other.
+
+.END:
+ @rm -f dep-double-colon-1???
+
+_!= touch -t 202001011200 dep-double-colon-1200
+_!= touch -t 202001011300 dep-double-colon-1300
+_!= touch -t 202001011400 dep-double-colon-1400
+_!= touch -t 202001011500 dep-double-colon-1500
+
+all: dep-double-colon-1300
+
+dep-double-colon-1300:: dep-double-colon-1200
+ : 'Making 1200 ${.TARGET} from ${.ALLSRC} oodate ${.OODATE}'
+
+dep-double-colon-1300:: dep-double-colon-1400
+ : 'Making 1400 ${.TARGET} from ${.ALLSRC} oodate ${.OODATE}'
+
+dep-double-colon-1300:: dep-double-colon-1500
+ : 'Making 1500 ${.TARGET} from ${.ALLSRC} oodate ${.OODATE}'
diff --git a/usr.bin/make/unit-tests/dep-wildcards.exp b/usr.bin/make/unit-tests/dep-wildcards.exp
index f0ad304a022..77cffbd5f25 100644
--- a/usr.bin/make/unit-tests/dep-wildcards.exp
+++ b/usr.bin/make/unit-tests/dep-wildcards.exp
@@ -1,5 +1,6 @@
dep-colon-bug-cross-file.mk
dep-colon.mk
+dep-double-colon-indep.mk
dep-double-colon.mk
dep-exclam.mk
dep-none.mk