get_current_build_size.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python3
  2. import configparser
  3. import os
  4. import subprocess
  5. dir = os.path.dirname(__file__)
  6. config = configparser.ConfigParser()
  7. config_file_path = f"{dir}/../config/ydb_qa_db.ini"
  8. config.read(config_file_path)
  9. YDBD_PATH = config["YDBD"]["YDBD_PATH"]
  10. def get_build_size():
  11. if not os.path.exists(YDBD_PATH):
  12. # can be possible due to incremental builds and ydbd itself is not affected by changes
  13. print("Error: {} not exists, skipping".format(YDBD_PATH))
  14. return 0
  15. binary_size_bytes = subprocess.check_output(
  16. ["bash", "-c", "cat {} | wc -c".format(YDBD_PATH)]
  17. )
  18. binary_size_stripped_bytes = subprocess.check_output(
  19. ["bash", "-c", "./ya tool strip {} -o - | wc -c".format(YDBD_PATH)]
  20. )
  21. size_stripped_bytes = int(binary_size_stripped_bytes.decode("utf-8"))
  22. size_bytes = int(binary_size_bytes.decode("utf-8"))
  23. if binary_size_bytes and binary_size_stripped_bytes:
  24. return {"size_bytes": size_bytes, "size_stripped_bytes": size_stripped_bytes}
  25. else:
  26. print(f"Error: Cant get build size")
  27. return 1
  28. if __name__ == "__main__":
  29. get_build_size()