From: Simon Glass <simon.glass@canonical.com> Add a new tool called 'codman' (code manager) for analysing source code usage in U-Boot builds. This tool determines which files and lines of code are actually compiled based on the build configuration. The tool provides three analysis methods: - unifdef: Static preprocessor analysis (default) - DWARF: Debug information from compiled code (-w) - (experimental) LSP: Language server analysis using clangd (-l) Codman supports: - File-level analysis: which files are compiled vs unused - Line-level analysis: which lines are active vs removed by preprocessor - Kconfig-impact analysis with -a/--adjust option - Various output formats: stats, directories, detail, summary Since there is quite a lot of processing involved, Codman uses parallel processing where possible. This tool is admittedly not quite up to my normal code quality, but it has been an interesting experiment in using Claude to create something from scratch. The unifdef part of the tool benefits from some patches I created for that tool: - O(1) algorithm for symbol lookup, instead of O(n) - faster! - support for IS_ENABLED(), CONFIG_IS_ENABLED() Please get in touch if you would like the patches. This series also includes a minor improvement to buildman and a tidy-up of the tout library to reduce code duplication. Simon Glass (9): u_boot_pylib: Add stderr parameter to tprint() u_boot_pylib: Use terminal.tprint() for output in tout buildman: Support comma-separated values in -a flag codman: Add a new source-code analysis tool codman: Provide an unifdef analyser codman: Provide an dwarf analyser codman: Begin an experimental lsp analyser codman: Add some basic tests codman: Add documentation doc/develop/codman.rst | 1 + doc/develop/index.rst | 1 + tools/buildman/buildman.rst | 13 + tools/buildman/cfgutil.py | 19 +- tools/buildman/cmdline.py | 3 +- tools/buildman/test.py | 12 + tools/codman/analyser.py | 76 ++++ tools/codman/codman | 1 + tools/codman/codman.py | 664 +++++++++++++++++++++++++++++++++ tools/codman/codman.rst | 426 +++++++++++++++++++++ tools/codman/dwarf.py | 200 ++++++++++ tools/codman/lsp.py | 319 ++++++++++++++++ tools/codman/lsp_client.py | 225 +++++++++++ tools/codman/output.py | 536 ++++++++++++++++++++++++++ tools/codman/test_codman.py | 470 +++++++++++++++++++++++ tools/codman/test_lsp.py | 153 ++++++++ tools/codman/unifdef.py | 429 +++++++++++++++++++++ tools/u_boot_pylib/terminal.py | 10 +- tools/u_boot_pylib/tout.py | 24 +- 19 files changed, 3554 insertions(+), 28 deletions(-) create mode 120000 doc/develop/codman.rst create mode 100644 tools/codman/analyser.py create mode 120000 tools/codman/codman create mode 100755 tools/codman/codman.py create mode 100644 tools/codman/codman.rst create mode 100644 tools/codman/dwarf.py create mode 100644 tools/codman/lsp.py create mode 100644 tools/codman/lsp_client.py create mode 100644 tools/codman/output.py create mode 100755 tools/codman/test_codman.py create mode 100755 tools/codman/test_lsp.py create mode 100644 tools/codman/unifdef.py -- 2.43.0 base-commit: ac7212f5f9792af31bbacc0f46423d0ca6a39e1d branch: codman