4 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
5 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
6 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
7 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 # Copyright © 2010 Rafaël Carré <rafael.carre@gmail>
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 2
15 # of the License, or (at your option) any later version.
17 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 # KIND, either express or implied.
30 def percent_diff(old
, new
):
33 diff
= 100.0*(new
-old
)/old
34 return format(diff
, '+2.2f') + '%'
39 for file in os
.listdir(dir):
40 path
= os
.path
.join(dir, file)
41 if stat
.S_ISDIR(os
.stat(path
).st_mode
) != 0:
42 dirs
+= find_map(path
)
43 elif fnmatch
.fnmatch(file, '*.map'):
49 info
= os
.path
.join(dir, 'rockbox-info.txt')
50 if not os
.path
.lexists(info
):
52 info
= open(info
).read()
53 s
= re
.search('^Version: .*', info
, re
.MULTILINE
)
56 return re
.sub('^Version: ', '', info
[s
.start():s
.end()])
60 file = os
.path
.basename(map)
61 name
= file.rsplit('.map', 1)[0]
63 # ignore ape-pre map, used to fill IRAM
68 ovlmap
= os
.path
.join(os
.path
.dirname(map), name
, file)
69 if os
.path
.lexists(ovlmap
):
72 f
= open(map).read() # read map content
74 s
= re
.search('^PLUGIN_RAM *0x(\d|[abcdef])*', f
, re
.MULTILINE
)
75 if not s
: return (name
, 0)
76 plugin_start
= re
.sub('^PLUGIN_RAM *0x0*', '', f
[s
.start():s
.end()])
78 s
= re
.search('^\.pluginend *0x(\d|[abcdef])*', f
, re
.MULTILINE
)
79 if not s
: return (name
, 0)
80 plugin_end
= re
.sub('^\.pluginend *0x0*', '', f
[s
.start():s
.end()])
82 size
= int(plugin_end
, 16) - int(plugin_start
, 16)
86 def get_new(oldinfo
, newinfo
, name
):
88 while i
< len(oldinfo
) and i
< len(newinfo
):
89 if newinfo
[i
][0] == name
:
95 def compare(olddir
, newdir
, oldver
, newer
):
97 for map in find_map(olddir
):
103 for map in find_map(newdir
):
113 for (name
, old_size
) in oldinfo
:
114 new
= get_new(oldinfo
, newinfo
, name
)
117 (name
, new_size
) = new
118 if len(name
) > longest_name
:
119 longest_name
= len(name
)
120 diff
+= [(name
, new_size
- old_size
, old_size
)]
122 spacelen
= (longest_name
+ 3)
124 print(' ' * spacelen
+ oldver
+ '\t\t' + newver
+ '\n')
126 for (name
, diff
, old_size
) in diff
:
127 space
= ' ' * (longest_name
- len(name
) + 3)
128 new_size
= old_size
+ diff
129 pdiff
= percent_diff(old_size
, new_size
)
134 print(name
+ space
+ str(old_size
) + '\t' + diff
+ \
135 '\t=\t' + str(new_size
) + '\t-->\t' + pdiff
)
143 if len(sys
.argv
) != 3:
144 print('Usage: ' + sys
.argv
[0] + ' build-old build-new')
147 oldver
= rb_version(sys
.argv
[1])
148 newver
= rb_version(sys
.argv
[2])
150 oldplugindir
= sys
.argv
[1] + '/apps/plugins'
151 newplugindir
= sys
.argv
[2] + '/apps/plugins'
152 oldcodecsdir
= sys
.argv
[1] + '/lib/rbcodec/codecs'
153 newcodecsdir
= sys
.argv
[2] + '/lib/rbcodec/codecs'
155 if os
.path
.lexists(oldplugindir
) and os
.path
.lexists(newplugindir
):
156 compare(oldplugindir
, newplugindir
, oldver
, newver
)
160 if os
.path
.lexists(oldcodecsdir
) and os
.path
.lexists(newcodecsdir
):
161 compare(oldcodecsdir
, newcodecsdir
, oldver
, newver
)