tdf#137308 - Add zstd build support and decompression classes

Integrate build system support for the Zstandard (zstd) library and
implement the corresponding C++ decompression stream classes, enabling
future use of zstd-compressed streams in ZIP packages.

Build System (Part 2a):
- Add `--with-system-zstd=[yes|no|auto]` configure option.
- Implement system library checks (`zstd.h`, `libzstd`) in configure.ac.
- Define rules (`external/zstd/*`) for downloading and building the
  internal zstd static library (decompression components only).
- Set up necessary CFLAGS/LIBS via configure.ac and config_host.mk.in.
- Configure linking via RepositoryExternal.mk (`gb_LinkTarget__use_zstd`).
- Update auxiliary files (download.lst, distro-configs, etc.).

C++ Implementation (Part 2b):
- Implement `InflateZstd` (in `include/package`) and `InflaterBytesZstd`
  (in `package/inc`) inheriting from `Inflater`/`InflaterBytes`.
- Use the zstd streaming API (`ZSTD_decompressStream`) following the
  existing single-call pattern established by the zlib implementation.
- Manage context (`ZSTD_DCtx`) and input buffer (`ZSTD_inBuffer`) state.
- Handle errors, stream completion (`ret == 0`), and input truncation.
- Add new classes to `package/Library_package2.mk` build.

This completes the infrastructure for zstd decompression support.
The next step (Part 2c) involves adding logic to select the
appropriate Inflater based on the ZIP entry's compression method ID.

Change-Id: Ia673f3f19b6a751ba5225394fcf8c3f145c4ae63
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184243
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
This commit is contained in:
Akshay Kumar Dubey
2025-05-01 12:18:19 +02:00
committed by Caolán McNamara
parent 55169df2f6
commit b410749d30
21 changed files with 440 additions and 0 deletions
+17
View File
@@ -409,6 +409,23 @@ endef
endif # SYSTEM_ZLIB
ifneq ($(SYSTEM_ZSTD),)
define gb_LinkTarget__use_zstd
$(call gb_LinkTarget_add_libs,$(1),-lzstd)
endef
gb_ExternalProject__use_zstd :=
else
define gb_LinkTarget__use_zstd
$(call gb_LinkTarget_set_include,$(1),$(ZSTD_CFLAGS) $$(INCLUDE))
$(call gb_LinkTarget_use_static_libraries,$(1),zstd)
endef
define gb_ExternalProject__use_zstd
$(call gb_ExternalProject_use_static_libraries,$(1),zstd)
endef
endif
ifneq ($(SYSTEM_LIBJPEG),)