Files
odfstudio/external/zstd/StaticLibrary_zstd.mk
Akshay Kumar Dubey b410749d30 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>
2025-05-01 12:18:19 +02:00

42 lines
1.4 KiB
Makefile

# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_StaticLibrary_StaticLibrary,zstd))
$(eval $(call gb_StaticLibrary_use_unpacked,zstd,zstd))
$(eval $(call gb_StaticLibrary_set_warnings_disabled,zstd))
$(eval $(call gb_StaticLibrary_set_include,zstd,\
-I$(gb_UnpackedTarball_workdir)/zstd/lib \
-I$(gb_UnpackedTarball_workdir)/zstd/lib/common \
-I$(gb_UnpackedTarball_workdir)/zstd/lib/decompress \
$$(INCLUDE) \
))
$(eval $(call gb_StaticLibrary_add_generated_cobjects,zstd,\
UnpackedTarball/zstd/lib/common/entropy_common \
UnpackedTarball/zstd/lib/common/error_private \
UnpackedTarball/zstd/lib/common/fse_decompress \
UnpackedTarball/zstd/lib/common/xxhash \
UnpackedTarball/zstd/lib/common/zstd_common \
UnpackedTarball/zstd/lib/decompress/huf_decompress \
UnpackedTarball/zstd/lib/decompress/zstd_ddict \
UnpackedTarball/zstd/lib/decompress/zstd_decompress \
UnpackedTarball/zstd/lib/decompress/zstd_decompress_block \
))
$(eval $(call gb_StaticLibrary_add_cflags,zstd,-DZSTD_DISABLE_ASM))
ifeq ($(ENABLE_DEBUG),TRUE)
$(eval $(call gb_StaticLibrary_add_cflags,zstd,-DZSTD_DEBUG=1))
endif
# vim: set noet sw=4 ts=4: