__init__.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import os
  2. from devtools.yamaker.fileutil import files
  3. from devtools.yamaker.modules import Switch, Linkable
  4. from devtools.yamaker.project import GNUMakeNixProject
  5. def post_install(self):
  6. with self.yamakes["."] as libpng:
  7. # libpng generates export script, but we are going to link statically
  8. os.remove(f"{self.dstdir}/libpng.vers")
  9. # libpng generates config.h but does not use any of its defines.
  10. os.remove(f"{self.dstdir}/config.h")
  11. libpng.CFLAGS.remove("-DHAVE_CONFIG_H")
  12. # Support ARM.
  13. arm_srcs = files(f"{self.dstdir}/arm", rel=self.dstdir)
  14. self.yamakes["."].after(
  15. "SRCS",
  16. Switch(
  17. {
  18. "NOT MSVC": Switch(
  19. {
  20. "ARCH_AARCH64 OR ARCH_ARM": Linkable(SRCS=arm_srcs),
  21. }
  22. )
  23. }
  24. ),
  25. )
  26. libpng.RECURSE.add("include")
  27. libpng = GNUMakeNixProject(
  28. owners=["g:cpp-contrib"],
  29. arcdir="contrib/libs/libpng",
  30. nixattr="libpng",
  31. makeflags=["libpng16.la"],
  32. copy_sources=[
  33. "arm/*",
  34. "pngprefix.h",
  35. ],
  36. disable_includes=[
  37. "config.h",
  38. "pngusr.h",
  39. "mem.h",
  40. "PNG_MIPS_MMI_FILE",
  41. "PNG_MIPS_MSA_FILE",
  42. "PNG_POWERPC_VSX_FILE",
  43. "PNG_ARM_NEON_FILE",
  44. ],
  45. # Original libpng layout provides unnecessary ADDINCL(include/libpng16)
  46. keep_paths=["include/ya.make"],
  47. ignore_commands=["gawk"],
  48. inclink={"include": ["png.h", "pngconf.h", "pnglibconf.h"]},
  49. post_install=post_install,
  50. )