If the user hasn't specified a buildstats directory, use the latest
entry under $BUILDDIR.

Signed-off-by: Ross Burton <[email protected]>
---
 scripts/buildstats-summary | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/scripts/buildstats-summary b/scripts/buildstats-summary
index b10c671b29b..cc2a27722af 100755
--- a/scripts/buildstats-summary
+++ b/scripts/buildstats-summary
@@ -87,7 +87,11 @@ def main(argv=None) -> int:
     )
 
     parser.add_argument(
-        "buildstats", metavar="BUILDSTATS", help="Buildstats file", 
type=pathlib.Path
+        "buildstats",
+        metavar="BUILDSTATS",
+        nargs="?",
+        type=pathlib.Path,
+        help="Buildstats file, or latest if not specified",
     )
     parser.add_argument(
         "--sort",
@@ -116,6 +120,16 @@ def main(argv=None) -> int:
 
     args = parser.parse_args(argv)
 
+    # If a buildstats file wasn't specified, try to find the last one
+    if not args.buildstats:
+        try:
+            builddir = pathlib.Path(os.environ["BUILDDIR"])
+            buildstats_dir = builddir / "tmp" / "buildstats"
+            args.buildstats = sorted(buildstats_dir.iterdir())[-1]
+        except KeyError:
+            print("Build environment has not been configured, cannot find 
buildstats")
+            return 1
+
     bs = read_buildstats(args.buildstats)
     dump_buildstats(args, bs)
 
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#206066): 
https://lists.openembedded.org/g/openembedded-core/message/206066
Mute This Topic: https://lists.openembedded.org/mt/109085409/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to