Commit Graph

4295 Commits

Author SHA1 Message Date
Simon Glass
b03663be7b pickman: Add GitLab integration to push and create MRs
Add -p/--push option to the apply command to push the cherry-pick branch
to GitLab and create a merge request. Uses the python-gitlab library.

Options:
  -p, --push     Push branch and create GitLab MR
  -r, --remote   Git remote for push (default: ci)
  -t, --target   Target branch for MR (default: master)

Requires GITLAB_TOKEN environment variable to be set.

Also record cherry-pick history in .pickman-history file on successful
apply. Each entry includes the date, source branch, commits, and the
agent's conversation log. This file is committed automatically and
included in the MR description when using -p.

Name the module gitlab_api.py to avoid shadowing the python-gitlab
library.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-16 13:15:19 +00:00
Simon Glass
616e0abb7b pickman: Add GitLab API module
Add gitlab_api module with functions for interacting with GitLab:

- check_available(): Check if python-gitlab is installed
- get_token(): Get GitLab API token from environment
- get_remote_url(): Get URL for a git remote
- parse_url(): Parse GitLab URLs (SSH and HTTPS formats)
- push_branch(): Push a branch to a remote
- create_mr(): Create a merge request via GitLab API
- push_and_create_mr(): Combined push and MR creation

Requires python-gitlab library and GITLAB_TOKEN environment variable.

Name the module gitlab_api.py to avoid shadowing the python-gitlab
library.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-16 13:15:19 +00:00
Simon Glass
38bea21d9a pickman: Add an apply command to cherry-pick commits
Add a command that automates cherry-picking commits using the agent
module. The apply command:

- Gets the next set of commits (same as next-set)
- Creates a new branch for the cherry-picks (-b/--branch option)
- Runs the agent to execute the cherry-picks
- Returns to the original branch after completion

The database is not updated automatically; use 'commit-source' to update
after reviewing the cherry-picked branch.

Also refactor control.py to extract get_next_commits() for reuse and
use a dispatch table for commands.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-16 13:15:19 +00:00
Simon Glass
55733b2749 pickman: Add a Claude agent
Add an agent which uses the Claude Agent SDK to automate cherry-picking
commits.

The agent module provides an async interface to the Claude Agent SDK
with a synchronous wrapper for easy use from the CLI.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-16 13:15:19 +00:00
Simon Glass
5cae65fea4 pickman: Add pcommit and mergereq tables to database
Add new database tables to track individual commits and merge requests:

- pcommit: tracks commits being cherry-picked with status, author,
  subject, and optional link to merge request
- mergereq: tracks GitLab merge requests with branch name, MR ID,
  status, and URL

Also add helper functions for both tables and update control.py to
write commit status to the database during apply operations.

Update README.rst with documentation for all database tables.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-16 13:15:19 +00:00
Simon Glass
da8d0d8028 pickman: Add next-set command to show commits to cherry-pick
Add a command that finds the next set of commits to cherry-pick from a
source branch. It lists commits from the last cherry-picked commit up
to and including the next merge commit, which typically represents a
logical grouping (e.g., a pull request).

If no merge commit is found, it lists all remaining commits with a note
indicating this.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-16 13:15:19 +00:00
Simon Glass
11b1f8fdd8 pickman: Add list-sources command
Add a command to list all tracked source branches and their last
cherry-picked commits from the database.

Usage: ./tools/pickman/pickman list-sources

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-16 13:15:19 +00:00
Simon Glass
ac54ae95c0 pickman: Add add-source command to track source branches
Add a command to register a source branch in the database. This finds
the merge-base commit between master and the source branch and stores
it as the starting point for cherry-picking.

Usage: ./tools/pickman/pickman add-source <branch>

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-16 13:15:19 +00:00
Simon Glass
23c4d2be3c pickman: Add database for tracking cherry-pick state
Add an sqlite3 database module to track the state of cherry-picking
commits between branches. The database uses .pickman.db and includes:

- source table: tracks source branches and their last cherry-picked
  commit into master
- Schema versioning for future migrations

The database code is mostly lifted from patman

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-16 13:15:19 +00:00
Simon Glass
999a36a675 pickman: Add argument parsing with compare and test commands
Add subcommand support:
- compare: Compare branches (existing functionality)
- test: Run the functional tests

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-16 13:15:19 +00:00
Simon Glass
840c1a6855 pickman: Add tool to compare branch differences
Add a tool to check the number of commits in a source branch
(us/next) that are not in the master branch (ci/master), and find
the last common commit between them.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-16 13:15:19 +00:00
Simon Glass
f231a055fc codman: Update documentation for new features
Update the documentation to cover the new options and features:
- Add --kloc and --html options to dirs command options list
- Add new "HTML Reports" section explaining --html usage
- Note that files are sorted alphabetically and hidden when zero active
- Update all example outputs to reflect current behavior

Cover-letter:
codman: Assorted improvements and HTML output
This series adds various improvements to codman including:
- Hide files with zero active lines by default
- Sort files alphabetically and simplify output columns
- Better formatting with kLOC display and whole number percentages
- HTML report generation with collapsible hierarchical drill-down
END

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-12-08 17:37:36 -07:00
Simon Glass
b7b6a731f5 codman: Add --html option to generate colored HTML reports
Add HTML output support with collapsible hierarchical directory
structure, color-coded metrics, and build info in the header.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-08 17:37:35 -07:00
Simon Glass
c9649b9df4 codman: Add a --kloc option to show klines instead of lines
Raw line counts can be hard to read for large codebases. Add a --kloc
(-k) option to display line counts in kilolines format for a more
compact view.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-08 17:20:20 -07:00
Simon Glass
d0cc800516 codman: Add blank line after file list in dirs output
When showing files within directories (dirs -fs), there is no visual
separation between one directory's files and the next directory. Add
a blank line after each file list to improve readability.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-08 17:10:17 -07:00
Simon Glass
fc6290be35 codman: Show %Code as whole numbers for files
File percentages show one decimal place while directory percentages
show whole numbers. Display file %Code as whole numbers to match the
directory format for cleaner, more consistent output.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-08 17:10:08 -07:00
Simon Glass
34cdaeafdb codman: Move file line counts to kLOC column
File metrics do not align with directory columns, making it hard to
compare them visually. Align file output with directory columns by:
- Skipping the Files, Used, and %Used columns (leave empty)
- Showing percentage active in the %Code column
- Showing total lines (in kLOC) in the kLOC column
- Showing active lines (in kLOC) in the Used column

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-08 17:09:59 -07:00
Simon Glass
e0543235e1 codman: Sort files alphabetically and drop inactive column
Files appear in arbitrary order, making it hard to find specific
files. Sort them alphabetically by filename for easier navigation.

Also remove the inactive lines column from file output to reduce
clutter, keeping only: filename, total lines, active lines, and
percentage active.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-08 17:09:52 -07:00
Simon Glass
0406a0d829 codman: Hide files with zero active lines unless -e is set
Files with 0 active lines clutter the output when viewing directories
with 'dirs -fs'. Hide them by default, matching the directory display
behavior. Use the -e flag (dirs -fse) to show them.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-08 17:09:42 -07:00
Simon Glass
9d6670f89a codman: Add documentation
Provide a description of the purpose of codman and some examples of how
to use it.

Series-to: concept
Cover-letter:
codman: Add a new source-code analysis tool

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.
END

Signed-off-by: Simon Glass <simon.glass@canonical.com>
Series-links: 1:65
2025-11-24 06:47:19 -07:00
Simon Glass
d2772a2359 codman: Add some basic tests
Add some rudimentary tests of the codman functionality.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-24 06:47:07 -07:00
Simon Glass
50e9e75d44 codman: Begin an experimental lsp analyser
It is possible to use an LSP to determine which code is used, at least
to some degree.

Make a start on this, in the hope that future work may prove out the
concept.

So far I have not found this to be particularly useful, since it does
not seem to handle IS_ENABLED() and similar macros when working out
inactive regions.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-24 06:47:07 -07:00
Simon Glass
683d1578ae codman: Provide an dwarf analyser
Add a way to do static preprocessor analysis using debug information
from compiled code. This reads the DWARF tables to determin which lines
produced code.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-24 06:47:07 -07:00
Simon Glass
aeae0f5d58 codman: Provide an unifdef analyser
Add a way to do static preprocessor analysis using unifdef, as a way of
figuring out what code is actually used in the build.

I have modified the unifdef tool as follows:
- O(1) algorithm for symbol lookup, instead of O(n)
- support for IS_ENABLED(), CONFIG_IS_ENABLED()

The first patch was sent upstream. The others are U-Boot-specific so I
have not submitted those.

Please get in touch if you would like the patches.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-24 06:44:52 -07:00
Simon Glass
1839832ad3 codman: Add a new source-code analysis tool
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.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-24 06:34:31 -07:00
Simon Glass
2006fc3693 buildman: Support comma-separated values in -a flag
Allow users to specify multiple config adjustments in a single -a
argument using commas. This is more convenient than repeating -a
multiple times.

Examples:
  buildman -a FOO,~BAR
  buildman -a FOO,~BAR -a BAZ=123

Add tests to verify comma-separated values work correctly.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-23 12:25:30 -07:00
Simon Glass
bde75b138a u_boot_pylib: Use terminal.tprint() for output in tout
Refactor tout.py to use terminal.tprint() instead of direct print()
calls. This provides better control over output formatting and
supports the new stderr parameter. It also reduces code duplication.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-22 14:53:50 -07:00
Simon Glass
c6f2e290f4 u_boot_pylib: Add stderr parameter to tprint()
Add optional stderr parameter to tprint() to allow printing to stderr
instead of stdout.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-22 14:53:23 -07:00
Simon Glass
192c586a5d fit: Change indent from string to int
Change the indent field in fit_print_ctx from a string pointer to an int
number of spaces to indent.

Set the initial indent value to 3 to match IMAGE_INDENT_STRING

Drop indentation from the debug() calls since these are not visible to
users.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
62a4c7e10a fit: Put the indent string into print context
Move the indent string into struct fit_print_ctx so it is available to
the printing functions. This avoids having to pass it as a separate
parameter.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:50:10 -07:00
Simon Glass
6b6f03c388 fit: Add a context struct for FIT-printing
Create a struct fit_print_ctx to hold the FIT pointer and pass it to all
printing functions instead of passing the FIT pointer directly. This
provides a foundation for adding additional context in the future.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:50:10 -07:00
Simon Glass
0b51f99bf0 fit: Move printing code to its own file
There is enough code here that it makes sense to put it in its own file.
Create a new fit_print.c file, before undertaking future refactoring.

Printing is only included in the main build if CONFIG_FIT_PRINT is
enabled, although it is always included in the tools build.

Add static inlines for existing callers.

Make a few small code-style adjustments, including fixing checkpatch
warnings about over-use of brackets.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:50:09 -07:00
Simon Glass
cca21f0d2f fit: Remove unused len parameter from fit_get_name()
Remove the unused third parameter (len) from fit_get_name(). All uses of
this function pass NULL for this parameter.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:37:40 -07:00
Simon Glass
daf122806e tools: Fix debug() to avoid unused-variable warnings
The debug() macro in mkimage.h expands to nothing when MKIMAGE_DEBUG
is not defined. This causes the compiler to warn about unused variables
that are only referenced in debug() statements.

Fix this using the same approach as the debug_cond() macro.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-18 17:02:33 -07:00
Simon Glass
561a7efe58 docker: Add cryptsetup package for LUKS testing
Add cryptsetup to the CI Docker image to enable LUKS encryption tests.
This is needed to create test images.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 10:06:04 +01:00
Simon Glass
08dccb40fe docker: Provide a rust toolchain
Install a Rust toolchain in the CI image so that it is possible to build
the Rust examples.

Co-developed-by: Claude <noreply@anthropic.com>
Co-developed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-11 12:51:48 -06:00
Tom Rini
a4001909a8 CI: Update to coreboot 25.03
At this point there's problems rebuilding coreboot-24.08 without manual
intervention. Let us upgrade to a newer version.

Signed-off-by: Tom Rini <trini@konsulko.com>
2025-09-11 12:51:47 -06:00
Simon Glass
3d1982a7a1 u_boot_pylib: Correct docs for run_test_coverage() required
This should be a set, not a list. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-08 12:16:38 -06:00
Simon Glass
b5fb7fefe8 lib: Rename gen_v5_guid() to indicate it is little-endian
Normally v5 GUIDs are big-endian, so rename this function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-04 07:08:24 -06:00
Simon Glass
c3b2c14731 patman: Support autolink when some series are archived
Archived series currently cause an error when autolink is attempted. Add
a check to avoid this.

Series-to: u-boot
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:458284
2025-08-20 09:54:41 -06:00
Simon Glass
12a20d3122 patman: Correct parsing of branch names
The name 'x86a' must be parsed as a branch name, not as versio 86 of
branch 'x'. Correct the regex and add a test for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
a9ea16e399 patman: Allow using the first commit as series description
Sometimes series don't have a cover letter. Add a --use-commit option to
easily use the first commit's subject instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
e26ea124fb patman: Allow showing progress on archived series
Sometimes it is useful to include archived series in the progress report
so you can see all the work completed. Add a flag for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
16667556bd patman: Allow listing archived series
Sometimes it is useful to include archived series in the listing so you
can see which series could potentially be unarchived. Add a flag for
this.

Add a --include-archived option to the 'series ls' command for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
da1cdaf278 patman: Move split_name_version to patchstream
This function is needed by 'patman status', meaning that it must import
cser_helper which needs pygit2

Move it to patchstream so that pygit2 is not needed for the
'patman status' command.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
abb8470f86 patman: Avoid needing pygit2 for all subcommands
If pygit2 does not exist, patman refuses to work at all, but most
subcommands don't need it. Move the imports to resolve this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
85d560becc dtoc: Add a test for the fdt_util.EnsureCompiled with indir
Provide a test which covers this feature of the EnsureCompiled()
function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 07:41:19 -06:00
Simon Glass
da2183fd74 buildman: Handle CROSS_COMPILE being in the environment
If CROSS_COMPILE is set in the environment passed to buildman,
testMakeEnvironment() fails. Fix this by removing the variable before
starting the test.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 07:41:19 -06:00
Simon Glass
23be77e922 buildman: Handle CPP being in the environment
If CPP is set (e.g. to 'gcc -E') buildman currently gives an error. Add
a little more logic to handle this case.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 07:41:19 -06:00
Simon Glass
e5d9997361 buildman: Fix pylint warning in test_skip_dtc()
Use a different variable to avoid overriding the toolchain module in
this function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 07:41:19 -06:00