diff --git a/WORKSPACE b/WORKSPACE index 6acf475d00ee2..603cd8b25c557 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -478,8 +478,10 @@ crates_repository( deps = [":librdkafka"], )], "libz-sys": [crate.annotation( + additive_build_file = "@//misc/bazel/c_deps:rust-sys/BUILD.libz.bazel", gen_build_script = False, - deps = ["@zlib"], + # Note: This is a target we add from the additive build file above. + deps = [":zlib"], )], "openssl-sys": [crate.annotation( build_script_data = [ diff --git a/misc/bazel/c_deps/rust-sys/BUILD.libz.bazel b/misc/bazel/c_deps/rust-sys/BUILD.libz.bazel new file mode 100644 index 0000000000000..c0bb0b7bbd6f0 --- /dev/null +++ b/misc/bazel/c_deps/rust-sys/BUILD.libz.bazel @@ -0,0 +1,71 @@ +# Copyright Materialize, Inc. and contributors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License in the LICENSE file at the +# root of this repository, or online at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Builds zlib. + +Derived from: +""" + +cc_library( + name = "zlib", + srcs = [ + "src/zlib/adler32.c", + "src/zlib/compress.c", + "src/zlib/crc32.c", + "src/zlib/deflate.c", + "src/zlib/infback.c", + "src/zlib/inffast.c", + "src/zlib/inflate.c", + "src/zlib/inftrees.c", + "src/zlib/trees.c", + "src/zlib/uncompr.c", + "src/zlib/zutil.c", + ], + hdrs = [ + "src/zlib/crc32.h", + "src/zlib/deflate.h", + "src/zlib/inffast.h", + "src/zlib/inffixed.h", + "src/zlib/inflate.h", + "src/zlib/inftrees.h", + "src/zlib/trees.h", + "src/zlib/zconf.h", + "src/zlib/zlib.h", + "src/zlib/zutil.h", + ], + copts = select({ + "//conditions:default": [ + "-Wno-unused-variable", + "-Wno-implicit-function-declaration", + "-Wno-deprecated-non-prototype", + "-Wno-macro-redefined", + "-fvisibility=hidden", + ], + }), + includes = ["src/zlib"], + local_defines = [ + "Z_SOLO", + "STDC", + "_LARGEFILE64_SOURCE", + "_POSIX_SOURCE", + ] + select({ + "@platforms//os:macos": [ + "_C99_SOURCE", + ], + "//conditions:default": [], + }), + visibility = ["//visibility:public"], +)