7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-01-06 21:11:59 +00:00
kicad/thirdparty/pybind11/tools/libsize.py
Jeff Young 2533141583 Revert "Update pybind11 to version 2.10.4" for now.
This reverts commits 9d077c9ba5 and
b4938f5198.

They cause a crash-on-startup on Mac ARM machines, failing to get the
locale encoding (nl_langinfo(CODESET) failed).
2023-04-18 17:28:10 +01:00

40 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
from __future__ import division, print_function
import os
import sys
# Internal build script for generating debugging test .so size.
# Usage:
# python libsize.py file.so save.txt -- displays the size of file.so and, if save.txt exists, compares it to the
# size in it, then overwrites save.txt with the new size for future runs.
if len(sys.argv) != 3:
sys.exit("Invalid arguments: usage: python libsize.py file.so save.txt")
lib = sys.argv[1]
save = sys.argv[2]
if not os.path.exists(lib):
sys.exit("Error: requested file ({}) does not exist".format(lib))
libsize = os.path.getsize(lib)
print("------", os.path.basename(lib), "file size:", libsize, end="")
if os.path.exists(save):
with open(save) as sf:
oldsize = int(sf.readline())
if oldsize > 0:
change = libsize - oldsize
if change == 0:
print(" (no change)")
else:
print(" (change of {:+} bytes = {:+.2%})".format(change, change / oldsize))
else:
print()
with open(save, "w") as sf:
sf.write(str(libsize))