summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-05-30 23:14:34 +0100
committerDamien George <damien.p.george@gmail.com>2015-05-30 23:14:34 +0100
commitdb52fd8e4dcc45d07ad1567329943d2b9dabcdea (patch)
tree0414422ebd38c92ab581b752ebe66325f3ebb4b7 /py
parent0ec8cf8e80ecdac77416a2d3fed861c95515d5df (diff)
py: Wrap qstr defs in quotes to protect from C preprocessor.
This patch converts Q(abc) to "Q(abc)" to protect the abc from the C preprocessor, then converts back after the preprocessor is finished. So now we can safely put includes in mpconfig(port).h, and also preprocess qstrdefsport.h (latter is now done also in this patch). Addresses issue #1252.
Diffstat (limited to 'py')
-rw-r--r--py/py.mk9
1 files changed, 5 insertions, 4 deletions
diff --git a/py/py.mk b/py/py.mk
index 5ab2b3b13..5c22a8f00 100644
--- a/py/py.mk
+++ b/py/py.mk
@@ -135,11 +135,12 @@ $(HEADER_BUILD)/mpversion.h: FORCE | $(HEADER_BUILD)
# Adding an order only dependency on $(HEADER_BUILD) causes $(HEADER_BUILD) to get
# created before we run the script to generate the .h
+# Note: we need to protect the qstr names from the preprocessor, so we wrap
+# the lines in "" and then unwrap after the preprocessor is finished.
$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(PY_SRC)/mpconfig.h | $(HEADER_BUILD)
- $(ECHO) "CPP $<"
- $(Q)$(CPP) $(CFLAGS) $(PY_QSTR_DEFS) -o $(HEADER_BUILD)/qstrdefs.preprocessed.h
- $(ECHO) "makeqstrdata $(PY_QSTR_DEFS) $(QSTR_DEFS)"
- $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h $(QSTR_DEFS) > $@
+ $(ECHO) "GEN $@"
+ $(Q)cat $(PY_QSTR_DEFS) $(QSTR_DEFS) | $(SED) 's/^Q(.*)/"&"/' | $(CPP) $(CFLAGS) - | sed 's/^"\(Q(.*)\)"/\1/' > $(HEADER_BUILD)/qstrdefs.preprocessed.h
+ $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@
# emitters