From patchwork Wed Aug 7 20:35:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 1143663 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="IV3DZ0ap"; 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 463jwT0bglz9s7T for ; Thu, 8 Aug 2019 06:36:54 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 3FF28203BA; Wed, 7 Aug 2019 20:36:52 +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 ku4+xJ6V+xJn; Wed, 7 Aug 2019 20:36:50 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id EC3D420427; Wed, 7 Aug 2019 20:36:49 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id AB1D41BF3B1 for ; Wed, 7 Aug 2019 20:36:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id A830486868 for ; Wed, 7 Aug 2019 20:36:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UKNbT3iqs5DL for ; Wed, 7 Aug 2019 20:36:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) by fraxinus.osuosl.org (Postfix) with ESMTPS id AEEC68685A for ; Wed, 7 Aug 2019 20:36:47 +0000 (UTC) Received: by mail-lf1-f45.google.com with SMTP id c19so65040463lfm.10 for ; Wed, 07 Aug 2019 13:36:47 -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=xICHAX0/b4t9pVV/URulZUOIoEInbcfh/b/8myPyynk=; b=IV3DZ0ap5WOBaBtKuyQ2ouEV10uiYmDgnvyDl7fJZvWqUBJIJiJSQqcAIFVkGKplAt pZxJLV3uVIa7OUaJNhCdPJRw/FSAH2T8Crqr4Z6w+eXGxwJT2Z19KgZULwITOSww72gc vBMwngHnMLT5qa569rhlPd4JlObNDAhn9+Ib9cU78doe6RF7BTxZeP8ugz+c7pMLFauB iXNaTd4RpI1HaaHZoIJ2WEzx5Pwv211jC04pzipE8qFdjXI4ZD2ftlRCN9Bs+4upgtt1 5KrhOuch3D0lx8ijF/mocp0hKh/eFTvYYs+K/YG4RaV74LNcgJYkZ1qhyzHU4RJq/lp6 dsGQ== 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=xICHAX0/b4t9pVV/URulZUOIoEInbcfh/b/8myPyynk=; b=ijHOe2eN1Qh38WbYXphX3Wc372nVxbNFfRXlw3LHzkw9EFe/CzqdVsBs+9jCdRfTU/ zdJ5GNp3TcCRI6Y3NRUSuxyoKXxVV1HijPZytbc1T6jLl0mIn/BwhEND0cpXGdLDhOUb Vooy1Qx6WPkhjjf9Q+ERyNuBqdEH1DaK++tA4K3XgNS5SKOW1zpSyFAsDMOK+uBOQqDb co5FpYQMsMV3KY9BAkbA4aECbQzkw4oe4tyQ0JJohKQIKpKUwntuDDVoZ0pwrrxewhDR c0bqe3zS2SwMZfWfSaw7ZDllOhphTa0z7aUlf3pDWgiuCGHBx45rv+Vz2PpIiYVMoH20 yE6Q== X-Gm-Message-State: APjAAAVwohtJrFwLRvMJuYYEEnoJS7vDDAa1XmQu/9VyP2X3yQcT8073 18alH8ekmQCZ5PvIB8rf2jsOxfwg X-Google-Smtp-Source: APXvYqzGi4T1XLXjS+WGSDCimp7IcUVmiUZ/uxvfwtXFUk51kkT/MV/pK8Mxl3TT8rArLKgnQ+UEDQ== X-Received: by 2002:a19:7006:: with SMTP id h6mr6970180lfc.5.1565210205486; Wed, 07 Aug 2019 13:36:45 -0700 (PDT) Received: from localhost.localdomain ([93.75.246.20]) by smtp.gmail.com with ESMTPSA id s26sm18539644ljs.77.2019.08.07.13.36.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 07 Aug 2019 13:36:44 -0700 (PDT) From: Vadim Kochan To: buildroot@buildroot.org Date: Wed, 7 Aug 2019 23:35:02 +0300 Message-Id: <20190807203502.27269-1-vadim4j@gmail.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Subject: [Buildroot] [PATCH 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 --- utils/show-progress | 106 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100755 utils/show-progress diff --git a/utils/show-progress b/utils/show-progress new file mode 100755 index 0000000000..1395664696 --- /dev/null +++ b/utils/show-progress @@ -0,0 +1,106 @@ +#!/usr/bin/env python + +from __future__ import print_function +import subprocess +import json +import time +import sys +import os + +do_exit = False + +class Package: + def __init__(self): + self.build_dir = "" + self.version = "" + self.type = "" + self.name = "" + + def get_full_name(self): + if self.version != "": + return self.name + "-" + self.version + return self.name + + def is_built(self): + return os.path.exists(self.build_dir + "/build/" + \ + self.get_full_name() + "/.stamp_" + self.type + "_installed") + +def usage(): + print("""Usage: show-progress [-h] PATH + +Shows progress about selected and built packages. +PATH must point to the output folder with generated Makefile. + +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" or pkg_list[p]["virtual"]: + continue + + pkg = Package() + pkg.version = pkg_list[p]["version"] + pkg.build_dir = build_dir + pkg.name = p + + if pkg_list[p]["install_images"]: + pkg.type = "images" + elif pkg_list[p]["install_staging"] and not pkg_list[p]["install_target"]: + pkg.type = "staging" + else: + pkg.type = pkg_list[p]["type"] + + results.append(pkg) + + return results + +def progress(ready, total): + max_len = 60 + perc = ready / (total * 1.0) + fill = int(round(perc * max_len)) + line = '#' * fill + '-' * (60 - fill) + line = line + '[{:>7.2%} {: >2d}/{}]'.format(perc, ready, total) + print('\r', line, end='') + sys.stdout.flush() + +def main(): + if "-h" in sys.argv or "--help" in sys.argv or len(sys.argv) == 1: + usage() + + build_dir = sys.argv[1] + + pkgs = get_pkgs_list(os.path.realpath(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 p.is_built(): + ready = ready + 1 + + progress(ready, total) + time.sleep(1) + + if ready == total: + print("Done") + break + +try: + main() +except KeyboardInterrupt: + do_exit = True