mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
res_collect: noop if no changes detected
This commit is contained in:
parent
a18b883249
commit
63e6e85a7c
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import io
|
||||
|
||||
resources = {}
|
||||
resources_size = 0
|
||||
@ -39,11 +40,21 @@ for name in os.listdir('apps/'):
|
||||
process_dir_rec(path)
|
||||
|
||||
resfile = 'trezor/res/resources.py'
|
||||
with open(resfile, 'wt') as f:
|
||||
f.write('resdata = {\n')
|
||||
for k in sorted(resources.keys()):
|
||||
f.write(" '%s': %s,\n" % (k, resources[k]))
|
||||
f.write('}\n')
|
||||
|
||||
bio = io.StringIO()
|
||||
bio.write('resdata = {\n')
|
||||
for k in sorted(resources.keys()):
|
||||
bio.write(" '%s': %s,\n" % (k, resources[k]))
|
||||
bio.write('}\n')
|
||||
|
||||
with open(resfile, 'r') as f:
|
||||
stale = f.read()
|
||||
fresh = bio.getvalue()
|
||||
|
||||
if stale != fresh:
|
||||
with open(resfile, 'wt') as f:
|
||||
f.write(fresh)
|
||||
print('written %s with %d entries (total %d bytes)' %
|
||||
(resfile, len(resources), resources_size))
|
||||
else:
|
||||
print('continuing with %s, no changes detected' % (resfile))
|
||||
|
Loading…
Reference in New Issue
Block a user