mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-17 01:52:02 +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
|
#!/usr/bin/env python3
|
||||||
import os
|
import os
|
||||||
|
import io
|
||||||
|
|
||||||
resources = {}
|
resources = {}
|
||||||
resources_size = 0
|
resources_size = 0
|
||||||
@ -39,11 +40,21 @@ for name in os.listdir('apps/'):
|
|||||||
process_dir_rec(path)
|
process_dir_rec(path)
|
||||||
|
|
||||||
resfile = 'trezor/res/resources.py'
|
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')
|
|
||||||
|
|
||||||
print('written %s with %d entries (total %d bytes)' %
|
bio = io.StringIO()
|
||||||
(resfile, len(resources), resources_size))
|
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