diff options
author | Alessandro Gatti <a.gatti@frob.it> | 2025-08-26 20:49:20 +0200 |
---|---|---|
committer | Alessandro Gatti <a.gatti@frob.it> | 2025-08-26 21:17:03 +0200 |
commit | ce834b8d661a6fde275ec64083b7e2f4f3efea4d (patch) | |
tree | 2acd69501aa309293f9c9788f62209c6780ad0af /tests/unix/mod_os.py | |
parent | 8c47e446bf99393fd20c0416970f5c9a78b294f7 (diff) |
tools/mpy-tool.py: Allow dumping MPY segments into their own files.HEADorigin/masterorigin/HEADmaster
This commit lets "tools/mpy-tool.py" extract MPY segments into their own
files, one file per segment.
A pair of new command line arguments were added, namely "-e"/"--extract"
that takes a filename prefix to use as a base for the generated files'
name, and "--extract-only" that - combined with "--extract" - allows
selecting which kinds of segment should be dumped to the filesystem.
So, for example, assuming there's a file called "module.mpy", running
"./mpy-tool.py --extract segments module.mpy" would yield a series of
files with names like "segments_0_module.py_QSTR_module.py.bin",
"segments_1_module.py_META__module_.bin",
"segments_2_module.py_QSTR_function.bin", etc. In short the file name
format is "<base>_<count>_<sourcefile>_<segmentkind>_<segmentname>.bin",
with <segmentkind> being META, QSTR, OBJ, or CODE. Source file names
and segment names will only contain characters in the range
"a-zA-Z0-9_-." to avoid having output file names with unexpected
characters.
The "--extract-only" option can accept one or more kinds, separated by
commas and treated as case insensitive strings. The supported kinds
match what is currently handled by the "MPYSegment" class in
"tools/mpy-tool.py": "META", "QSTR", "OBJ", and "CODE". The absence of
this command line option implies dumping every segment found.
If "--extract" is passed along with "--merge", dumping is performed
after the merge process takes place, in order to dump all possible
segments that match the requested segment kinds.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Diffstat (limited to 'tests/unix/mod_os.py')
0 files changed, 0 insertions, 0 deletions