1 from __future__ import print_function, division
5 # Internal build script for generating debugging test .so size.
7 # python libsize.py file.so save.txt -- displays the size of file.so and, if save.txt exists, compares it to the
8 # size in it, then overwrites save.txt with the new size for future runs.
10 if len(sys.argv) != 3:
11 sys.exit("Invalid arguments: usage: python libsize.py file.so save.txt")
16 if not os.path.exists(lib):
17 sys.exit("Error: requested file ({}) does not exist".format(lib))
19 libsize = os.path.getsize(lib)
21 print("------", os.path.basename(lib), "file size:", libsize, end='')
23 if os.path.exists(save):
24 with open(save) as sf:
25 oldsize = int(sf.readline())
28 change = libsize - oldsize
32 print(" (change of {:+} bytes = {:+.2%})".format(change, change / oldsize))
36 with open(save, 'w') as sf:
37 sf.write(str(libsize))