SCsub 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/usr/bin/env python
  2. from misc.utility.scons_hints import *
  3. Import("env")
  4. env_png = env.Clone()
  5. # Thirdparty source files
  6. thirdparty_obj = []
  7. if env["builtin_libpng"]:
  8. thirdparty_dir = "#thirdparty/libpng/"
  9. thirdparty_sources = [
  10. "png.c",
  11. "pngerror.c",
  12. "pngget.c",
  13. "pngmem.c",
  14. "pngpread.c",
  15. "pngread.c",
  16. "pngrio.c",
  17. "pngrtran.c",
  18. "pngrutil.c",
  19. "pngset.c",
  20. "pngtrans.c",
  21. "pngwio.c",
  22. "pngwrite.c",
  23. "pngwtran.c",
  24. "pngwutil.c",
  25. ]
  26. thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
  27. env_png.Prepend(CPPPATH=[thirdparty_dir])
  28. # Needed for drivers includes and in platform/web.
  29. env.Prepend(CPPPATH=[thirdparty_dir])
  30. env_thirdparty = env_png.Clone()
  31. env_thirdparty.disable_warnings()
  32. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
  33. if env["arch"].startswith("arm"):
  34. if env.msvc: # Can't compile assembly files with MSVC.
  35. env_thirdparty.Append(CPPDEFINES=[("PNG_ARM_NEON_OPT", 0)])
  36. else:
  37. env_neon = env_thirdparty.Clone()
  38. if "S_compiler" in env:
  39. env_neon["CC"] = env["S_compiler"]
  40. neon_sources = []
  41. neon_sources.append(env_neon.Object(thirdparty_dir + "arm/arm_init.c"))
  42. neon_sources.append(env_neon.Object(thirdparty_dir + "arm/filter_neon_intrinsics.c"))
  43. neon_sources.append(env_neon.Object(thirdparty_dir + "arm/filter_neon.S"))
  44. neon_sources.append(env_neon.Object(thirdparty_dir + "arm/palette_neon_intrinsics.c"))
  45. thirdparty_obj += neon_sources
  46. elif env["arch"].startswith("x86"):
  47. env_thirdparty.Append(CPPDEFINES=["PNG_INTEL_SSE"])
  48. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "intel/intel_init.c")
  49. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "intel/filter_sse2_intrinsics.c")
  50. elif env["arch"] == "ppc64":
  51. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "powerpc/powerpc_init.c")
  52. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "powerpc/filter_vsx_intrinsics.c")
  53. env.drivers_sources += thirdparty_obj
  54. # Godot source files
  55. driver_obj = []
  56. env_png.add_source_files(driver_obj, "*.cpp")
  57. env.drivers_sources += driver_obj
  58. # Needed to force rebuilding the driver files when the thirdparty library is updated.
  59. env.Depends(driver_obj, thirdparty_obj)