methods.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. def disable_warnings(self):
  2. # 'self' is the environment
  3. if self["platform"] == "windows" and not self["use_mingw"]:
  4. # We have to remove existing warning level defines before appending /w,
  5. # otherwise we get: "warning D9025 : overriding '/W3' with '/w'"
  6. WARN_FLAGS = ["/Wall", "/W4", "/W3", "/W2", "/W1", "/W0"]
  7. self["CCFLAGS"] = [x for x in self["CCFLAGS"] if x not in WARN_FLAGS]
  8. self["CFLAGS"] = [x for x in self["CFLAGS"] if x not in WARN_FLAGS]
  9. self["CXXFLAGS"] = [x for x in self["CXXFLAGS"] if x not in WARN_FLAGS]
  10. self.AppendUnique(CCFLAGS=["/w"])
  11. else:
  12. self.AppendUnique(CCFLAGS=["-w"])
  13. def prepare_timer():
  14. import atexit
  15. import time
  16. def print_elapsed_time(time_at_start: float):
  17. time_elapsed = time.time() - time_at_start
  18. time_formatted = time.strftime("%H:%M:%S", time.gmtime(time_elapsed))
  19. time_centiseconds = round((time_elapsed % 1) * 100)
  20. print(f"[Time elapsed: {time_formatted}.{time_centiseconds}]")
  21. atexit.register(print_elapsed_time, time.time())
  22. def write_macos_plist(target, binary_name, identifier, name):
  23. import os
  24. os.makedirs(f"{target}/Resource/", exist_ok=True)
  25. with open(f"{target}/Resource/Info.plist", "w", encoding="utf-8", newline="\n") as f:
  26. f.write(f"""\
  27. <?xml version="1.0" encoding="UTF-8"?>
  28. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  29. <plist version="1.0">
  30. <dict>
  31. <key>CFBundleExecutable</key>
  32. <string>{binary_name}</string>
  33. <key>CFBundleIdentifier</key>
  34. <string>{identifier}</string>
  35. <key>CFBundleInfoDictionaryVersion</key>
  36. <string>6.0</string>
  37. <key>CFBundleName</key>
  38. <string>{name}</string>
  39. <key>CFBundlePackageType</key>
  40. <string>FMWK</string>
  41. <key>CFBundleShortVersionString</key>
  42. <string>1.0.0</string>
  43. <key>CFBundleSupportedPlatforms</key>
  44. <array>
  45. <string>MacOSX</string>
  46. </array>
  47. <key>CFBundleVersion</key>
  48. <string>1.0.0</string>
  49. <key>LSMinimumSystemVersion</key>
  50. <string>10.14</string>
  51. </dict>
  52. </plist>
  53. """)