aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-07-05 13:18:59 +0100
committerSimon Glass <sjg@chromium.org>2023-07-12 09:48:18 -0600
commit0e8da6274971a4417641db441109e2f792b23752 (patch)
treeeb9eff5b255f97af6b1adb9a303efdf5fbd5b5c6
parent9b1833dfd00f0303c22ac0c833ade7e17253df3a (diff)
downloadu-boot-0e8da6274971a4417641db441109e2f792b23752.zip
u-boot-0e8da6274971a4417641db441109e2f792b23752.tar.gz
u-boot-0e8da6274971a4417641db441109e2f792b23752.tar.bz2
buildman: Create a function to get number of built commits
Move this code into a function. This removes the last pylint error in the control module. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--tools/buildman/control.py34
1 files changed, 25 insertions, 9 deletions
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index c2ac56e..bf4843c 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -29,7 +29,24 @@ def get_plural(count):
"""Returns a plural 's' if count is not 1"""
return 's' if count != 1 else ''
-def get_action_summary(is_summary, commits, selected, step, threads, jobs):
+
+def count_build_commits(commits, step):
+ """Calculate the number of commits to be built
+
+ Args:
+ commits (list of Commit): Commits to build or None
+ step (int): Step value for commits, typically 1
+
+ Returns:
+ Number of commits that will be built
+ """
+ if commits:
+ count = len(commits)
+ return (count + step - 1) // step
+ return 0
+
+
+def get_action_summary(is_summary, commit_count, selected, threads, jobs):
"""Return a string summarising the intended action.
Args:
@@ -43,10 +60,8 @@ def get_action_summary(is_summary, commits, selected, step, threads, jobs):
Returns:
Summary string.
"""
- if commits:
- count = len(commits)
- count = (count + step - 1) // step
- commit_str = f'{count} commit{get_plural(count)}'
+ if commit_count:
+ commit_str = f'{commit_count} commit{get_plural(commit_count)}'
else:
commit_str = 'current source'
msg = (f"{'Summary of' if is_summary else 'Building'} "
@@ -83,8 +98,8 @@ def show_actions(series, why_selected, boards_selected, output_dir,
commits = series.commits
else:
commits = None
- print(get_action_summary(False, commits, boards_selected, step, threads,
- jobs))
+ print(get_action_summary(False, count_build_commits(commits, step),
+ boards_selected, threads, jobs))
print(f'Build directory: {output_dir}')
if commits:
for upto in range(0, len(series.commits), step):
@@ -486,8 +501,9 @@ def run_builder(builder, commits, board_selected, options):
builder.gnu_make = gnu_make
if not options.ide:
- tprint(get_action_summary(options.summary, commits, board_selected,
- options.step, options.threads, options.jobs))
+ commit_count = count_build_commits(commits, options.step)
+ tprint(get_action_summary(options.summary, commit_count, board_selected,
+ options.threads, options.jobs))
builder.SetDisplayOptions(
options.show_errors, options.show_sizes, options.show_detail,