* [PATCH] buildstats-diff: find last two buildstats files if none are specified
@ 2025-05-16 10:33 Ross Burton
2025-05-16 10:37 ` [OE-core] " Richard Purdie
0 siblings, 1 reply; 3+ messages in thread
From: Ross Burton @ 2025-05-16 10:33 UTC (permalink / raw)
To: openembedded-core
If no buildstats directories are specified, then find the last two runs
under BUILDDIR.
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
scripts/buildstats-diff | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/scripts/buildstats-diff b/scripts/buildstats-diff
index c9aa76a8faf..0e975ddcfc9 100755
--- a/scripts/buildstats-diff
+++ b/scripts/buildstats-diff
@@ -12,6 +12,7 @@ import glob
import logging
import math
import os
+import pathlib
import sys
from operator import attrgetter
@@ -251,11 +252,31 @@ Script for comparing buildstats of two separate builds."""
"average over them")
parser.add_argument('--only-task', dest='only_tasks', metavar='TASK', action='append', default=[],
help="Only include TASK in report. May be specified multiple times")
- parser.add_argument('buildstats1', metavar='BUILDSTATS1', help="'Left' buildstat")
- parser.add_argument('buildstats2', metavar='BUILDSTATS2', help="'Right' buildstat")
+ parser.add_argument('buildstats1', metavar='BUILDSTATS1', nargs="?", help="'Left' buildstat")
+ parser.add_argument('buildstats2', metavar='BUILDSTATS2', nargs="?", help="'Right' buildstat")
args = parser.parse_args(argv)
+ if args.buildstats1 and args.buildstats2:
+ # Both paths specified
+ pass
+ elif args.buildstats1 or args.buildstats2:
+ # Just one path specified, this is an error
+ parser.print_usage(sys.stderr)
+ print("Either specify two buildstats paths, or none to use the last two paths.", file=sys.stderr)
+ sys.exit(1)
+ else:
+ # No paths specified, try to find the last two buildstats
+ try:
+ buildstats_dir = pathlib.Path(os.environ["BUILDDIR"]) / "tmp" / "buildstats"
+ paths = sorted(buildstats_dir.iterdir())
+ args.buildstats2 = paths.pop()
+ args.buildstats1 = paths.pop()
+ except KeyError:
+ parser.print_usage(sys.stderr)
+ print("Build environment has not been configured, cannot find buildstats", file=sys.stderr)
+ sys.exit(1)
+
# We do not nedd/want to read all buildstats if we just want to look at the
# package versions
if args.ver_diff:
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [OE-core] [PATCH] buildstats-diff: find last two buildstats files if none are specified
2025-05-16 10:33 [PATCH] buildstats-diff: find last two buildstats files if none are specified Ross Burton
@ 2025-05-16 10:37 ` Richard Purdie
2025-05-16 10:42 ` Ross Burton
0 siblings, 1 reply; 3+ messages in thread
From: Richard Purdie @ 2025-05-16 10:37 UTC (permalink / raw)
To: ross.burton, openembedded-core
On Fri, 2025-05-16 at 11:33 +0100, Ross Burton via lists.openembedded.org wrote:
> If no buildstats directories are specified, then find the last two runs
> under BUILDDIR.
>
> Signed-off-by: Ross Burton <ross.burton@arm.com>
> ---
> scripts/buildstats-diff | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/buildstats-diff b/scripts/buildstats-diff
> index c9aa76a8faf..0e975ddcfc9 100755
> --- a/scripts/buildstats-diff
> +++ b/scripts/buildstats-diff
> @@ -12,6 +12,7 @@ import glob
> import logging
> import math
> import os
> +import pathlib
> import sys
> from operator import attrgetter
>
> @@ -251,11 +252,31 @@ Script for comparing buildstats of two separate builds."""
> "average over them")
> parser.add_argument('--only-task', dest='only_tasks', metavar='TASK', action='append', default=[],
> help="Only include TASK in report. May be specified multiple times")
> - parser.add_argument('buildstats1', metavar='BUILDSTATS1', help="'Left' buildstat")
> - parser.add_argument('buildstats2', metavar='BUILDSTATS2', help="'Right' buildstat")
> + parser.add_argument('buildstats1', metavar='BUILDSTATS1', nargs="?", help="'Left' buildstat")
> + parser.add_argument('buildstats2', metavar='BUILDSTATS2', nargs="?", help="'Right' buildstat")
>
> args = parser.parse_args(argv)
>
> + if args.buildstats1 and args.buildstats2:
> + # Both paths specified
> + pass
> + elif args.buildstats1 or args.buildstats2:
> + # Just one path specified, this is an error
> + parser.print_usage(sys.stderr)
> + print("Either specify two buildstats paths, or none to use the last two paths.", file=sys.stderr)
> + sys.exit(1)
> + else:
> + # No paths specified, try to find the last two buildstats
> + try:
> + buildstats_dir = pathlib.Path(os.environ["BUILDDIR"]) / "tmp" / "buildstats"
> + paths = sorted(buildstats_dir.iterdir())
> + args.buildstats2 = paths.pop()
> + args.buildstats1 = paths.pop()
> + except KeyError:
> + parser.print_usage(sys.stderr)
> + print("Build environment has not been configured, cannot find buildstats", file=sys.stderr)
> + sys.exit(1)
> +
> # We do not nedd/want to read all buildstats if we just want to look at the
> # package versions
> if args.ver_diff:
Should this print something so the user knows which ones it picked?
Cheers,
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [OE-core] [PATCH] buildstats-diff: find last two buildstats files if none are specified
2025-05-16 10:37 ` [OE-core] " Richard Purdie
@ 2025-05-16 10:42 ` Ross Burton
0 siblings, 0 replies; 3+ messages in thread
From: Ross Burton @ 2025-05-16 10:42 UTC (permalink / raw)
To: Richard Purdie; +Cc: openembedded-core@lists.openembedded.org
> On 16 May 2025, at 11:37, Richard Purdie <richard.purdie@linuxfoundation.org> wrote:
>
> Should this print something so the user knows which ones it picked?
Good point, v2 sent.
Ross
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-16 10:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-16 10:33 [PATCH] buildstats-diff: find last two buildstats files if none are specified Ross Burton
2025-05-16 10:37 ` [OE-core] " Richard Purdie
2025-05-16 10:42 ` Ross Burton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.