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# This is basically a copy of tools/release/bins.pl, with small changes.
3use File::Basename;
4use File::Path;
5use Cwd;
6
7require "tools/builds.pm";
8
9my ($verbose, $strip, $update, $doonly, $version);
10my @doonly;
11
12my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time());
13$year+=1900;
14$mon+=1;
15$verbose=0;
16
17my $filename = "rockbox-sim-<target>-<version>";
18
19while (scalar @ARGV > 0) {
20 if ($ARGV[0] eq "-h") {
21 print $ARGV[0]."\n";
22 print <<MOO
23Usage: w32sims [-v] [-u] [-s] [-w] [-r VERSION] [-f filename] [buildonly]
24 -v Verbose output
25 -u Run 'git pull' before building
26 -r Use the specified version string for filenames (defaults to git revision)
27 -s Strip binaries before zipping them up.
28 -w Crosscompile for Windows (requires mingw32)
29 -f Filename format string (without extension). This can include a
30 filepath (relative or absolute) May include the following special
31 strings:
32 <version> - Replaced by the revision (or version name if -r is
33 used)
34 <target> - Target shortname
35 <YYYY> - Year (4 digits)
36 <MM> - Month (2 digits)
37 <DD> - Day of month (2 digits - 0-padded)
38 <HH> - Hour of day (2 digits, 0-padded, 00-23)
39 <mm> - Minute (2 digits, 0-padded)
40 The default filename is rockbox-sim-<target>-<version>
41MOO
42;
43 exit 1;
44 }
45 elsif ($ARGV[0] eq "-v") {
46 $verbose =1;
47 }
48 elsif ($ARGV[0] eq "-u") {
49 $update =1;
50 }
51 elsif ($ARGV[0] eq "-s") {
52 $strip =1;
53 }
54 elsif ($ARGV[0] eq "-w") {
55 $cross =1;
56 }
57 elsif ($ARGV[0] eq "-r") {
58 $version =$ARGV[1];
59 shift @ARGV;
60 }
61 elsif ($ARGV[0] eq "-f") {
62 $filename = $ARGV[1];
63 shift @ARGV;
64 }
65 else {
66 push(@doonly,$ARGV[0]);
67 }
68 shift @ARGV;
69}
70
71if($update) {
72 # Update git repo!
73 system("git pull");
74}
75
76$test = `sdl2-config --libs`;
77if ($test eq "") {
78 printf("You don't appear to have sdl2-config\n");
79 die();
80}
81
82$rev = `tools/version.sh .`;
83chomp $rev;
84
85if (@doonly) {
86 printf("Build only %s\n", join(', ', @doonly)) if($verbose);
87}
88
89if (!defined($version)) {
90 $version = $rev;
91}
92print "version $version\n" if($verbose);
93
94# made once for all targets
95sub runone {
96 my ($dir, $extra)=@_;
97 my $a;
98
99 if(@doonly > 0 && !grep(/^$dir$/, @doonly)) {
100 return;
101 }
102
103 mkdir "build-$dir";
104 chdir "build-$dir";
105 print "Build in build-$dir\n" if($verbose);
106
107 # build the target
108 $a = buildit($dir, $extra);
109
110 # Do not continue if the rockboxui executable is not created. This will
111 # prevent a good build getting overwritten by a bad build when
112 # uploaded to the web server.
113 unless ( (-e "rockboxui") || (-e "rockboxui.exe") ) {
114 print "No rockboxui, clean up and return\n" if($verbose);
115 chdir "..";
116 system("rm -rf build-$dir");
117 return $a;
118 }
119
120 if ($strip) {
121 print "Stripping binaries\n" if ($verbose);
122 # find \( -name "*.exe" -o -name "*.rock" -o -name "*.codec" \) -exec ls -l "{}" ";"
123 open(MAKE, "Makefile");
124 my $AS=(grep(/^export AS=/, <MAKE>))[0];
125 chomp($AS);
126 (my $striptool = $AS) =~ s/^export AS=(.*)as$/$1strip/;
127
128 $cmd = "find \\( -name 'rockboxui*' -o -iname '*dll' -o -name '*.rock' -o -name '*.codec' \\) -exec $striptool '{}' ';'";
129 print("$cmd\n") if ($verbose);
130 `$cmd`;
131 close(MAKE);
132 }
133
134 chdir "..";
135
136 my $newo=$filename;
137
138 $newo =~ s/<version>/$version/g;
139 $newo =~ s/<target>/$dir/g;
140 $newo =~ s/<YYYY>/$year/g;
141 $newo =~ s/<MM>/$mon/g;
142 $newo =~ s/<DD>/$mday/g;
143 $newo =~ s/<HH>/$hour/g;
144 $newo =~ s/<mm>/$min/g;
145
146
147 print "Zip up the sim and associated files\n" if ($verbose);
148 mkpath(dirname($newo));
149 system("mv build-$dir $newo");
150 my $toplevel = getcwd();
151 chdir(dirname($newo));
152 $cmd = "zip -9 -r -q \"".basename($newo)."\" "
153 . "\"".basename($newo)."\"/rockboxui* "
154 . "\"".basename($newo)."\"/UI256.bmp "
155 . "\"".basename($newo)."\"/simdisk ";
156 print("$cmd\n") if($verbose);
157 `$cmd`;
158 chdir($toplevel);
159
160 print "remove all contents in $newo\n" if($verbose);
161 system("rm -rf $newo");
162
163 return $a;
164};
165
166sub buildit {
167 my ($dir, $extra)=@_;
168
169 `rm -rf * >/dev/null 2>&1`;
170
171 if ($cross) {
172 $simstring = 'a\nw\ns\n\n';
173 }
174 else {
175 $simstring = 's\n';
176 }
177
178 my $c = sprintf('printf "%s\n%s%s" | ../tools/configure',
179 $dir, $extra, $simstring);
180
181 print "C: $c\n" if($verbose);
182 `$c`;
183
184 print "Run 'make'\n" if($verbose);
185 `make 2>/dev/null`;
186
187 print "Run 'make install'\n" if($verbose);
188 `make install 2>/dev/null`;
189}
190
191for my $b (sort &simbuilds) {
192 if ($builds{$b}{ram} ne '')
193 {
194 # These builds need the ram size sent to configure
195 runone($b, $builds{$b}{ram} . '\n');
196 }
197 else
198 {
199 runone($b);
200 }
201}