• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package(default_visibility = ["//visibility:public"])
2
3licenses(["notice"])  # BSD/MIT-like license (for zlib)
4
5_ZLIB_HEADERS = [
6    "crc32.h",
7    "deflate.h",
8    "gzguts.h",
9    "inffast.h",
10    "inffixed.h",
11    "inflate.h",
12    "inftrees.h",
13    "trees.h",
14    "zconf.h",
15    "zlib.h",
16    "zutil.h",
17]
18
19_ZLIB_PREFIXED_HEADERS = ["zlib/include/" + hdr for hdr in _ZLIB_HEADERS]
20
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.
24genrule(
25    name = "copy_public_headers",
26    srcs = _ZLIB_HEADERS,
27    outs = _ZLIB_PREFIXED_HEADERS,
28    cmd = "cp $(SRCS) $(@D)/zlib/include/",
29    visibility = ["//visibility:private"],
30)
31
32cc_library(
33    name = "zlib",
34    srcs = [
35        "adler32.c",
36        "compress.c",
37        "crc32.c",
38        "deflate.c",
39        "gzclose.c",
40        "gzlib.c",
41        "gzread.c",
42        "gzwrite.c",
43        "infback.c",
44        "inffast.c",
45        "inflate.c",
46        "inftrees.c",
47        "trees.c",
48        "uncompr.c",
49        "zutil.c",
50        # Include the un-prefixed headers in srcs to work
51        # around the fact that zlib isn't consistent in its
52        # choice of <> or "" delimiter when including itself.
53    ] + _ZLIB_HEADERS,
54    hdrs = _ZLIB_PREFIXED_HEADERS,
55    copts = [
56        "-Wno-unused-variable",
57        "-Wno-implicit-function-declaration",
58    ],
59    includes = ["zlib/include/"],
60)
61