zlib.BUILD 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Copyright The OpenTelemetry Authors
  2. # SPDX-License-Identifier: Apache-2.0
  3. # Builds ZLIB from a distribution.
  4. # Copied from https://github.com/protocolbuffers/protobuf/blob/master/third_party/zlib.BUILD
  5. licenses(["notice"]) # BSD/MIT-like license (for zlib)
  6. exports_files(["zlib.BUILD"])
  7. _ZLIB_HEADERS = [
  8. "crc32.h",
  9. "deflate.h",
  10. "gzguts.h",
  11. "inffast.h",
  12. "inffixed.h",
  13. "inflate.h",
  14. "inftrees.h",
  15. "trees.h",
  16. "zconf.h",
  17. "zlib.h",
  18. "zutil.h",
  19. ]
  20. _ZLIB_PREFIXED_HEADERS = ["zlib/include/" + hdr for hdr in _ZLIB_HEADERS]
  21. # In order to limit the damage from the `includes` propagation
  22. # via `:zlib`, copy the public headers to a subdirectory and
  23. # expose those.
  24. genrule(
  25. name = "copy_public_headers",
  26. srcs = _ZLIB_HEADERS,
  27. outs = _ZLIB_PREFIXED_HEADERS,
  28. cmd_bash = "cp $(SRCS) $(@D)/zlib/include/",
  29. cmd_bat = " && ".join(
  30. ["@copy /Y $(location %s) $(@D)\\zlib\\include\\ >NUL" %
  31. s for s in _ZLIB_HEADERS],
  32. ),
  33. )
  34. cc_library(
  35. name = "zlib",
  36. srcs = [
  37. "adler32.c",
  38. "compress.c",
  39. "crc32.c",
  40. "deflate.c",
  41. "gzclose.c",
  42. "gzlib.c",
  43. "gzread.c",
  44. "gzwrite.c",
  45. "infback.c",
  46. "inffast.c",
  47. "inflate.c",
  48. "inftrees.c",
  49. "trees.c",
  50. "uncompr.c",
  51. "zutil.c",
  52. # Include the un-prefixed headers in srcs to work
  53. # around the fact that zlib isn't consistent in its
  54. # choice of <> or "" delimiter when including itself.
  55. ] + _ZLIB_HEADERS,
  56. hdrs = _ZLIB_PREFIXED_HEADERS,
  57. copts = select({
  58. "@platforms//os:windows": [],
  59. "//conditions:default": [
  60. "-Wno-deprecated-non-prototype",
  61. "-Wno-unused-variable",
  62. "-Wno-implicit-function-declaration",
  63. ],
  64. }),
  65. includes = ["zlib/include/"],
  66. visibility = ["//visibility:public"],
  67. )