From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Thomas Huth" <thuth@redhat.com>
Subject: [PULL 1/8] gitlab: use argparse in check-units script
Date: Mon, 14 Jul 2025 13:02:27 +0100 [thread overview]
Message-ID: <20250714120234.1524401-2-alex.bennee@linaro.org> (raw)
In-Reply-To: <20250714120234.1524401-1-alex.bennee@linaro.org>
Modernise the argument parsing so we can easily add to the script.
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250710104531.3099313-2-alex.bennee@linaro.org>
diff --git a/.gitlab-ci.d/check-units.py b/.gitlab-ci.d/check-units.py
index 268a4118d5..cdc62ae5ee 100755
--- a/.gitlab-ci.d/check-units.py
+++ b/.gitlab-ci.d/check-units.py
@@ -8,8 +8,10 @@
# SPDX-License-Identifier: GPL-2.0-or-later
from os import access, R_OK, path
-from sys import argv, exit
+from sys import exit
import json
+import argparse
+from pathlib import Path
from collections import Counter
@@ -51,16 +53,17 @@ def analyse_units(build_units):
if __name__ == "__main__":
- if len(argv) != 2:
- script_name = path.basename(argv[0])
- print(f"Usage: {script_name} <path_to_compile_commands.json>")
- exit(1)
+ parser = argparse.ArgumentParser(
+ description="analyse number of build units in compile_commands.json")
+ parser.add_argument("cc_path", type=Path, default=None,
+ help="Path to compile_commands.json")
+
+ args = parser.parse_args()
- cc_path = argv[1]
- if path.isfile(cc_path) and access(cc_path, R_OK):
- units = extract_build_units(cc_path)
+ if path.isfile(args.cc_path) and access(args.cc_path, R_OK):
+ units = extract_build_units(args.cc_path)
analyse_units(units)
exit(0)
else:
- print(f"{cc_path} doesn't exist or isn't readable")
+ print(f"{args.cc_path} doesn't exist or isn't readable")
exit(1)
--
2.47.2
next prev parent reply other threads:[~2025-07-14 12:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 12:02 [PULL 0/8] maintainer updates for rc0 (gitlab, gdbstub, plugins, docs) Alex Bennée
2025-07-14 12:02 ` Alex Bennée [this message]
2025-07-14 12:02 ` [PULL 2/8] gitlab: add -n option to check-units script Alex Bennée
2025-07-14 12:02 ` [PULL 3/8] contrib/plugins/execlog: Add tab to the separator search of insn_disas Alex Bennée
2025-07-14 12:02 ` [PULL 4/8] target/alpha: Add GDB XML feature file Alex Bennée
2025-07-14 12:02 ` [PULL 5/8] plugins: fix inclusion of user-mode APIs Alex Bennée
2025-07-14 12:02 ` [PULL 6/8] docs: use :kbd: role in sphinx docs Alex Bennée
2025-07-14 12:02 ` [PULL 7/8] docs/system: clean-up formatting of virtio-net-failover Alex Bennée
2025-07-14 12:02 ` [PULL 8/8] gdbstub: add the GDB register XML files for sparc64 Alex Bennée
2025-07-15 19:50 ` [PULL 0/8] maintainer updates for rc0 (gitlab, gdbstub, plugins, docs) Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250714120234.1524401-2-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=manos.pitsidianakis@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).