From patchwork Mon Jul 13 03:16:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Spooren X-Patchwork-Id: 1327683 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=aparcar.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=R36D4s7L; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B4plL4dz1z9sR4 for ; Mon, 13 Jul 2020 13:18:54 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=JSA7ksDskM4Cwmxq7Gx0HZ5VaQIjSJ2rIaFdRepyHcg=; b=R36D4s7LHq60CRLw8zKz8Qo97U /UvY8djtd1YS9vmztuetPAXhQujEkTbMj9crCr0PZkMZ3JsHk8knPjSvFbVqj5quudBGfH2reHJ2c GmVfwHPLpYIg607iYrLVR7svyLJgBtA20037EuIVnBVmqzZ+BML/rESoxt0cRB7euxL4lIIy4ScAj NBDSo/BMM4aULXV+rDD0/7Nxg892qugj8WNgPoNO46ANT7S5tDU4HKIv82oSPXyq6nLKxUSlV0QEF 0e4pDjTcpQ1EzL4NkHFamCG2VKhUDAJfufrDZYFbIJiVVs91zuOPVE7sQd0xqm2cC60DYnplHA88c OmjFL8bw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1juoxl-0001Cz-Dn; Mon, 13 Jul 2020 03:17:05 +0000 Received: from relay9-d.mail.gandi.net ([217.70.183.199]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1juoxg-0001By-SH for openwrt-devel@lists.openwrt.org; Mon, 13 Jul 2020 03:17:03 +0000 X-Originating-IP: 72.234.141.215 Received: from dawn.lan (udp224251uds.hawaiiantel.net [72.234.141.215]) (Authenticated sender: mail@aparcar.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPA id 157E6FF805; Mon, 13 Jul 2020 03:16:54 +0000 (UTC) From: Paul Spooren To: openwrt-devel@lists.openwrt.org Subject: [PATCH] scripts: Add Buildbot dumpinfo.pl script Date: Sun, 12 Jul 2020 17:16:30 -1000 Message-Id: <20200713031629.1716736-1-mail@aparcar.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200712_231701_101948_20A121D1 X-CRM114-Status: GOOD ( 10.78 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [217.70.183.199 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jo@mein.io, Paul Spooren Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The dumpinfo.pl script comes from buildbot.git[0] and is used to print available targets and architectures, which are then build. As the buildbot clones openwrt.git anyway, the script might as well live here as it can be used for other cases as well, e.g. determining what architectures are available when building Docker containers or show developers an overview which architectures are used by which target. It's called with either the parameter `architectures` or `targets`, showing architectures followed by supported targets or targets, followed by the supported architectures: $ ./scripts/dumpinfo.pl architectures aarch64_cortex-a53 bcm27xx/bcm2710 mediatek/mt7622 mvebu/cortexa53 sunxi/cortexa53 aarch64_cortex-a72 bcm27xx/bcm2711 mvebu/cortexa72 ... $ ./scripts/dumpinfo.pl targets apm821xx/nand powerpc_464fp apm821xx/sata powerpc_464fp ... In the future the `dumpinfo.pl` script could be removed from the buildbot repository and maintained only here. [0]: https://git.openwrt.org/?p=buildbot.git;a=blob;f=scripts/dumpinfo.pl;h=aa97f8d60379076a41b968402e9337cea824ece5;hb=HEAD Signed-off-by: Paul Spooren --- scripts/dumpinfo.pl | 91 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 scripts/dumpinfo.pl diff --git a/scripts/dumpinfo.pl b/scripts/dumpinfo.pl new file mode 100755 index 0000000000..aa97f8d603 --- /dev/null +++ b/scripts/dumpinfo.pl @@ -0,0 +1,91 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Cwd; + +my (%targets, %architectures); + +$ENV{'TOPDIR'} = Cwd::getcwd(); + + +sub parse_targetinfo { + my ($target_dir, $subtarget) = @_; + + if (open M, "make -C '$target_dir' --no-print-directory DUMP=1 TARGET_BUILD=1 SUBTARGET='$subtarget' |") { + my ($target_name, $target_arch, @target_features); + while (defined(my $line = readline M)) { + chomp $line; + + if ($line =~ /^Target: (.+)$/) { + $target_name = $1; + } + elsif ($line =~ /^Target-Arch-Packages: (.+)$/) { + $target_arch = $1; + } + elsif ($line =~ /^Target-Features: (.+)$/) { + @target_features = split /\s+/, $1; + } + elsif ($line =~ /^@\@$/) { + if ($target_name && $target_arch && + !grep { $_ eq 'broken' or $_ eq 'source-only' } @target_features) { + $targets{$target_name} = $target_arch; + $architectures{$target_arch} ||= []; + push @{$architectures{$target_arch}}, $target_name; + } + + undef $target_name; + undef $target_arch; + @target_features = (); + } + } + close M; + } +} + +sub get_targetinfo { + foreach my $target_makefile (glob "target/linux/*/Makefile") { + my ($target_dir) = $target_makefile =~ m!^(.+)/Makefile$!; + my @subtargets; + + if (open M, "make -C '$target_dir' --no-print-directory DUMP=1 TARGET_BUILD=1 val.FEATURES V=s 2>/dev/null |") { + if (defined(my $line = readline M)) { + chomp $line; + if (grep { $_ eq 'broken' or $_ eq 'source-only' } split /\s+/, $line) { + next; + } + } + } + + if (open M, "make -C '$target_dir' --no-print-directory DUMP=1 TARGET_BUILD=1 val.SUBTARGETS V=s 2>/dev/null |") { + if (defined(my $line = readline M)) { + chomp $line; + @subtargets = split /\s+/, $line; + } + close M; + } + + push @subtargets, 'generic' if @subtargets == 0; + + foreach my $subtarget (@subtargets) { + parse_targetinfo($target_dir, $subtarget); + } + } +} + +if (@ARGV == 1 && $ARGV[0] eq 'targets') { + get_targetinfo(); + foreach my $target_name (sort keys %targets) { + printf "%s %s\n", $target_name, $targets{$target_name}; + } +} +elsif (@ARGV == 1 && $ARGV[0] eq 'architectures') { + get_targetinfo(); + foreach my $target_arch (sort keys %architectures) { + printf "%s %s\n", $target_arch, join ' ', @{$architectures{$target_arch}}; + } +} +else { + print "Usage: $0 targets\n"; + print "Usage: $0 architectures\n"; +}