__init__.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 config.h but does not use any of its defines.
  8. os.remove(f"{self.dstdir}/config.h")
  9. libpng.CFLAGS.remove("-DHAVE_CONFIG_H")
  10. # Support ARM.
  11. arm_srcs = files(f"{self.dstdir}/arm", rel=self.dstdir)
  12. self.yamakes["."].after(
  13. "SRCS",
  14. Switch(
  15. {
  16. "NOT MSVC": Switch(
  17. {
  18. "ARCH_AARCH64 OR ARCH_ARM": Linkable(SRCS=arm_srcs),
  19. }
  20. )
  21. }
  22. ),
  23. )
  24. libpng.RECURSE.add("include")
  25. libpng = GNUMakeNixProject(
  26. owners=["g:cpp-contrib"],
  27. arcdir="contrib/libs/libpng",
  28. nixattr="libpng",
  29. makeflags=["libpng16.la"],
  30. copy_sources=[
  31. "arm/*",
  32. "pngprefix.h",
  33. ],
  34. disable_includes=[
  35. "config.h",
  36. "PNG_MIPS_MSA_FILE",
  37. "PNG_POWERPC_VSX_FILE",
  38. "PNG_ARM_NEON_FILE",
  39. ],
  40. # Original libpng layout provides unnecessary ADDINCL(include/libpng16)
  41. keep_paths=["include/ya.make"],
  42. ignore_commands=["gawk"],
  43. inclink={"include": ["png.h", "pngconf.h", "pnglibconf.h"]},
  44. post_install=post_install,
  45. )