1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-27 18:32:34 +00:00

res_collect: fix for resources in subdirectories

This commit is contained in:
Jan Pochyla 2016-10-12 13:12:27 +02:00
parent 0a5e43723f
commit 2d7d241a8d

View File

@ -7,6 +7,7 @@ resources_size = 0
os.chdir(os.path.dirname(__file__)) os.chdir(os.path.dirname(__file__))
os.chdir('../src/') os.chdir('../src/')
def process_file(name): def process_file(name):
if name.endswith('.gitignore'): if name.endswith('.gitignore'):
return return
@ -21,20 +22,21 @@ def process_file(name):
global resources_size global resources_size
resources_size += len(data) resources_size += len(data)
# scan common resources
for res in os.listdir('trezor/res/'):
name = os.path.join('trezor/res/', res)
if os.path.isfile(name):
process_file(name)
# scan apps def process_dir_rec(dir):
for app in os.listdir('apps/'): for name in os.listdir(dir):
name = os.path.join('apps/', app) path = os.path.join(dir, name)
if os.path.isdir(name) and os.path.isdir('apps/%s/res/' % app): if os.path.isfile(path):
for res in os.listdir('apps/%s/res/' % app): process_file(path)
name = 'apps/%s/res/%s' % (app, res) elif os.path.isdir(path):
if os.path.isfile(name): process_dir_rec(path)
process_file(name)
process_dir_rec('trezor/res/')
for name in os.listdir('apps/'):
path = os.path.join('apps/', name, 'res/')
if os.path.isdir(path):
process_dir_rec(path)
resfile = 'trezor/res/resources.py' resfile = 'trezor/res/resources.py'
with open(resfile, 'wt') as f: with open(resfile, 'wt') as f:
@ -43,4 +45,5 @@ with open(resfile, 'wt') as f:
f.write(" '%s': %s,\n" % (k, resources[k])) f.write(" '%s': %s,\n" % (k, resources[k]))
f.write('}\n') f.write('}\n')
print('written %s with %d entries (total %d bytes)' % (resfile, len(resources), resources_size)) print('written %s with %d entries (total %d bytes)' %
(resfile, len(resources), resources_size))