Skip to content

Commit bd0e954

Browse files
yujincheng08topjohnwu
authored andcommitted
Replace zlib with zlib-rs
1 parent 675471a commit bd0e954

File tree

9 files changed

+21
-34
lines changed

9 files changed

+21
-34
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
[submodule "libcxx"]
1414
path = native/src/external/libcxx
1515
url = https://github.com/topjohnwu/libcxx.git
16-
[submodule "zlib"]
17-
path = native/src/external/zlib
18-
url = https://android.googlesource.com/platform/external/zlib
1916
[submodule "zopfli"]
2017
path = native/src/external/zopfli
2118
url = https://github.com/google/zopfli.git

native/src/Android.mk

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ LOCAL_STATIC_LIBRARIES := \
8989
liblzma \
9090
liblz4 \
9191
libbz2 \
92-
libz \
9392
libzopfli \
9493
libboot-rs
9594

native/src/Cargo.lock

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

native/src/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ syn = "2"
3434
quote = "1"
3535
proc-macro2 = "1"
3636
argh = { version = "0.1.13", default-features = false }
37+
libz-rs-sys = { version = "0.4.2", default-features = false, features=["c-allocator"] }
3738

3839
# Pin version to prevent cargo update break builds
3940
block-buffer = "=0.11.0-rc.3"

native/src/boot/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ der = { workspace = true, features = ["derive", "pem"] }
3232
fdt = { workspace = true }
3333
bytemuck = { workspace = true, features = ["derive", "min_const_generics"] }
3434
num-traits = { workspace = true }
35+
libz-rs-sys = { workspace = true }

native/src/boot/compress.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class zopfli_encoder : public chunk_out_stream {
153153
public:
154154
explicit zopfli_encoder(out_strm_ptr &&base) :
155155
chunk_out_stream(std::move(base), ZOPFLI_MASTER_BLOCK_SIZE),
156-
zo{}, out(nullptr), outsize(0), crc(crc32_z(0L, Z_NULL, 0)), in_total(0), bp(0) {
156+
zo{}, out(nullptr), outsize(0), crc(crc32(0L, Z_NULL, 0)), in_total(0), bp(0) {
157157
ZopfliInitOptions(&zo);
158158

159159
// This config is already better than gzip -9
@@ -198,7 +198,7 @@ class zopfli_encoder : public chunk_out_stream {
198198
auto in = static_cast<const unsigned char *>(buf);
199199

200200
in_total += len;
201-
crc = crc32_z(crc, in, len);
201+
crc = crc32(crc, in, len);
202202

203203
ZopfliDeflatePart(&zo, 2, final, in, 0, len, &bp, &out, &outsize);
204204

native/src/boot/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![feature(iter_intersperse)]
44
#![feature(try_blocks)]
55

6+
pub use libz_rs_sys::*;
67
pub use base;
78
use cpio::cpio_commands;
89
use dtb::dtb_commands;

native/src/external/Android.mk

-27
Original file line numberDiff line numberDiff line change
@@ -233,33 +233,6 @@ LOCAL_SRC_FILES := \
233233
lsplt/lsplt/src/main/jni/lsplt.cc
234234
include $(BUILD_STATIC_LIBRARY)
235235

236-
# libz.a
237-
include $(CLEAR_VARS)
238-
LOCAL_MODULE:= libz
239-
LOCAL_C_INCLUDES := $(LOCAL_PATH)/zlib
240-
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
241-
LOCAL_CFLAGS := \
242-
-DHAVE_HIDDEN -DZLIB_CONST -Wall -Werror \
243-
-Wno-unused -Wno-unused-parameter -Wno-deprecated-non-prototype
244-
LOCAL_SRC_FILES := \
245-
zlib/adler32.c \
246-
zlib/compress.c \
247-
zlib/cpu_features.c \
248-
zlib/crc32.c \
249-
zlib/deflate.c \
250-
zlib/gzclose.c \
251-
zlib/gzlib.c \
252-
zlib/gzread.c \
253-
zlib/gzwrite.c \
254-
zlib/infback.c \
255-
zlib/inffast.c \
256-
zlib/inflate.c \
257-
zlib/inftrees.c \
258-
zlib/trees.c \
259-
zlib/uncompr.c \
260-
zlib/zutil.c
261-
include $(BUILD_STATIC_LIBRARY)
262-
263236
# libzopfli.a
264237
include $(CLEAR_VARS)
265238
LOCAL_MODULE:= libzopfli

native/src/external/zlib

-1
This file was deleted.

0 commit comments

Comments
 (0)