8349933: Mixing of includes and snippets stack causes the wrong -post snippet to be included

Reviewed-by: ihse
This commit is contained in:
Erik Joelsson 2025-02-20 17:46:06 +00:00
parent 53db57648a
commit 16873732a7
4 changed files with 12 additions and 12 deletions

View File

@ -34,12 +34,12 @@ ifneq ($(NO_CUSTOM_EXTENSIONS), true)
endif
# Pop our helper name off the stack
HELPER_STACK := $(wordlist 2, $(words $(HELPER_STACK)), $(HELPER_STACK))
INCLUDE_STACK := $(wordlist 2, $(words $(INCLUDE_STACK)), $(INCLUDE_STACK))
# Print an indented message, also counting the top-level makefile as a level
ifeq ($(LOG_FLOW), true)
$(info :$(foreach s, top $(HELPER_STACK), )Leave $(THIS_INCLUDE))
$(info :$(foreach s, top $(INCLUDE_STACK) $(SNIPPET_STACK), )Leave $(THIS_INCLUDE))
endif
# Restore the previous helper name
THIS_INCLUDE := $(firstword $(HELPER_STACK))
THIS_INCLUDE := $(firstword $(INCLUDE_STACK))

View File

@ -39,11 +39,11 @@ else
endif
ifeq ($(LOG_FLOW), true)
$(info :$(foreach s, top $(HELPER_STACK), )Enter $(THIS_INCLUDE) [$(THIS_INCLUDE_MSG)])
$(info :$(foreach s, top $(INCLUDE_STACK) $(SNIPPET_STACK), )Enter $(THIS_INCLUDE) [$(THIS_INCLUDE_MSG)])
endif
ifneq ($(filter $(THIS_INCLUDE), $(HELPER_STACK)), )
$(error Internal makefile error: Include loop detected: $(THIS_INCLUDE) $(HELPER_STACK))
ifneq ($(filter $(THIS_INCLUDE), $(INCLUDE_STACK)), )
$(error Internal makefile error: Include loop detected: $(THIS_INCLUDE) $(INCLUDE_STACK))
endif
ifeq ($(words $(MAKEFILE_LIST)), 2)
@ -66,7 +66,7 @@ ifneq ($(IS_PREINIT_ENV), true)
endif
# Push our helper name onto the stack
HELPER_STACK := $(THIS_INCLUDE) $(HELPER_STACK)
INCLUDE_STACK := $(THIS_INCLUDE) $(INCLUDE_STACK)
# Setup an automatic include guard
ifneq ($(INCLUDE_GUARD_$(THIS_INCLUDE)), true)

View File

@ -34,12 +34,12 @@ ifneq ($(NO_CUSTOM_EXTENSIONS), true)
endif
# Pop our helper name off the stack
HELPER_STACK := $(wordlist 2, $(words $(HELPER_STACK)), $(HELPER_STACK))
SNIPPET_STACK := $(wordlist 2, $(words $(SNIPPET_STACK)), $(SNIPPET_STACK))
# Print an indented message, also counting the top-level makefile as a level
ifeq ($(LOG_FLOW), true)
$(info :$(foreach s, top $(HELPER_STACK), )Leave $(THIS_SNIPPET))
$(info :$(foreach s, top $(INCLUDE_STACK) $(SNIPPET_STACK), )Leave $(THIS_SNIPPET))
endif
# Restore the previous helper name
THIS_SNIPPET := $(firstword $(HELPER_STACK))
THIS_SNIPPET := $(firstword $(SNIPPET_STACK))

View File

@ -33,11 +33,11 @@ endif
# Print an indented message, also counting the top-level makefile as a level
ifeq ($(LOG_FLOW), true)
$(info :$(foreach s, top $(HELPER_STACK), )Enter $(THIS_SNIPPET) [snippet])
$(info :$(foreach s, top $(INCLUDE_STACK) $(SNIPPET_STACK), )Enter $(THIS_SNIPPET) [snippet])
endif
# Push our helper name onto the stack
HELPER_STACK := $(THIS_SNIPPET) $(HELPER_STACK)
SNIPPET_STACK := $(THIS_SNIPPET) $(SNIPPET_STACK)
# Hook to include the corresponding custom file, if present.
ifneq ($(NO_CUSTOM_EXTENSIONS), true)