zlib.BUILD 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. load("@rules_cc//cc:defs.bzl", "cc_library")
  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. )
  26. cc_library(
  27. name = "zlib",
  28. srcs = [
  29. "adler32.c",
  30. "compress.c",
  31. "crc32.c",
  32. "deflate.c",
  33. "gzclose.c",
  34. "gzlib.c",
  35. "gzread.c",
  36. "gzwrite.c",
  37. "infback.c",
  38. "inffast.c",
  39. "inflate.c",
  40. "inftrees.c",
  41. "trees.c",
  42. "uncompr.c",
  43. "zutil.c",
  44. # Include the un-prefixed headers in srcs to work
  45. # around the fact that zlib isn't consistent in its
  46. # choice of <> or "" delimiter when including itself.
  47. ] + _ZLIB_HEADERS,
  48. hdrs = _ZLIB_PREFIXED_HEADERS,
  49. copts = select({
  50. "@bazel_tools//src/conditions:windows": [],
  51. "//conditions:default": [
  52. "-Wno-unused-variable",
  53. "-Wno-implicit-function-declaration",
  54. ],
  55. }),
  56. includes = ["zlib/include/"],
  57. visibility = ["//visibility:public"],
  58. )