Skip to content

Commit

Permalink
Use V8's zlib
Browse files Browse the repository at this point in the history
  • Loading branch information
npaun committed Aug 27, 2024
1 parent 58c83c1 commit 1e29f25
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 25 deletions.
44 changes: 19 additions & 25 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -282,34 +282,28 @@ http_archive(
# the build process. To update the dependency, update the reference commit in
# rust-deps/BUILD.bazel and run `bazel run //rust-deps:crates_vendor -- --repin`

# Based on https://github.com/bazelbuild/bazel/blob/master/third_party/zlib/BUILD.
_zlib_build = """
cc_library(
name = "zlib",
srcs = glob(["*.c"]),
hdrs = glob(["*.h"]),
includes = ["."],
# Workaround for zlib warnings and mac compilation. Some issues were resolved in v1.3, but there are still implicit function declarations.
copts = [
"-w",
"-Dverbose=-1",
] + select({
"@platforms//os:linux": [ "-Wno-implicit-function-declaration" ],
"@platforms//os:macos": [ "-Wno-implicit-function-declaration" ],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
)
"""
# rules_foreign_cc
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Rule repository, note that it's recommended to use a pinned commit to a released version of the rules
http_archive(
name = "rules_foreign_cc",
sha256 = "2a4d07cd64b0719b39a7c12218a3e507672b82a97b98c6a89d38565894cf7c51",
strip_prefix = "rules_foreign_cc-0.9.0",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/refs/tags/0.9.0.tar.gz",
)

load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")

# This sets up some common toolchains for building targets. For more details, please see
# https://github.com/bazelbuild/rules_foreign_cc/tree/main/docs#rules_foreign_cc_dependencies
rules_foreign_cc_dependencies()

git_repository(
name = "zlib",
build_file_content = _zlib_build,
sha256 = "38ef96b8dfe510d42707d9c781877914792541133e1870841463bfa73f883e32",
strip_prefix = "zlib-1.3.1",
# Using the .tar.xz artifact from the release page – for many other dependencies we use a
# snapshot based on the tag of a release instead.
urls = ["https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.xz"],
build_file = "//:build/BUILD.zlib",
commit = "71660e196bcfc74b2c657a46b512037cb49079a2",
remote = "https://chromium.googlesource.com/chromium/src/third_party/zlib.git",
)

http_file(
Expand Down
17 changes: 17 additions & 0 deletions build/BUILD.zlib
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

cmake(
name = "zlib",
lib_source = "@zlib//:all_srcs",
visibility = ["//visibility:public"],
# seriously...
lib_name = select({
"@platforms//os:windows": "zlib",
"//conditions:default": "libz",
}),
)

0 comments on commit 1e29f25

Please sign in to comment.