[PATCH v2] scripts: Add Buildbot dump-target-info.pl script

mail at adrianschmutzler.de mail at adrianschmutzler.de
Mon Aug 3 04:32:39 EDT 2020


> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces at lists.openwrt.org]
> On Behalf Of Paul Spooren
> Sent: Montag, 3. August 2020 10:11
> To: openwrt-devel at lists.openwrt.org
> Cc: Paul Spooren <mail at aparcar.org>
> Subject: [PATCH v2] scripts: Add Buildbot dump-target-info.pl script
> 
> 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/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

Name should be updated in the examples as well ...

Best

Adrian

> ...
> 
> 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=aa9
> 7f8d60379076a41b968402e9337cea824ece5;hb=HEAD
> 
> Signed-off-by: Paul Spooren <mail at aparcar.org>
> ---
>  scripts/dump-target-info.pl | 91
> +++++++++++++++++++++++++++++++++++++
>  1 file changed, 91 insertions(+)
>  create mode 100755 scripts/dump-target-info.pl
> 
> 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";
> +}
> --
> 2.25.1
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openpgp-digital-signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.openwrt.org/pipermail/openwrt-devel/attachments/20200803/ebb4103c/attachment.sig>


More information about the openwrt-devel mailing list