From patchwork Mon Aug 3 17:31:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Spooren X-Patchwork-Id: 1340392 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=Isx8iTCc; 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 4BL4jx1YL7z9sTd for ; Tue, 4 Aug 2020 03:33:41 +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:References:In-Reply-To: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:List-Owner; bh=qgYgmA1ZAu+F9RlEVSUHdbNRnbdnjSAW6UJtwuMKtbo=; b=Isx8iTCcwhxJNs/AEmrwgx/1l ubN1hCptm2lo8N2pLlEc/ZlXwGwLQwiYBN5Y6egP1ZADzDS8agcmNB6KH189rTcIRHhIs9XSX89oB PlQLGyIIM2GIilUQMscWbC3ewpiKRWzeGq25pkhnFlINy2JGZ4tEsiuHVa63YIZ/HG+Q0fDTKu3r5 xnQ3KrZD1sri7tGopoW2nWrPV39/cCa1LDaXgv92useXo86Bev9kcs1tVB/knkJHf4JuIkedfkfkW BeySbiItAgERtuCCKMvl/Lk016rBHeXnRhAOxUtgECLH9tQHyRRKPM80k6MSMzULH0SQQ+c8YGJar fs9QCDz0A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2eJv-00033Y-2z; Mon, 03 Aug 2020 17:32:19 +0000 Received: from relay1-d.mail.gandi.net ([217.70.183.193]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2eJs-00033A-KD for openwrt-devel@lists.openwrt.org; Mon, 03 Aug 2020 17:32:18 +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 relay1-d.mail.gandi.net (Postfix) with ESMTPA id 6C4E524000A; Mon, 3 Aug 2020 17:32:11 +0000 (UTC) From: Paul Spooren To: openwrt-devel@lists.openwrt.org Subject: [PATCH v3] scripts: Add Buildbot dump-target-info.pl script Date: Mon, 3 Aug 2020 07:31:43 -1000 Message-Id: <20200803173142.373689-1-mail@aparcar.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713031629.1716736-1-mail@aparcar.org> References: <20200713031629.1716736-1-mail@aparcar.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200803_133216_868274_1698454F X-CRM114-Status: GOOD ( 15.71 ) 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.193 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [217.70.183.193 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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: Paul Spooren Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The 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 to 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/dump-target-info.pl architectures aarch64_cortex-a53 bcm27xx/bcm2710 mediatek/mt7622 mvebu/cortexa53 sunxi/cortexa53 aarch64_cortex-a72 bcm27xx/bcm2711 mvebu/cortexa72 ... $ ./scripts/dump-target-info.pl targets apm821xx/nand powerpc_464fp apm821xx/sata powerpc_464fp ... In the future the the script could be removed from the buildbot repository and maintained only here. Rename `dumpinfo.pl` to `dump-target-info.pl` to improve verbosity of filename. [0]: https://git.openwrt.org/?p=buildbot.git;a=blob;f=scripts/dumpinfo.pl;h=aa97f8d60379076a41b968402e9337cea824ece5;hb=HEAD Signed-off-by: Paul Spooren --- v2: rename dumpinfo.pl to dump-target-info.pl v3: fix example naming scripts/checkpatch.sh | 3 ++ scripts/dump-target-info.pl | 91 +++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 scripts/checkpatch.sh create mode 100755 scripts/dump-target-info.pl diff --git a/scripts/checkpatch.sh b/scripts/checkpatch.sh new file mode 100644 index 0000000000..720b337ab7 --- /dev/null +++ b/scripts/checkpatch.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +PATCH_FILES="$*" make kernel_checkpatch diff --git a/scripts/dump-target-info.pl b/scripts/dump-target-info.pl new file mode 100755 index 0000000000..aa97f8d603 --- /dev/null +++ b/scripts/dump-target-info.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"; +}