From patchwork Wed Jul 17 23:55:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 1133467 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.137; helo=fraxinus.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="rlrplLUg"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45pvLj4HpNz9sDQ for ; Thu, 18 Jul 2019 09:56:45 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 5B891869BE; Wed, 17 Jul 2019 23:56:42 +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 xUH7KbRMBosI; Wed, 17 Jul 2019 23:56:41 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id CC83D86990; Wed, 17 Jul 2019 23:56:41 +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 69CE91BF33A for ; Wed, 17 Jul 2019 23:56:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 6673486990 for ; Wed, 17 Jul 2019 23:56:41 +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 llIRV01x15l0 for ; Wed, 17 Jul 2019 23:56:40 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 7C0D28697E for ; Wed, 17 Jul 2019 23:56:40 +0000 (UTC) Received: by mail-lj1-f175.google.com with SMTP id d24so25402311ljg.8 for ; Wed, 17 Jul 2019 16:56:40 -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=XCPrbq+5J9e91RQBT0kbT7bEYZM33QYGaNcNNwL2hcI=; b=rlrplLUgDo2cezRrKeGxuewY1hL3JI5S6mIgvZW9xuPIV+KeP/d8g7kKK+hHF8fJh2 nbXEvPXdjxh5xHvfej+Du8by96u/+SDhZvCTbprvrD7IKYpeMIMNnFxszaDIuuikD9kL IVAyfy+FU1+trm1LUDeYfB+o2gi5+lGkEC5ErKSbe6Kof3Wo2syrX6FeQnO0fgdHRsD1 jcZpG50EAp1dgYUtgw6aARckkA6o7xxKwtn0JLondUWsheiOLH558MJ6gV1uEPwHb1mv 7IbQP4FAHhG6krhSgVW98UFQifEZxn7Q74Iz8B8QrMbEWvRsRXS25pdF0uQrca/Rvm8h OIPQ== 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=XCPrbq+5J9e91RQBT0kbT7bEYZM33QYGaNcNNwL2hcI=; b=oOBLt+Pr51ScfjahczpLK+n7Dm8OER3xDlObrxBdCTVJG2fz1wuDcg/FSRmVSj7dBH HMgESs4HU9xNvppCLyGuNX9w5G3W1k4WckUj6GOa912QW0AX2ZpXzHNJSlzufs2KV4rV 8zvnVGb1SmfwGnUlwyvuO+BEAyD04kT+vNFgr1Fw5kfGj2HUW46BrhD4xAJUe/yENli7 5erqQDBhdB1KLfg4Jd1zYvNJyN9iHXOlRmecw/Hky8nIHX01drh9tJoqrHHMnWqmvQrc liM8D07iS2f5jstijmX3WHhgUdStI7onh8RJGCvfXWOP9os/5heNgYwJdI5zoZLuIJHA EKqA== X-Gm-Message-State: APjAAAUHak9jZxtvCXbPQb0xsBOZEXEgS4T/Q9xucoIA6JtU+u4KxcYi rnVg5oao0fHS1kwdaZz61EUvQ+U8 X-Google-Smtp-Source: APXvYqyjcVUTE/tad1VDv4RKuL2GMdFjjHTH44OLtOkwhLRUUZWWLe2AAy7i8g+ewTZChed6pg9duA== X-Received: by 2002:a2e:9192:: with SMTP id f18mr22174313ljg.52.1563407798305; Wed, 17 Jul 2019 16:56:38 -0700 (PDT) Received: from localhost.localdomain ([93.75.246.20]) by smtp.gmail.com with ESMTPSA id b17sm4778623ljf.34.2019.07.17.16.56.37 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 17 Jul 2019 16:56:37 -0700 (PDT) From: Vadim Kochan To: buildroot@buildroot.org Date: Thu, 18 Jul 2019 02:55:15 +0300 Message-Id: <20190717235515.28725-1-vadim4j@gmail.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Subject: [Buildroot] [RFC 1/1] utils/build-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 abort ... Building: output/qemu_x86_64 ##################################------------------------------ [ 42.42% 14/33] Signed-off-by: Vadim Kochan --- utils/build-progress | 88 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 utils/build-progress diff --git a/utils/build-progress b/utils/build-progress new file mode 100755 index 0000000000..9af9a9af2a --- /dev/null +++ b/utils/build-progress @@ -0,0 +1,88 @@ +#!/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: build-progress [-h] [PATH] +build-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: + $ build-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: + ver = "" if pkg_list[p]["type"] == "rootfs" or \ + pkg_list[p]["virtual"] else "-" + pkg_list[p]["version"] + + 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 abort ...\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 + + if ready == total: + print("Done") + break + + progress(ready, total) + time.sleep(1) + +try: + main() +except KeyboardInterrupt: + do_exit = True