Skip to content

Commit 5aaef11

Browse files
cblichmanncopybara-github
authored andcommitted
Use standard zlib in examples
This change updates the Sandboxed API examples to use the standard zlib library. For Bazel, this means depending on the `zlib` module from the Bazel Central Repository (v1.3.1). For CMake, it uses `FetchContent_MakeAvailable` with zlib v1.3.1. The custom `zlib.BUILD` file and the `zlib.patch` are no longer necessary and have been removed. The patch was originally a workaround for a libclang issue with the `OF()` macro in older zlib versions, which is not present in zlib 1.3.1. PiperOrigin-RevId: 805767594 Change-Id: Id068af6b10d54079fa00f5045da53e99fc47ed9e
1 parent 686b4a5 commit 5aaef11

8 files changed

Lines changed: 28 additions & 1440 deletions

File tree

MODULE.bazel

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ bazel_dep(name = "rules_python", version = "1.0.0")
3333
bazel_dep(name = "rules_cc", version = "0.1.2")
3434
bazel_dep(name = "libunwind", version = "1.8.1")
3535
bazel_dep(name = "libffi", version = "3.4.7")
36+
bazel_dep(name = "zlib", version = "1.3.1.bcr.7") # Only needed for examples
3637

3738
# Non-Modularized Dependencies:
3839

@@ -50,23 +51,3 @@ http_archive(
5051
strip_prefix = "libcap-2.27",
5152
urls = ["https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.27.tar.gz"],
5253
)
53-
54-
# zlib, only needed for examples
55-
http_archive(
56-
name = "net_zlib",
57-
build_file = "//sandboxed_api:bazel/external/zlib.BUILD",
58-
patch_args = ["-p1"],
59-
# This is a patch that removes the "OF" macro that is used in zlib function
60-
# definitions. It is necessary, because libclang, the library used by the
61-
# interface generator to parse C/C++ files contains a bug that manifests
62-
# itself with macros like this.
63-
# We are investigating better ways to avoid this issue. For most "normal"
64-
# C and C++ headers, parsing just works.
65-
patches = ["//sandboxed_api:bazel/external/zlib.patch"],
66-
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", # 2020-04-23
67-
strip_prefix = "zlib-1.2.11",
68-
urls = [
69-
"https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz",
70-
"https://www.zlib.net/zlib-1.2.11.tar.gz",
71-
],
72-
)

MODULE.bazel.lock

Lines changed: 19 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmake/zlib.cmake

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,11 @@
1313
# limitations under the License.
1414

1515
FetchContent_Declare(zlib
16-
URL https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz
17-
URL_HASH SHA256=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1
18-
PATCH_COMMAND patch -p1
19-
< "${SAPI_SOURCE_DIR}/sandboxed_api/bazel/external/zlib.patch"
16+
URL https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz
17+
URL_HASH SHA256=9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23
2018
)
21-
FetchContent_GetProperties(zlib)
22-
if(NOT zlib_POPULATED)
23-
FetchContent_Populate(zlib)
24-
endif()
19+
FetchContent_MakeAvailable(zlib)
2520

2621
set(ZLIB_FOUND TRUE)
2722
set(ZLIB_INCLUDE_DIRS ${zlib_SOURCE_DIR})
28-
29-
add_library(z STATIC
30-
${zlib_SOURCE_DIR}/adler32.c
31-
${zlib_SOURCE_DIR}/compress.c
32-
${zlib_SOURCE_DIR}/crc32.c
33-
${zlib_SOURCE_DIR}/crc32.h
34-
${zlib_SOURCE_DIR}/deflate.c
35-
${zlib_SOURCE_DIR}/deflate.h
36-
${zlib_SOURCE_DIR}/gzclose.c
37-
${zlib_SOURCE_DIR}/gzguts.h
38-
${zlib_SOURCE_DIR}/gzlib.c
39-
${zlib_SOURCE_DIR}/gzread.c
40-
${zlib_SOURCE_DIR}/gzwrite.c
41-
${zlib_SOURCE_DIR}/infback.c
42-
${zlib_SOURCE_DIR}/inffast.c
43-
${zlib_SOURCE_DIR}/inffast.h
44-
${zlib_SOURCE_DIR}/inffixed.h
45-
${zlib_SOURCE_DIR}/inflate.c
46-
${zlib_SOURCE_DIR}/inflate.h
47-
${zlib_SOURCE_DIR}/inftrees.c
48-
${zlib_SOURCE_DIR}/inftrees.h
49-
${zlib_SOURCE_DIR}/trees.c
50-
${zlib_SOURCE_DIR}/trees.h
51-
${zlib_SOURCE_DIR}/uncompr.c
52-
${zlib_SOURCE_DIR}/zconf.h
53-
${zlib_SOURCE_DIR}/zlib.h
54-
${zlib_SOURCE_DIR}/zutil.c
55-
${zlib_SOURCE_DIR}/zutil.h
56-
)
57-
add_library(ZLIB::ZLIB ALIAS z)
58-
target_include_directories(z PUBLIC
59-
${zlib_SOURCE_DIR}
60-
)
61-
target_compile_options(z PRIVATE
62-
-w
63-
-Dverbose=-1
64-
)
65-
target_link_libraries(z PRIVATE
66-
sapi::base
67-
)
68-
23+
add_library(ZLIB::ZLIB ALIAS zlibstatic)

sandboxed_api/bazel/external/zlib.BUILD

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)