From 08e0e065f4fa26cb1f52567ad53052310bc656e6 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 24 Jun 2021 09:43:54 +1000 Subject: [PATCH] py/makeqstrdefs.py: Don't include .h files explicitly in preprocessing. Only include .c and .cpp files explicitly in the list of files passed to the preprocessor for QSTR extraction. All relevant .h files will be included in this process by "#include" from the .c(pp) files. In particular for moduledefs.h, this is included by py/objmodule.c (and doesn't actually contain any extractable MP_QSTR_xxx, but rather defines macros with MP_QSTR_xxx's in them which are then part of py/objmodule.c). The main reason for this change is to simplify the preprocessing step on the javascript port, which tries to compile .h files as C++ precompiled headers if they are passed with -E to clang. Signed-off-by: Damien George --- py/makeqstrdefs.py | 2 +- py/mkrules.mk | 2 +- py/py.mk | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py index ad4f22d5e4cf..187a9aeeaa48 100644 --- a/py/makeqstrdefs.py +++ b/py/makeqstrdefs.py @@ -34,7 +34,7 @@ def preprocess(): for source in sources: if source.endswith(".cpp"): cxxsources.append(source) - else: + elif source.endswith(".c"): csources.append(source) try: os.makedirs(os.path.dirname(args.output[0])) diff --git a/py/mkrules.mk b/py/mkrules.mk index eb8477cbb1d8..b8d07ef56d55 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -100,7 +100,7 @@ $(OBJ): | $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/mpversion.h $(OBJ # - else, if list of newer prerequisites ($?) is not empty, then process just these ($?) # - else, process all source files ($^) [this covers "make -B" which can set $? to empty] # See more information about this process in docs/develop/qstr.rst. -$(HEADER_BUILD)/qstr.i.last: $(SRC_QSTR) $(QSTR_GLOBAL_DEPENDENCIES) | $(QSTR_GLOBAL_REQUIREMENTS) +$(HEADER_BUILD)/qstr.i.last: $(SRC_QSTR) $(QSTR_GLOBAL_DEPENDENCIES) $(HEADER_BUILD)/moduledefs.h | $(QSTR_GLOBAL_REQUIREMENTS) $(ECHO) "GEN $@" $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py pp $(CPP) output $(HEADER_BUILD)/qstr.i.last cflags $(QSTR_GEN_CFLAGS) cxxflags $(QSTR_GEN_CXXFLAGS) sources $^ dependencies $(QSTR_GLOBAL_DEPENDENCIES) changed_sources $? diff --git a/py/py.mk b/py/py.mk index 59abc8f50373..ab01b0ec21e9 100644 --- a/py/py.mk +++ b/py/py.mk @@ -269,8 +269,6 @@ $(HEADER_BUILD)/moduledefs.h: $(SRC_QSTR) $(QSTR_GLOBAL_DEPENDENCIES) | $(HEADER @$(ECHO) "GEN $@" $(Q)$(PYTHON) $(PY_SRC)/makemoduledefs.py --vpath="., $(TOP), $(USER_C_MODULES)" $(SRC_QSTR) > $@ -SRC_QSTR += $(HEADER_BUILD)/moduledefs.h - # Standard C functions like memset need to be compiled with special flags so # the compiler does not optimise these functions in terms of themselves. CFLAGS_BUILTIN ?= -ffreestanding -fno-builtin -fno-lto