Commit 1b60a6dc authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

py: Divide "split" and "cat" phases of qstr extraction for better efficiency.

E.g. for stmhal, accumulated preprocessed output may grow large due to
bloated vendor headers, and then reprocessing tens of megabytes on each
build make take couple of seconds on fast hardware (=> potentially dozens
of seconds on slow hardware). So instead, split once after each change,
and only cat repetitively (guaranteed to be fast, as there're thousands
of lines involved at most).
parent 8dd704b0
...@@ -87,6 +87,8 @@ def cat_together(): ...@@ -87,6 +87,8 @@ def cat_together():
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Generates qstr definitions from a specified source') parser = argparse.ArgumentParser(description='Generates qstr definitions from a specified source')
parser.add_argument('command',
help='Command (split/cat)')
parser.add_argument('input_filename', parser.add_argument('input_filename',
help='Name of the input file (when not specified, the script reads standard input)') help='Name of the input file (when not specified, the script reads standard input)')
parser.add_argument('output_dir', parser.add_argument('output_dir',
...@@ -100,11 +102,9 @@ if __name__ == "__main__": ...@@ -100,11 +102,9 @@ if __name__ == "__main__":
except OSError: except OSError:
pass pass
if args.input_filename: if args.command == "split":
infile = open(args.input_filename, 'r') with open(args.input_filename) as infile:
else: process_file(infile)
infile = sys.stdin
file_data = process_file(infile) if args.command == "cat":
infile.close() cat_together()
cat_together()
...@@ -90,9 +90,14 @@ $(HEADER_BUILD)/qstr.i.last: $(SRC_QSTR) | $(HEADER_BUILD)/mpversion.h ...@@ -90,9 +90,14 @@ $(HEADER_BUILD)/qstr.i.last: $(SRC_QSTR) | $(HEADER_BUILD)/mpversion.h
$(CPP) $(QSTR_GEN_EXTRA_CFLAGS) $(CFLAGS) $? >$(HEADER_BUILD)/qstr.i.last; \ $(CPP) $(QSTR_GEN_EXTRA_CFLAGS) $(CFLAGS) $? >$(HEADER_BUILD)/qstr.i.last; \
fi fi
$(QSTR_DEFS_COLLECTED): $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr.split: $(HEADER_BUILD)/qstr.i.last
$(ECHO) "GEN $@" $(ECHO) "GEN $@"
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED) $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py split $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED)
$(Q)touch $@
$(QSTR_DEFS_COLLECTED): $(HEADER_BUILD)/qstr.split
$(ECHO) "GEN $@"
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py cat $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED)
# $(sort $(var)) removes duplicates # $(sort $(var)) removes duplicates
# #
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment