fix red.
[kugel-rb/myfork.git] / tools / release / sims.pl
blobbcec7065c637ad4d77bd239529b64c4bdef8a987
1 #!/usr/bin/perl
2 # This is basically a copy of tools/release/bins.pl, with small changes.
3 use File::Basename;
4 use File::Path;
5 use Cwd;
7 my $verbose, $strip, $update, $doonly, $version;
8 my @doonly;
10 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time());
11 $year+=1900;
12 $mon+=1;
13 $verbose=0;
15 my $filename = "rockbox-sim-<target>-<version>";
17 while (scalar @ARGV > 0) {
18 if ($ARGV[0] eq "-h") {
19 print $ARGV[0]."\n";
20 print <<MOO
21 Usage: w32sims [-v] [-u] [-r VERSION] [-f filename] [buildonly]
22 -v Verbose output
23 -u Run svn up before building
24 -r Use the specified version string for filenames (defaults to SVN
25 revision)
26 -s Strip binaries before zipping them up.
27 -f Filename format string (without extension). This can include a
28 filepath (relative or absolute) May include the following special
29 strings:
30 <version> - Replaced by the revision (or version name if -r is
31 used)
32 <target> - Target shortname
33 <YYYY> - Year (4 digits)
34 <MM> - Month (2 digits)
35 <DD> - Day of month (2 digits - 0-padded)
36 <HH> - Hour of day (2 digits, 0-padded, 00-23)
37 <mm> - Minute (2 digits, 0-padded)
38 The default filename is rockbox-sim-<target>-<version>
39 MOO
41 exit 1;
43 elsif ($ARGV[0] eq "-v") {
44 $verbose =1;
46 elsif ($ARGV[0] eq "-u") {
47 $update =1;
49 elsif ($ARGV[0] eq "-s") {
50 $strip =1;
52 elsif ($ARGV[0] eq "-r") {
53 $version =$ARGV[1];
54 shift @ARGV;
56 elsif ($ARGV[0] eq "-f") {
57 $filename = $ARGV[1];
58 shift @ARGV;
60 else {
61 push(@doonly,$ARGV[0]);
63 shift @ARGV;
66 if($update) {
67 # svn update!
68 system("svn -q up");
71 $test = `sdl-config --libs`;
72 if ($test eq "") {
73 printf("You don't appear to have sdl-config\n");
74 die();
77 $rev = `tools/version.sh .`;
78 chomp $rev;
79 print "rev $rev\n" if($verbose);
81 if (@doonly) {
82 printf("Build only %s\n", join(', ', @doonly)) if($verbose);
85 if (!defined($version)) {
86 $version = $rev;
89 # made once for all targets
90 sub runone {
91 my ($dir, $confnum, $extra)=@_;
92 my $a;
94 if(@doonly > 0 && !grep(/^$dir$/, @doonly)) {
95 return;
98 mkdir "build-$dir";
99 chdir "build-$dir";
100 print "Build in build-$dir\n" if($verbose);
102 # build the target
103 $a = buildit($dir, $confnum, $extra);
105 if ($strip) {
106 print "Stripping binaries\n" if ($verbose);
107 # find \( -name "*.exe" -o -name "*.rock" -o -name "*.codec" \) -exec ls -l "{}" ";"
108 open(MAKE, "Makefile");
109 my $AS=(grep(/^export AS=/, <MAKE>))[0];
110 chomp($AS);
111 (my $striptool = $AS) =~ s/^export AS=(.*)as$/$1strip/;
113 $cmd = "find \\( -name 'rockboxui*' -o -iname '*dll' -o -name '*.rock' -o -name '*.codec' \\) -exec $striptool '{}' ';'";
114 print("$cmd\n") if ($verbose);
115 `$cmd`;
118 chdir "..";
120 my $newo=$filename;
122 $newo =~ s/<version>/$version/g;
123 $newo =~ s/<target>/$dir/g;
124 $newo =~ s/<YYYY>/$year/g;
125 $newo =~ s/<MM>/$mon/g;
126 $newo =~ s/<DD>/$mday/g;
127 $newo =~ s/<HH>/$hour/g;
128 $newo =~ s/<mm>/$min/g;
131 print "Zip up the sim and associated files\n" if ($verbose);
132 mkpath(dirname($newo));
133 system("mv build-$dir $newo");
134 if (-f "$newo/rockboxui.exe") {
135 print "Find and copy SDL.dll\n" if ($verbose);
136 `cp \`dirname \\\`which sdl-config\\\`\`/SDL.dll ./$newo/`;
138 my $toplevel = getcwd();
139 chdir(dirname($newo));
140 $cmd = "zip -9 -r -q \"".basename($newo)."\" \"".basename($newo)."\"/{rockboxui*,UI256.bmp,SDL.dll,simdisk}";
141 print("$cmd\n") if($verbose);
142 `$cmd`;
143 chdir($toplevel);
145 print "remove all contents in $newo\n" if($verbose);
146 system("rm -rf $newo");
148 return $a;
151 sub buildit {
152 my ($target, $confnum, $extra)=@_;
154 `rm -rf * >/dev/null 2>&1`;
156 my $c = sprintf('printf "%s\n%ss\n" | ../tools/configure',
157 $confnum, $extra);
159 print "C: $c\n" if($verbose);
160 `$c`;
162 print "Run 'make'\n" if($verbose);
163 `make 2>/dev/null`;
165 print "Run 'make install'\n" if($verbose);
166 `make install 2>/dev/null`;
169 runone("player", "player", '\n');
170 runone("recorder", "recorder", '\n');
171 #runone("recorder8mb", "recorder", '8\n');
172 runone("fmrecorder", "fmrecorder", '\n');
173 #runone("fmrecorder8mb", "fmrecorder", '8\n');
174 runone("recorderv2", "recorderv2", '\n');
175 runone("ondiosp", "ondiosp", '\n');
176 runone("ondiofm", "ondiofm", '\n');
177 runone("h100", "h100");
178 runone("h120", "h120");
179 runone("h300", "h300");
180 runone("ipodcolor", "ipodcolor");
181 runone("ipodnano", "ipodnano");
182 runone("ipod4gray", "ipod4g");
183 runone("ipodvideo", "ipodvideo", '32\n');
184 #runone("ipodvideo64mb", "ipodvideo", '64\n');
185 runone("ipod3g", "ipod3g");
186 runone("ipod1g2g", "ipod1g2g");
187 runone("iaudiox5", "x5");
188 runone("iaudiom5", "m5");
189 runone("iaudiom3", "m3");
190 runone("ipodmini1g", "ipodmini");
191 runone("ipodmini2g", "ipodmini2g");
192 runone("h10", "h10");
193 runone("h10_5gb", "h10_5gb");
194 runone("gigabeatf", "gigabeatf");
195 runone("gigabeats", "gigabeats");
196 runone("sansae200", "e200");
197 runone("sansae200v2", "e200v2");
198 runone("sansac200", "c200");
199 runone("mrobe500", "mrobe500");
200 runone("mrobe100", "mrobe100");
201 runone("cowond2", "cowond2");
202 runone("clip", "clip");
203 runone("zvm30gb", "creativezvm30gb");
204 runone("zvm60gb", "creativezvm60gb");
205 runone("zenvision", "creativezenvision");
206 runone("hdd1630", "hdd1630");
207 runone("fuze", "fuze");
208 runone("m200v4", "m200v4");
209 runone("sa9200", "sa9200");
210 runone("sansac200v2", "c200v2");
211 runone("yh820", "yh_820");
212 runone("yh920", "yh_920");
213 runone("yh925", "yh_925");
214 runone("ondavx747", "ondavx747");
215 runone("ondavx747p", "ondavx747p");
216 runone("ifp7xx", "ifp7xx");