Understanding the qstr generation process
Posted: Sun Jan 23, 2022 2:43 am
i'm trying to work out how exactly the build process works when generating the qstr headers, and i've run into an issue:
py/py.mk says
and py/mkrules.mk says
so it's pretty straightforward, that qstr.i.last depends on the core objects (with some exceptions, like the nlr\* stuff). but where i'm confused is that
so it looks like qstrdefs.generated.h depends on QSTR_DEFS_COLLECTED which depends on qstr.split which depends on qstr.i.last which as we saw above depends on the core objects....... which is where the problem lies, because immediately in mpstate.c, one of the core sources, we can follow the includes to a dependency on qstrdefs.generated.h, which is what i'm trying to build.
so the question is: how does building the qstrdefs work with a circular dependency like this?
py/py.mk says
Code: Select all
# Sources that may contain qstrings
SRC_QSTR_IGNORE = py/nlr%
SRC_QSTR += $(SRC_MOD) $(filter-out $(SRC_QSTR_IGNORE),$(PY_CORE_O_BASENAME:.o=.c)) $(PY_EXTMOD_O_BASENAME:.o=.c)
Code: Select all
(HEADER_BUILD)/qstr.i.last: $(SRC_QSTR) $(QSTR_GLOBAL_DEPENDENCIES) $(HEADER_BUILD)/moduledefs.h | $(QSTR_GLOBAL_REQUIREMENTS)
...
Code: Select all
# py/py.mk
$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(MPCONFIGPORT_MK) $(PY_SRC)/mpconfig.h | $(HEADER_BUILD)
...
# py/mkrules.mk
$(QSTR_DEFS_COLLECTED): $(HEADER_BUILD)/qstr.split
...
$(HEADER_BUILD)/qstr.split: $(HEADER_BUILD)/qstr.i.last
...
so the question is: how does building the qstrdefs work with a circular dependency like this?