From patchwork Thu Jul 18 07:32:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 1133562 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nsswWbOh"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45q5Vd51l6z9s8m for ; Thu, 18 Jul 2019 17:34:15 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 5B08320387; Thu, 18 Jul 2019 07:34:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DF-P92WpkKly; Thu, 18 Jul 2019 07:34:10 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 5076D204CB; Thu, 18 Jul 2019 07:34:10 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 9AFD21BF366 for ; Thu, 18 Jul 2019 07:34:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 93063881AB for ; Thu, 18 Jul 2019 07:34:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OHtTifxtVq-X for ; Thu, 18 Jul 2019 07:34:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by hemlock.osuosl.org (Postfix) with ESMTPS id 8E7A388072 for ; Thu, 18 Jul 2019 07:34:08 +0000 (UTC) Received: by mail-lj1-f172.google.com with SMTP id t28so26245005lje.9 for ; Thu, 18 Jul 2019 00:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KCja95ENTIHFAiAq66eo/nL06PkXiJkddMmAZjSRxAc=; b=nsswWbOhZyAzibF5vfpMvS0Ty0j8CwURKR5bT4ea4BUkf4nUFGDRboe791BA+gycJN OQ6dxdooSm38VGzP/SU79FyYRuGonabcCLtDEQzCvMdRCYLkZ/JRAfkCqw2IbN81pYDo b68pYqiOK21W8PHq/JSP4oOmv4NO0FXbRHBuiaOBT0Fj9XMQnFAQwTTdt2O6Ew2ixUq1 UUHCO0HVhsqagSjUZL2aQU19oiXavo4pKpQZGBImK9cB8pJsFB0Q6AsS1ZlnTpF0uEuW v8P0mbxOUa97M1HsitcRPDQ8wmFzwZS9PcY5J+VP0Q9mvdtQs+f8f2lNR+vM0G1TFz6j SIaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KCja95ENTIHFAiAq66eo/nL06PkXiJkddMmAZjSRxAc=; b=CY6AeBUdrNcsPq8uLaAgpQgEekpfobN8iuIsQvtN9BhZesjC9BQNYswaufSbm/VHnr WiYGcyZnd+AHb+6ugmz0WN2oaLAoTvFny2B8k6/noeN+qfyefwsDsHr6uf/F70zeZnz9 PciNeBfXo9PgdAnbZp/QO7M1Gvb1f5pVKNwb82N856o571KJPRhiPsbYExnxyRSUcm/Q 6KLF0cwSQDadPAjJxOj3zNulolc25LnYu2l1HjntM2hNRVCyyrT/Jnh7ddJkj9uCWwiN 6c0RRObA1NP2cZx7YoBRA1Li9IKxDAFfYE/O3Kw2Ipf0yf+r0HAKgM2ZxK+VWdVYp+T0 spPg== X-Gm-Message-State: APjAAAW42o5stQ9HoRKH3jwf7WKwwh/3XU+xd7qufRB+zBdxGFPD/Zqt J2vgZ9FKCxEz7v4sVDgN/s1rpGeW X-Google-Smtp-Source: APXvYqznR0/CIkd5/VWiz2QyobjTK/1EMTYQ6tudeuyW9kpKOYYz5bQAbFsMa9zE/4s9tJMSzv/ODg== X-Received: by 2002:a2e:86c3:: with SMTP id n3mr24370626ljj.129.1563435246375; Thu, 18 Jul 2019 00:34:06 -0700 (PDT) Received: from localhost.localdomain ([93.75.246.20]) by smtp.gmail.com with ESMTPSA id u9sm3861528lfb.38.2019.07.18.00.34.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 18 Jul 2019 00:34:05 -0700 (PDT) From: Vadim Kochan To: buildroot@buildroot.org Date: Thu, 18 Jul 2019 10:32:43 +0300 Message-Id: <20190718073243.10767-1-vadim4j@gmail.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Subject: [Buildroot] [RFC v2 1/1] utils/show-progress: add tool to show build progress at runtime X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vadim Kochan Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This might be useful to watch the amount of built and selected packages and some progress about it. So added python script which prints progress and build stats. The sample of output is: Press Ctrl-C to exit ... Building: output/qemu_x86_64 ##################################------------------------------ [ 42.42% 14/33] Signed-off-by: Vadim Kochan --- RFC v2: 1) filter rootfs package type 2) rename build-progress -> show-progress 3) check empty version utils/show-progress | 91 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 utils/show-progress diff --git a/utils/show-progress b/utils/show-progress new file mode 100755 index 0000000000..ee1e1da289 --- /dev/null +++ b/utils/show-progress @@ -0,0 +1,91 @@ +#!/usr/bin/env python + +# Copyright (C) 2019 Vadim Kochan + +import os +import sys +import json +import time +import logging +import subprocess + +do_exit = False + +def usage(): + print("""Usage: show-progress [-h] [PATH] +show-progress shows progress about selected and built packages. +If PATH is no specified then the current working one will be used as +build output directory. + +Example usage: + $ show-progress output/qemu_x86_64 + +""") + sys.exit(0) + +def get_pkgs_list(build_dir): + cmd = ["make", "-C", build_dir, "-s", "--no-print-directory", "show-info"] + results = [] + + with open(os.devnull, 'wb') as devnull: + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=devnull, + universal_newlines=True) + pkg_list = json.loads(p.communicate()[0]) + + for p in pkg_list: + if pkg_list[p]["type"] == "rootfs": + continue + + ver = "" if pkg_list[p]["virtual"] else pkg_list[p]["version"] + ver = "-" + ver if ver != "" else ver + + results.append(p + ver) + + return results + +def is_pkg_built(build_dir, p): + for s in ["host", "target"]: + if os.path.exists(build_dir + "/build/" + p + "/.stamp_" + s + "_installed"): + return True + + return False + +def progress(ready, total): + perc = ready / total + fill = round(perc * 80) + print('\r', '#' * fill + '-' * (80 - fill), '[{:>7.2%} {}/{} ]'.format(perc, ready, total), end='') + sys.stdout.flush() + +def main(): + build_dir = "." + + if "-h" in sys.argv or "--help" in sys.argv: + usage() + + if len(sys.argv) > 1: + build_dir = sys.argv[1] + + pkgs = get_pkgs_list(build_dir) + total = len(pkgs) + + print("Press Ctrl-C to exit ...\n") + print("Building: " + build_dir) + + while not do_exit: + ready = 0 + + for p in pkgs: + if is_pkg_built(build_dir, p): + ready = ready + 1 + + progress(ready, total) + time.sleep(1) + + if ready == total: + print("Done") + break + +try: + main() +except KeyboardInterrupt: + do_exit = True