- Factor out container specific code from apps/codecs/wma.c.
[kugel-rb.git] / tools / release / sims.pl
bloba9d094c35698fe82f630c76c694364f2eab3f7e0
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 require "tools/builds.pm";
9 my $verbose, $strip, $update, $doonly, $version;
10 my @doonly;
12 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time());
13 $year+=1900;
14 $mon+=1;
15 $verbose=0;
17 my $filename = "rockbox-sim-<target>-<version>";
19 while (scalar @ARGV > 0) {
20 if ($ARGV[0] eq "-h") {
21 print $ARGV[0]."\n";
22 print <<MOO
23 Usage: w32sims [-v] [-u] [-s] [-w] [-r VERSION] [-f filename] [buildonly]
24 -v Verbose output
25 -u Run svn up before building
26 -r Use the specified version string for filenames (defaults to SVN
27 revision)
28 -s Strip binaries before zipping them up.
29 -w Crosscompile for Windows (requires mingw32)
30 -f Filename format string (without extension). This can include a
31 filepath (relative or absolute) May include the following special
32 strings:
33 <version> - Replaced by the revision (or version name if -r is
34 used)
35 <target> - Target shortname
36 <YYYY> - Year (4 digits)
37 <MM> - Month (2 digits)
38 <DD> - Day of month (2 digits - 0-padded)
39 <HH> - Hour of day (2 digits, 0-padded, 00-23)
40 <mm> - Minute (2 digits, 0-padded)
41 The default filename is rockbox-sim-<target>-<version>
42 MOO
44 exit 1;
46 elsif ($ARGV[0] eq "-v") {
47 $verbose =1;
49 elsif ($ARGV[0] eq "-u") {
50 $update =1;
52 elsif ($ARGV[0] eq "-s") {
53 $strip =1;
55 elsif ($ARGV[0] eq "-w") {
56 $cross =1;
58 elsif ($ARGV[0] eq "-r") {
59 $version =$ARGV[1];
60 shift @ARGV;
62 elsif ($ARGV[0] eq "-f") {
63 $filename = $ARGV[1];
64 shift @ARGV;
66 else {
67 push(@doonly,$ARGV[0]);
69 shift @ARGV;
72 if($update) {
73 # svn update!
74 system("svn -q up");
77 $test = `sdl-config --libs`;
78 if ($test eq "") {
79 printf("You don't appear to have sdl-config\n");
80 die();
83 $rev = `tools/version.sh .`;
84 chomp $rev;
85 print "rev $rev\n" if($verbose);
87 if (@doonly) {
88 printf("Build only %s\n", join(', ', @doonly)) if($verbose);
91 if (!defined($version)) {
92 $version = $rev;
95 # made once for all targets
96 sub runone {
97 my ($dir, $extra)=@_;
98 my $a;
100 if(@doonly > 0 && !grep(/^$dir$/, @doonly)) {
101 return;
104 mkdir "build-$dir";
105 chdir "build-$dir";
106 print "Build in build-$dir\n" if($verbose);
108 # build the target
109 $a = buildit($dir, $extra);
111 # Do not continue if the rockboxui executable is not created. This will
112 # prevent a good build getting overwritten by a bad build when
113 # uploaded to the web server.
114 unless ( (-e "rockboxui") || (-e "rockboxui.exe") ) {
115 print "No rockboxui, clean up and return\n" if($verbose);
116 chdir "..";
117 system("rm -rf build-$dir");
118 return $a;
121 if ($strip) {
122 print "Stripping binaries\n" if ($verbose);
123 # find \( -name "*.exe" -o -name "*.rock" -o -name "*.codec" \) -exec ls -l "{}" ";"
124 open(MAKE, "Makefile");
125 my $AS=(grep(/^export AS=/, <MAKE>))[0];
126 chomp($AS);
127 (my $striptool = $AS) =~ s/^export AS=(.*)as$/$1strip/;
129 $cmd = "find \\( -name 'rockboxui*' -o -iname '*dll' -o -name '*.rock' -o -name '*.codec' \\) -exec $striptool '{}' ';'";
130 print("$cmd\n") if ($verbose);
131 `$cmd`;
132 close(MAKE);
135 chdir "..";
137 my $newo=$filename;
139 $newo =~ s/<version>/$version/g;
140 $newo =~ s/<target>/$dir/g;
141 $newo =~ s/<YYYY>/$year/g;
142 $newo =~ s/<MM>/$mon/g;
143 $newo =~ s/<DD>/$mday/g;
144 $newo =~ s/<HH>/$hour/g;
145 $newo =~ s/<mm>/$min/g;
148 print "Zip up the sim and associated files\n" if ($verbose);
149 mkpath(dirname($newo));
150 system("mv build-$dir $newo");
151 if ($cross) {
152 print "Find and copy SDL.dll\n" if ($verbose);
153 open(MAKE, "$newo/Makefile");
154 my $GCCOPTS=(grep(/^export GCCOPTS=/, <MAKE>))[0];
155 chomp($GCCOPTS);
156 (my $sdldll = $GCCOPTS) =~ s/^export GCCOPTS=.*-I([^ ]+)\/include\/SDL.*$/$1\/bin\/SDL.dll/;
157 print "Found $sdldll\n" if ($verbose);
158 `cp $sdldll ./$newo/`;
159 close(MAKE);
161 my $toplevel = getcwd();
162 chdir(dirname($newo));
163 $cmd = "zip -9 -r -q \"".basename($newo)."\" "
164 . "\"".basename($newo)."\"/rockboxui* "
165 . "\"".basename($newo)."\"/UI256.bmp "
166 . "\"".basename($newo)."\"/SDL.dll "
167 . "\"".basename($newo)."\"/simdisk ";
168 print("$cmd\n") if($verbose);
169 `$cmd`;
170 chdir($toplevel);
172 print "remove all contents in $newo\n" if($verbose);
173 system("rm -rf $newo");
175 return $a;
178 sub buildit {
179 my ($dir, $extra)=@_;
181 `rm -rf * >/dev/null 2>&1`;
183 if ($cross) {
184 $simstring = 'a\nw\ns\n\n';
186 else {
187 $simstring = 's\n';
190 my $c = sprintf('printf "%s\n%s%s" | ../tools/configure',
191 $dir, $extra, $simstring);
193 print "C: $c\n" if($verbose);
194 `$c`;
196 print "Run 'make'\n" if($verbose);
197 `make 2>/dev/null`;
199 print "Run 'make install'\n" if($verbose);
200 `make install 2>/dev/null`;
203 for my $b (sort byname keys %builds) {
204 if ($builds{$b}{status} >= 2)
206 # ipodvideo64mb uses the ipodvideo simulator
207 # sansae200r uses the sansae200 simulator
208 if ($b ne 'ipodvideo64mb' && $b ne 'sansae200r')
210 if ($builds{$b}{ram} ne '')
212 # These builds need the ram size sent to configure
213 runone($b, $builds{$b}{ram} . '\n');
215 else
217 runone($b);
223 #The following ports are in the unusable category, but the simulator does build
224 runone("gogearhdd1630");
225 runone("gogearsa9200");
226 runone("mini2440");
227 runone("ondavx747");
228 runone("ondavx747p");
229 runone("ondavx777");
230 runone("sansac200v2");
231 runone("sansam200v4");
232 runone("zenvision");
233 runone("zenvisionm30gb");
234 runone("zenvisionm60gb");