zlib.BUILD 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package(default_visibility = ["//visibility:public"])
  2. licenses(["notice"]) # BSD/MIT-like license (for zlib)
  3. _ZLIB_HEADERS = [
  4. "crc32.h",
  5. "deflate.h",
  6. "gzguts.h",
  7. "inffast.h",
  8. "inffixed.h",
  9. "inflate.h",
  10. "inftrees.h",
  11. "trees.h",
  12. "zconf.h",
  13. "zlib.h",
  14. "zutil.h",
  15. ]
  16. _ZLIB_PREFIXED_HEADERS = ["zlib/include/" + hdr for hdr in _ZLIB_HEADERS]
  17. # In order to limit the damage from the `includes` propagation
  18. # via `:zlib`, copy the public headers to a subdirectory and
  19. # expose those.
  20. genrule(
  21. name = "copy_public_headers",
  22. srcs = _ZLIB_HEADERS,
  23. outs = _ZLIB_PREFIXED_HEADERS,
  24. cmd = "cp $(SRCS) $(@D)/zlib/include/",
  25. visibility = ["//visibility:private"],
  26. )
  27. cc_library(
  28. name = "zlib",
  29. srcs = [
  30. "adler32.c",
  31. "compress.c",
  32. "crc32.c",
  33. "deflate.c",
  34. "gzclose.c",
  35. "gzlib.c",
  36. "gzread.c",
  37. "gzwrite.c",
  38. "infback.c",
  39. "inffast.c",
  40. "inflate.c",
  41. "inftrees.c",
  42. "trees.c",
  43. "uncompr.c",
  44. "zutil.c",
  45. # Include the un-prefixed headers in srcs to work
  46. # around the fact that zlib isn't consistent in its
  47. # choice of <> or "" delimiter when including itself.
  48. ] + _ZLIB_HEADERS,
  49. hdrs = _ZLIB_PREFIXED_HEADERS,
  50. copts = select({
  51. "@bazel_tools//src/conditions:windows": [],
  52. "//conditions:default": [
  53. "-Wno-unused-variable",
  54. "-Wno-implicit-function-declaration",
  55. ],
  56. }),
  57. includes = ["zlib/include/"],
  58. )