platform_windows_builders.py 1.2 KB

12345678910111213141516171819202122232425
  1. """Functions used to generate source files during build time"""
  2. import os
  3. from detect import get_mingw_bin_prefix, try_cmd
  4. def make_debug_mingw(target, source, env):
  5. dst = str(target[0])
  6. # Force separate debug symbols if executable size is larger than 1.9 GB.
  7. if env["separate_debug_symbols"] or os.stat(dst).st_size >= 2040109465:
  8. mingw_bin_prefix = get_mingw_bin_prefix(env["mingw_prefix"], env["arch"])
  9. if try_cmd("objcopy --version", env["mingw_prefix"], env["arch"]):
  10. os.system(mingw_bin_prefix + "objcopy --only-keep-debug {0} {0}.debugsymbols".format(dst))
  11. else:
  12. os.system("objcopy --only-keep-debug {0} {0}.debugsymbols".format(dst))
  13. if try_cmd("strip --version", env["mingw_prefix"], env["arch"]):
  14. os.system(mingw_bin_prefix + "strip --strip-debug --strip-unneeded {0}".format(dst))
  15. else:
  16. os.system("strip --strip-debug --strip-unneeded {0}".format(dst))
  17. if try_cmd("objcopy --version", env["mingw_prefix"], env["arch"]):
  18. os.system(mingw_bin_prefix + "objcopy --add-gnu-debuglink={0}.debugsymbols {0}".format(dst))
  19. else:
  20. os.system("objcopy --add-gnu-debuglink={0}.debugsymbols {0}".format(dst))