Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools/boards.txt.py rewrite #8595

Draft
wants to merge 37 commits into
base: master
Choose a base branch
from
Draft

Conversation

mcspr
Copy link
Collaborator

@mcspr mcspr commented Jun 8, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant