A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1#!/usr/bin/perl
2# __________ __ ___.
3# Open \______ \ ____ ____ | | _\_ |__ _______ ___
4# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7# \/ \/ \/ \/ \/
8#
9# Purpose: extract and gather info from a build and put that in a standard
10# way in the output file. Meant to be put in rockbox zip package to help and
11# aid machine installers and more.
12#
13
14my $output = $ARGV[0];
15
16sub filesize {
17 my ($f)=@_;
18 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
19 $atime,$mtime,$ctime,$blksize,$blocks)
20 = stat($f);
21 return $size;
22}
23
24sub cmd1line {
25 my ($c)=@_;
26 my @out=`$c 2>/dev/null`;
27 chomp $out[0];
28 return $out[0];
29}
30
31sub definescan {
32 my ($f, $d)=($_[0], $_[1]);
33 my $v;
34 open(M, "<$f");
35 while(<M>) {
36 if($_ =~ /\#define\s+$d\s+([^\s]+)\s?/) {
37 $v = $1;
38 last;
39 }
40 }
41 close(M);
42
43 return $v;
44}
45
46sub mapscan {
47 my ($f)=@_;
48 my $start, $end;
49 open(M, "<$f");
50 while(<M>) {
51 if($_ =~ / +0x([0-9a-f]+) *_end = \./) {
52 $end = $1;
53 last;
54 }
55 elsif($_ =~ / +0x([0-9a-f]+) *_loadaddress = \./) {
56 $start = $1;
57 }
58 elsif($_ =~ / +0x([0-9a-f]+) *_dramcopystart = \./) {
59 $start = $1;
60 }
61 elsif($_ =~ / +0x([0-9a-f]+) *__start/) {
62 $start = $1;
63 }
64 }
65 close(M);
66
67 # return number of bytes
68 return hex($end) - hex($start);
69}
70
71sub features {
72 my ($f)=@_;
73 my $feat;
74 open(M, "<$f");
75 while(<M>) {
76 chomp;
77 if($feat) {
78 $feat.=":";
79 }
80 $feat.=$_;
81 }
82 close(M);
83 return $feat;
84}
85
86if(!$output) {
87 print "Usage: mkinfo.pl <filename>\n";
88 exit;
89}
90open(O, ">$output") || die "couldn't open $output for writing";
91
92# Variables identifying the target, that should remain the same as long
93# as the hardware is unmodified
94printf O ("Target: %s\n", $ENV{'MODELNAME'});
95printf O ("Target id: %d\n", $ENV{'TARGET_ID'});
96printf O ("Target define: %s\n", $ENV{'TARGET'});
97printf O ("Memory: %d\n", $ENV{'MEMORYSIZE'});
98printf O ("CPU: %s\n", $ENV{'CPU'});
99printf O ("Manufacturer: %s\n", $ENV{'MANUFACTURER'});
100
101# Variables identifying Rockbox and bootloader properties. Possibly changing
102# every software upgrade.
103printf O ("Version: %s", `$ENV{TOOLSDIR}/version.sh $ENV{ROOTDIR}`);
104printf O ("Binary: %s\n", $ENV{'BINARY'});
105printf O ("Binary size: %s\n", filesize($ENV{'BINARY'}));
106printf O ("Voice format: %s\n", definescan("$ENV{APPSDIR}/talk.h", "VOICE_VERSION"));
107
108if ($ENV{'APPSDIR'} =~ /\/apps$/) {
109 if (-f "rockbox.bin") {
110 printf O ("Actual size: %s\n", filesize("rockbox.bin"));
111 } else {
112 printf O ("Actual size: %s\n", filesize($ENV{'BINARY'}));
113 }
114 printf O ("RAM usage: %s\n", mapscan("rockbox.map"));
115 printf O ("Features: %s\n", features("apps/features"));
116} elsif ($ENV{'APPSDIR'} =~ /\/bootloader$/) {
117 if (-f "bootloader.bin") {
118 printf O ("Actual size: %s\n", filesize("bootloader.bin"));
119 } else {
120 printf O ("Actual size: %s\n", filesize($ENV{'BINARY'}));
121 }
122 printf O ("RAM usage: %s\n", mapscan("bootloader.map"));
123}
124
125# Variables identifying tool and build environment details
126printf O ("gcc: %s\n", cmd1line("$ENV{'CC'} --version"));
127printf O ("ld: %s\n", cmd1line("$ENV{'LD'} --version"));
128printf O ("Host gcc: %s\n", cmd1line("$ENV{'HOSTCC'} --version"));
129printf O ("Host system: %s\n", $ENV{'UNAME'});
130
131close(O);