make(1): add test for .INCLUDEDFILE combined with .for loops
The .for loops are implemented as a special kind of .include, therefore they affect the .INCLUDEDFROM variable.
This commit is contained in:
parent
e446c2af54
commit
118ec9dfc5
@ -1,6 +1,10 @@
|
||||
make: "include-main.mk" line 12: main-before-ok
|
||||
make: "include-main.mk" line 19: main-before-for-ok
|
||||
make: "include-sub.mk" line 4: sub-before-ok
|
||||
make: "include-sub.mk" line 14: sub-before-for-ok
|
||||
make: "include-subsub.mk" line 4: subsub-ok
|
||||
make: "include-sub.mk" line 14: warning: sub-after-fail(include-sub.mk)
|
||||
make: "include-main.mk" line 22: warning: main-after-fail(include-sub.mk)
|
||||
make: "include-sub.mk" line 25: warning: sub-after-fail(include-sub.mk)
|
||||
make: "include-sub.mk" line 32: warning: sub-after-for-fail(include-sub.mk)
|
||||
make: "include-main.mk" line 30: warning: main-after-fail(include-sub.mk)
|
||||
make: "include-main.mk" line 35: main-after-for-ok
|
||||
exit status 0
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: include-main.mk,v 1.3 2020/09/05 16:59:19 rillig Exp $
|
||||
# $NetBSD: include-main.mk,v 1.4 2020/09/05 18:13:47 rillig Exp $
|
||||
#
|
||||
# Demonstrates that the .INCLUDEDFROMFILE magic variable does not behave
|
||||
# as described in the manual page.
|
||||
@ -14,6 +14,14 @@
|
||||
. warning main-before-fail(${.INCLUDEDFROMFILE})
|
||||
.endif
|
||||
|
||||
.for i in once
|
||||
. if !defined(${.INCLUDEDFROMFILE})
|
||||
. info main-before-for-ok
|
||||
. else
|
||||
. warning main-before-for-fail(${.INCLUDEDFROMFILE})
|
||||
. endif
|
||||
.endfor
|
||||
|
||||
.include "include-sub.mk"
|
||||
|
||||
.if !defined(.INCLUDEDFROMFILE)
|
||||
@ -22,4 +30,12 @@
|
||||
. warning main-after-fail(${.INCLUDEDFROMFILE})
|
||||
.endif
|
||||
|
||||
.for i in once
|
||||
. if !defined(${.INCLUDEDFROMFILE})
|
||||
. info main-after-for-ok
|
||||
. else
|
||||
. warning main-after-for-fail(${.INCLUDEDFROMFILE})
|
||||
. endif
|
||||
.endfor
|
||||
|
||||
all: # nothing
|
||||
|
@ -1,11 +1,22 @@
|
||||
# $NetBSD: include-sub.mk,v 1.2 2020/09/05 16:59:19 rillig Exp $
|
||||
# $NetBSD: include-sub.mk,v 1.3 2020/09/05 18:13:47 rillig Exp $
|
||||
|
||||
.if ${.INCLUDEDFROMFILE} == "include-main.mk"
|
||||
. info sub-before-ok
|
||||
.else
|
||||
. warning sub-before-fail
|
||||
. warning sub-before-fail(${.INCLUDEDFROMFILE})
|
||||
.endif
|
||||
|
||||
# As of 2020-09-05, the .for loop is implemented as "including a file"
|
||||
# with a custom buffer. Therefore this loop has side effects on these
|
||||
# variables.
|
||||
.for i in once
|
||||
. if ${.INCLUDEDFROMFILE} == "include-main.mk"
|
||||
. info sub-before-for-ok
|
||||
. else
|
||||
. warning sub-before-for-fail(${.INCLUDEDFROMFILE})
|
||||
. endif
|
||||
.endfor
|
||||
|
||||
.include "include-subsub.mk"
|
||||
|
||||
.if ${.INCLUDEDFROMFILE} == "include-main.mk"
|
||||
@ -13,3 +24,11 @@
|
||||
.else
|
||||
. warning sub-after-fail(${.INCLUDEDFROMFILE})
|
||||
.endif
|
||||
|
||||
.for i in once
|
||||
. if ${.INCLUDEDFROMFILE} == "include-main.mk"
|
||||
. info sub-after-for-ok
|
||||
. else
|
||||
. warning sub-after-for-fail(${.INCLUDEDFROMFILE})
|
||||
. endif
|
||||
.endfor
|
||||
|
@ -1,7 +1,7 @@
|
||||
# $NetBSD: include-subsub.mk,v 1.2 2020/09/05 16:59:19 rillig Exp $
|
||||
# $NetBSD: include-subsub.mk,v 1.3 2020/09/05 18:13:47 rillig Exp $
|
||||
|
||||
.if ${.INCLUDEDFROMFILE:T} == "include-sub.mk"
|
||||
.if ${.INCLUDEDFROMFILE} == "include-sub.mk"
|
||||
. info subsub-ok
|
||||
.else
|
||||
. warning subsub-fail
|
||||
. warning subsub-fail(${.INCLUDEDFROMFILE})
|
||||
.endif
|
||||
|
Loading…
Reference in New Issue
Block a user