-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated zlib BUILD file to support darwin-arm64 (#1931)
- Loading branch information
1 parent
a863132
commit fa304ae
Showing
1 changed file
with
57 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,67 @@ | ||
load("@bazel_skylib//rules:copy_file.bzl", "copy_file") | ||
load("@rules_cc//cc:defs.bzl", "cc_library") | ||
|
||
_ZLIB_HEADERS = [ | ||
"crc32.h", | ||
"deflate.h", | ||
"gzguts.h", | ||
"inffast.h", | ||
"inffixed.h", | ||
"inflate.h", | ||
"inftrees.h", | ||
"trees.h", | ||
"zconf.h", | ||
"zlib.h", | ||
"zutil.h", | ||
] | ||
|
||
# In order to limit the damage from the `includes` propagation | ||
# via `:zlib`, copy the public headers to a subdirectory and | ||
# expose those. | ||
_ZLIB_HEADER_PREFIX = "zlib/include" | ||
|
||
_ZLIB_PREFIXED_HEADERS = ["{}/{}".format(_ZLIB_HEADER_PREFIX, hdr) for hdr in _ZLIB_HEADERS] | ||
|
||
[ | ||
copy_file( | ||
name = "{}.copy".format(hdr), | ||
src = hdr, | ||
out = "{}/{}".format(_ZLIB_HEADER_PREFIX, hdr), | ||
) | ||
for hdr in _ZLIB_HEADERS | ||
] | ||
|
||
cc_library( | ||
name = "zlib", | ||
srcs = glob(["*.c"]), | ||
hdrs = glob(["*.h"]), | ||
# Use -Dverbose=-1 to turn off zlib's trace logging. | ||
# https://github.com/bazelbuild/bazel/issues/3280 | ||
srcs = [ | ||
"adler32.c", | ||
"compress.c", | ||
"crc32.c", | ||
"deflate.c", | ||
"gzclose.c", | ||
"gzlib.c", | ||
"gzread.c", | ||
"gzwrite.c", | ||
"infback.c", | ||
"inffast.c", | ||
"inflate.c", | ||
"inftrees.c", | ||
"trees.c", | ||
"uncompr.c", | ||
"zutil.c", | ||
# Include the un-prefixed headers in srcs to work | ||
# around the fact that zlib isn't consistent in its | ||
# choice of <> or "" delimiter when including itself. | ||
] + _ZLIB_HEADERS, | ||
hdrs = _ZLIB_PREFIXED_HEADERS, | ||
copts = select({ | ||
"@platforms//os:linux": [ | ||
"-w", | ||
"-Dverbose=-1", | ||
# Required for opt builds to avoid | ||
# `libzlib.a(crc32.o): requires unsupported dynamic reloc 11; recompile with -fPIC` | ||
"-fPIC", | ||
], | ||
"@platforms//os:windows": [], | ||
"//conditions:default": [ | ||
"-w", | ||
"-Dverbose=-1", | ||
"-Wno-deprecated-non-prototype", | ||
"-Wno-unused-variable", | ||
"-Wno-implicit-function-declaration", | ||
], | ||
}), | ||
includes = ["."], | ||
linkstatic = True, | ||
includes = ["zlib/include/"], | ||
visibility = ["//visibility:public"], | ||
) |