xref: /freebsd/contrib/bmake/unit-tests/include-sub.inc (revision 4fde40d9b540ea1a544cb4378a14f2f6da85ca6d)
1*4fde40d9SSimon J. Gerraty# $NetBSD: include-sub.inc,v 1.1 2023/01/19 23:26:14 rillig Exp $
2*4fde40d9SSimon J. Gerraty
3*4fde40d9SSimon J. Gerraty.if ${.INCLUDEDFROMFILE} == "include-main.mk"
4*4fde40d9SSimon J. Gerraty.  info sub-before-ok
5*4fde40d9SSimon J. Gerraty.else
6*4fde40d9SSimon J. Gerraty.  warning sub-before-fail(${.INCLUDEDFROMFILE})
7*4fde40d9SSimon J. Gerraty.endif
8*4fde40d9SSimon J. Gerraty
9*4fde40d9SSimon J. Gerraty# As of 2020-09-05, the .for loop is implemented as "including a file"
10*4fde40d9SSimon J. Gerraty# with a custom buffer.  Therefore this loop has side effects on these
11*4fde40d9SSimon J. Gerraty# variables.
12*4fde40d9SSimon J. Gerraty.for i in once
13*4fde40d9SSimon J. Gerraty.  if ${.INCLUDEDFROMFILE} == "include-main.mk"
14*4fde40d9SSimon J. Gerraty.    info sub-before-for-ok
15*4fde40d9SSimon J. Gerraty.  else
16*4fde40d9SSimon J. Gerraty.    warning sub-before-for-fail(${.INCLUDEDFROMFILE})
17*4fde40d9SSimon J. Gerraty.  endif
18*4fde40d9SSimon J. Gerraty.endfor
19*4fde40d9SSimon J. Gerraty
20*4fde40d9SSimon J. Gerraty# To see the variable 'includes' in action:
21*4fde40d9SSimon J. Gerraty#
22*4fde40d9SSimon J. Gerraty# Breakpoints:
23*4fde40d9SSimon J. Gerraty#	Parse_PushInput		at "Vector_Push(&includes)"
24*4fde40d9SSimon J. Gerraty#	HandleMessage		at entry
25*4fde40d9SSimon J. Gerraty# Watches:
26*4fde40d9SSimon J. Gerraty#	((const IncludedFile *[10])(*includes.items))
27*4fde40d9SSimon J. Gerraty#	*CurFile()
28*4fde40d9SSimon J. Gerraty
29*4fde40d9SSimon J. Gerraty.for i in deeply
30*4fde40d9SSimon J. Gerraty.  for i in nested
31*4fde40d9SSimon J. Gerraty.    for i in include
32*4fde40d9SSimon J. Gerraty.include "include-subsub.inc"
33*4fde40d9SSimon J. Gerraty.    endfor
34*4fde40d9SSimon J. Gerraty.  endfor
35*4fde40d9SSimon J. Gerraty.endfor
36*4fde40d9SSimon J. Gerraty
37*4fde40d9SSimon J. Gerraty.if ${.INCLUDEDFROMFILE} == "include-main.mk"
38*4fde40d9SSimon J. Gerraty.  info sub-after-ok
39*4fde40d9SSimon J. Gerraty.else
40*4fde40d9SSimon J. Gerraty.  warning sub-after-fail(${.INCLUDEDFROMFILE})
41*4fde40d9SSimon J. Gerraty.endif
42*4fde40d9SSimon J. Gerraty
43*4fde40d9SSimon J. Gerraty.for i in once
44*4fde40d9SSimon J. Gerraty.  if ${.INCLUDEDFROMFILE} == "include-main.mk"
45*4fde40d9SSimon J. Gerraty.    info sub-after-for-ok
46*4fde40d9SSimon J. Gerraty.  else
47*4fde40d9SSimon J. Gerraty.    warning sub-after-for-fail(${.INCLUDEDFROMFILE})
48*4fde40d9SSimon J. Gerraty.  endif
49*4fde40d9SSimon J. Gerraty.endfor
50