tools/boards.txt.py rewrite by mcspr · Pull Request #8595 · esp8266/Arduino (original) (raw)
Previously mentioned in #6690 and matrix back in april
Quite a lot of lines, though. (diff review might be useless :)
Drafting, to avoid the branch getting stale.
Updated CLI interface, using argparse and sub-commands
> tools/boards.txt.py --help
...
> tools/boards.txt.py generate --help # old *gen functions, either --all or specific --<name>
...
> tools/boards.txt test # new 'doctest' based verifier for our own code
> tools/boards.txt names # old boardslist
# Available board names. Delete or comment out the boards you do not need:
...
Things of note
- fixing fs size displayed in comments and menu, use the real value instead of the 'expected' one
- fixing .ld script comments regarding used regions and free space
- re-adds missing .ld scripts, uncommon 8m and 16m without fs
- re-adds missing upload_maximum_size property for IDE size display
- consistent output for boards{.local}.txt, sorting and filtering applied. different file output via --boards-file=...
- simplify 'defaults' -> 'boards' -> 'filter' flow before we attempt to work with the boards list
- consistent size in bytes all across the script; no need to multiply / divide by 1024, it's simply bytes all the time
- tweak the original key<->value idea for formatters, using python named arguments to inject things into the function scope
- consistent output argument; either write to file, prepare backup and write or use stdout
- humanize(size) helpers for menu properties, menu labels and .ld
- fixing escapes like
\_
->\\_
in .rst generator - support Windows: use fixed newline=, use fixed encoding=
- optional backup / .orig; default to no backup file, since it is pointless in git setups
- named flash regions and more flash layout helpers. should especially help out with custom mapping header or when modifying something in the layout (like adding a new region)
CI adds test
before running any generators. This is both useful for verifying the internal logic for regions and layouts, plus formatting could be verified as well. Could be replaced with unittest
if the 'comments are tests' approach seems too foreign :) Plus, we should probably have even more of those; I definitely missed some.
Some side effects, since we are changing a lot of things anyway
- migrate to py3 f-strings
- use language libs for buildflag combinations, no need for rosettacode
- alphabetical sorting in package index .json and boards.rst; perhaps unintentional, right now the order is the same as in the script
- lo-o-ong strings are split into multiple line ones. if there's no comma, it has the same effect as in C/C++ and it remains the same string without the indentation.
- consistent formatting using black; not forced (yet) in CI, should be applied to the rest of .py scripts as well