aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Marangi <ansuelsmth@gmail.com>2023-11-12 19:14:46 +0100
committerChristian Marangi <ansuelsmth@gmail.com>2023-11-15 11:00:42 +0100
commit7dabd7a206856d9a77fadc15b08ed0c04d995767 (patch)
treece85b0a8f71de1c8cc39b6f7e48beef395782f90
parent3555a2930f9ccefaabe4400364e1e2b29692b5de (diff)
downloadupstream-7dabd7a206856d9a77fadc15b08ed0c04d995767.tar.gz
upstream-7dabd7a206856d9a77fadc15b08ed0c04d995767.tar.bz2
upstream-7dabd7a206856d9a77fadc15b08ed0c04d995767.zip
scripts/dump-target-info.pl: add new function to DUMP devices
Add new function to dump-targer-info.pl to DUMP devices provided a matching target/subtarget. Example: ./scripts/dump-targer-info.pl devices ipq806x/generic will produce the sorted list of devices defined in the following format: device_id device_name Devices may have alternative names, the script will dump each alternative name in the same line of device_id. Following the pattern: device_id "PRIMARY DEVICE NAME" "ALT0 DEVICE NAME" "ALT1 DEVICE NAME" ... Example: tplink_ad7200 "TP-Link AD7200 v1/v2" "TP-Link Talon AD7200 v1/v2" Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> (cherry picked from commit 943c153cdd695904b9b7fe44800fc3546644973e)
-rwxr-xr-xscripts/dump-target-info.pl80
1 files changed, 79 insertions, 1 deletions
diff --git a/scripts/dump-target-info.pl b/scripts/dump-target-info.pl
index 0e4af17fe0..eec06ed6c4 100755
--- a/scripts/dump-target-info.pl
+++ b/scripts/dump-target-info.pl
@@ -4,7 +4,7 @@ use strict;
use warnings;
use Cwd;
-my (%targets, %architectures, %kernels);
+my (%targets, %architectures, %kernels, %devices);
$ENV{'TOPDIR'} = Cwd::getcwd();
@@ -56,6 +56,68 @@ sub parse_targetinfo {
}
}
+sub parse_devices {
+ my ($target_dir, $subtarget) = @_;
+
+ if (open M, "make -C '$target_dir' --no-print-directory DUMP=1 TARGET_BUILD=1 SUBTARGET='$subtarget' V=s |") {
+ my ($device_profile, $device_name, @device_alt_names, $device_is_alt);
+ while (defined(my $line = readline M)) {
+ chomp $line;
+
+ if ($line =~ /^Target-Profile-Name: (.+)$/) {
+ $device_name = $1;
+ }
+ elsif ($line =~ /^Target-Profile: DEVICE_(.+)$/) {
+ $device_profile = $1;
+ }
+ # Logic behind this.
+ # DUMP duplicate info for each alternative device name and
+ # the alternative device name are printed first before the
+ # primary device name
+ # Alternative device titles always have the full list of
+ # all the alternative device name.
+ # The device name pattern for an alternative device name is
+ # Target-Profile-Name: ALT_NAME (PRIMARY_NAME)
+ # We compare the detected device name and check if it does
+ # match the alternative device name pattern with one of
+ # the alternative device name in Alternative device titles:
+ # If an alternative device name is detected,
+ # alternative device is skipped.
+ elsif ($line =~ /^Alternative device titles:$/) {
+ while (defined($line = readline M)) {
+ if ($line =~ /^- (.+)$/) {
+ if ($device_name =~ /^\Q$1\E \((.+)\)$/) {
+ $device_is_alt = 1;
+ last;
+ }
+ push @device_alt_names, $1;
+ }
+ else {
+ last;
+ }
+ }
+ }
+ if ($line =~ /^@\@$/) {
+ if ($device_name && $device_profile && ! $device_is_alt) {
+ push @{$devices{$device_profile}}, $device_name;
+
+ if (scalar @device_alt_names) {
+ foreach my $device_alt_name (sort values @device_alt_names) {
+ push @{$devices{$device_profile}}, $device_alt_name;
+ }
+ }
+ }
+
+ undef $device_name;
+ undef $device_profile;
+ undef $device_is_alt;
+ @device_alt_names = ();
+ }
+ }
+ close M;
+ }
+}
+
sub get_targetinfo {
foreach my $target_makefile (glob "target/linux/*/Makefile") {
my ($target_dir) = $target_makefile =~ m!^(.+)/Makefile$!;
@@ -86,6 +148,15 @@ sub get_targetinfo {
}
}
+sub get_devices {
+ my ($target_subtarget) = @_;
+ my ($target, $subtarget) = split /\//, $target_subtarget;
+
+ my ($target_dir) = "target/linux/" . $target;
+
+ parse_devices($target_dir, $subtarget)
+}
+
if (@ARGV == 1 && $ARGV[0] eq 'targets') {
get_targetinfo();
foreach my $target_name (sort keys %targets) {
@@ -104,8 +175,15 @@ elsif (@ARGV == 1 && $ARGV[0] eq 'kernels') {
printf "%s %s\n", $target_name, join ' ', @{$kernels{$target_name}};
}
}
+elsif (@ARGV == 2 && $ARGV[0] eq 'devices') {
+ get_devices($ARGV[1]);
+ foreach my $device (sort keys %devices) {
+ printf "%s \"%s\"\n", $device, join '" "', @{$devices{$device}};
+ }
+}
else {
print "Usage: $0 targets\n";
print "Usage: $0 architectures\n";
print "Usage: $0 kernels\n";
+ print "Usage: $0 devices <target/subtarget>\n";
}