Skip to content

Commit

Permalink
start, make sure to build zlib from libz-sys crate source
Browse files Browse the repository at this point in the history
  • Loading branch information
ParkMyCar committed Jan 10, 2025
1 parent b1db073 commit a79c439
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
4 changes: 3 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
71 changes: 71 additions & 0 deletions misc/bazel/c_deps/rust-sys/BUILD.libz.bazel
Original file line number Diff line number Diff line change
@@ -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: <https://github.com/rust-lang/libz-sys/blob/8462d47d51e36c8cd7fa83db3cbcc2b725385650/build.rs>
"""

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"],
)

0 comments on commit a79c439

Please sign in to comment.