From f8c8ca78bad8e0c66b1429666442c958be1a33bf Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 28 Feb 2025 12:12:58 +0100 Subject: [PATCH] Switch from zlib-ng to zlib-rs zlib-rs provides the same performance as zlib-ng with minedmap, while reducing the amount of C code and avoiding the external build dependency on CMake. --- CHANGELOG.md | 4 ++++ Cargo.lock | 27 ++++++++++++--------------- Cargo.toml | 4 ++-- Dockerfile | 2 +- README.md | 5 ----- crates/nbt/Cargo.toml | 6 ++---- 6 files changed, 21 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8fd052..1b84b15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,10 @@ - Unknown biome types (from not yet supported or modded versions of Minecraft) will now use plains biome colors as a fallback instead of resulting in water, grass and foliage blocks to be rendered as transparent pixels +- Switched from zlib-ng to zlib-rs + + This should have no noticable effect on the usage of MinedMap, but avoids + an external build dependency on CMake. ## [2.4.0] - 2025-01-11 diff --git a/Cargo.lock b/Cargo.lock index c8cbbe6..7bd83ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -212,15 +212,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" -[[package]] -name = "cmake" -version = "0.1.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" -dependencies = [ - "cc", -] - [[package]] name = "colorchoice" version = "1.0.3" @@ -364,7 +355,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc" dependencies = [ "crc32fast", - "libz-ng-sys", + "libz-rs-sys", "miniz_oxide", ] @@ -609,13 +600,12 @@ dependencies = [ ] [[package]] -name = "libz-ng-sys" -version = "1.1.21" +name = "libz-rs-sys" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cee1488e961a80d172564fd6fcda11d8a4ac6672c06fe008e9213fa60520c2b" +checksum = "902bc563b5d65ad9bba616b490842ef0651066a1a1dc3ce1087113ffcb873c8d" dependencies = [ - "cmake", - "libc", + "zlib-rs", ] [[package]] @@ -664,6 +654,7 @@ dependencies = [ "clap", "enum-map", "fastnbt", + "flate2", "futures-util", "git-version", "humantime", @@ -1426,6 +1417,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "zlib-rs" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b20717f0917c908dc63de2e44e97f1e6b126ca58d0e391cee86d504eb8fbd05" + [[package]] name = "zstd" version = "0.13.3" diff --git a/Cargo.toml b/Cargo.toml index d213a56..812ad33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,7 @@ bincode = "1.3.3" clap = { version = "4.1.4", features = ["derive", "wrap_help"] } enum-map = "2.7.3" fastnbt = "2.3.2" +flate2 = { version = "1.1.0", features = ["zlib-rs"] } futures-util = "0.3.28" git-version = "0.3.5" humantime = "2.1.0" @@ -67,7 +68,6 @@ tracing-subscriber = "0.3.17" zstd = "0.13.0" [features] -default = ["jemalloc-auto", "zlib-ng"] +default = ["jemalloc-auto"] jemalloc-auto = ["dep:minedmap-default-alloc"] jemalloc = ["jemalloc-auto", "minedmap-default-alloc/jemalloc"] -zlib-ng = ["minedmap-nbt/zlib-ng"] diff --git a/Dockerfile b/Dockerfile index 389fb08..818971d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM docker.io/library/alpine:latest AS builder WORKDIR /build -RUN apk add --no-cache build-base cmake cargo +RUN apk add --no-cache build-base cargo ARG MINEDMAP_VERSION diff --git a/README.md b/README.md index 7d60f78..952163f 100644 --- a/README.md +++ b/README.md @@ -117,11 +117,6 @@ or newer). The following command can be used to build the current development ve cargo install --git 'https://github.com/neocturne/MinedMap.git' ``` -In addition, CMake is needed to build the zlib-ng library. If you do not have -CMake installed, you can disable the zlib-ng feature by passing `--no-default-features` -to cargo. A pure-Rust zlib implementation will be used, which is more portable, -but slower than zlib-ng. - If you are looking for the older C++ implementation of the MinedMap tile renderer, see the [v1.19.1](https://github.com/neocturne/MinedMap/tree/v1.19.1) tag. diff --git a/crates/nbt/Cargo.toml b/crates/nbt/Cargo.toml index 9f815da..01bbd78 100644 --- a/crates/nbt/Cargo.toml +++ b/crates/nbt/Cargo.toml @@ -11,12 +11,10 @@ repository.workspace = true anyhow = "1.0.75" bytemuck = "1.13.1" fastnbt = "2.4.4" -flate2 = "1.0.27" +flate2 = "1.1.0" minedmap-types = { version = "0.1.4", path = "../types" } serde = "1.0.183" -[features] -zlib-ng = ["flate2/zlib-ng"] - [dev-dependencies] clap = { version = "4.3.23", features = ["derive"] } +flate2 = { version = "1.1.0", features = ["zlib-rs"] }