init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
allhaileris
2026-02-16 15:50:16 +03:00
commit afb81b8278
13816 changed files with 3689732 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
Meson build system for lz4
==========================
Meson is a build system designed to optimize programmer productivity.
It aims to do this by providing simple, out-of-the-box support for
modern software development tools and practices, such as unit tests,
coverage reports, Valgrind, CCache and the like.
This Meson build system is provided with no guarantee.
## How to build
`cd` to this meson directory (`contrib/meson`)
```sh
meson setup --buildtype=release -Ddefault_library=shared -Dprograms=true builddir
cd builddir
ninja # to build
ninja install # to install
```
You might want to install it in staging directory:
```sh
DESTDIR=./staging ninja install
```
To configure build options, use:
```sh
meson configure
```
See [man meson(1)](https://manpages.debian.org/testing/meson/meson.1.en.html).

View File

@@ -0,0 +1,27 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
# This is a dummy meson file.
# The intention is that it can be easily moved to the root of the project
# (together with meson_options.txt) and packaged for wrapdb.
project(
'lz4',
['c'],
license: 'BSD-2-Clause-Patent AND GPL-2.0-or-later',
default_options: [
'c_std=c99',
'buildtype=release',
'warning_level=3'
],
version: 'DUMMY',
meson_version: '>=0.49.0'
)
subdir('meson')

View File

@@ -0,0 +1,39 @@
#!/usr/bin/env python3
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
import re
def find_version_tuple(filepath):
version_file_data = None
with open(filepath) as fd:
version_file_data = fd.read()
patterns = r"""#\s*define\s+LZ4_VERSION_MAJOR\s+([0-9]+).*$
#\s*define\s+LZ4_VERSION_MINOR\s+([0-9]+).*$
#\s*define\s+LZ4_VERSION_RELEASE\s+([0-9]+).*$
"""
regex = re.compile(patterns, re.MULTILINE)
version_match = regex.search(version_file_data)
if version_match:
return version_match.groups()
raise Exception("Unable to find version string.")
def main():
import argparse
parser = argparse.ArgumentParser(description='Print lz4 version from lib/lz4.h')
parser.add_argument('file', help='path to lib/lz4.h')
args = parser.parse_args()
version_tuple = find_version_tuple(args.file)
print('.'.join(version_tuple))
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,42 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
lz4_source_root = '../../../../..'
add_languages('cpp')
sources = files(
lz4_source_root / 'contrib/gen_manual/gen_manual.cpp'
)
gen_manual = executable(
'gen_manual',
sources,
native: true,
install: false
)
manual_pages = ['lz4', 'lz4frame']
foreach mp : manual_pages
custom_target(
'@0@_manual.html'.format(mp),
build_by_default: true,
input: lz4_source_root / 'lib/@0@.h'.format(mp),
output: '@0@_manual.html'.format(mp),
command: [
gen_manual,
lz4_version,
'@INPUT@',
'@OUTPUT@',
],
install: false
)
endforeach

View File

@@ -0,0 +1,11 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
subdir('gen_manual')

View File

@@ -0,0 +1,32 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
lz4_source_root = '../../../..'
examples = {
'printVersion': 'printVersion.c',
'doubleBuffer': 'blockStreaming_doubleBuffer.c',
'dictionaryRandomAccess': 'dictionaryRandomAccess.c',
'ringBuffer': 'blockStreaming_ringBuffer.c',
'ringBufferHC': 'HCStreaming_ringBuffer.c',
'lineCompress': 'blockStreaming_lineByLine.c',
'frameCompress': 'frameCompress.c',
'compressFunctions': 'compress_functions.c',
'simpleBuffer': 'simple_buffer.c',
}
foreach e, src : examples
executable(
e,
lz4_source_root / 'examples' / src,
dependencies: [liblz4_internal_dep],
install: false
)
endforeach

View File

@@ -0,0 +1,76 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
lz4_source_root = '../../../..'
sources = files(
lz4_source_root / 'lib/lz4.c',
lz4_source_root / 'lib/lz4frame.c',
lz4_source_root / 'lib/lz4hc.c',
lz4_source_root / 'lib/xxhash.c'
)
c_args = []
if host_machine.system() == 'windows' and get_option('default_library') != 'static'
c_args += '-DLZ4_DLL_EXPORT=1'
endif
if get_option('unstable')
compile_args += '-DLZ4_STATIC_LINKING_ONLY'
if get_option('default_library') != 'static'
c_args += '-DLZ4_PUBLISH_STATIC_FUNCTIONS'
endif
endif
liblz4 = library(
'lz4',
sources,
install: true,
version: lz4_version,
gnu_symbol_visibility: 'hidden'
)
liblz4_dep = declare_dependency(
link_with: liblz4,
include_directories: include_directories(lz4_source_root / 'lib')
)
if get_option('tests') or get_option('programs') or get_option('examples')
liblz4_internal = static_library(
'lz4-internal',
objects: liblz4.extract_all_objects(recursive: true),
gnu_symbol_visibility: 'hidden'
)
liblz4_internal_dep = declare_dependency(
link_with: liblz4_internal,
include_directories: include_directories(lz4_source_root / 'lib')
)
endif
pkgconfig.generate(
liblz4,
name: 'lz4',
filebase: 'liblz4',
description: 'extremely fast lossless compression algorithm library',
version: lz4_version,
url: 'http://www.lz4.org/'
)
install_headers(
lz4_source_root / 'lib/lz4.h',
lz4_source_root / 'lib/lz4hc.h',
lz4_source_root / 'lib/lz4frame.h'
)
if get_option('default_library') != 'shared'
install_headers(lz4_source_root / 'lib/lz4frame_static.h')
endif

View File

@@ -0,0 +1,67 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
cc = meson.get_compiler('c')
pkgconfig = import('pkgconfig')
lz4_source_root = '../../..'
lz4_version = meson.project_version()
lz4_h_file = lz4_source_root / 'lib/lz4.h'
GetLz4LibraryVersion_py = find_program('GetLz4LibraryVersion.py')
lz4_version = run_command(GetLz4LibraryVersion_py, lz4_h_file, check: true).stdout().strip()
message('Project version is now: @0@'.format(lz4_version))
add_project_arguments('-DXXH_NAMESPACE=LZ4_', language: 'c')
if get_option('debug')
add_project_arguments(cc.get_supported_arguments([
'-Wcast-qual',
'-Wcast-align',
'-Wshadow',
'-Wswitch-enum',
'-Wdeclaration-after-statement',
'-Wstrict-prototypes',
'-Wundef',
'-Wpointer-arith',
'-Wstrict-aliasing=1',
'-DLZ4_DEBUG=@0@'.format(get_option('debug-level')),
]
),
language: 'c',
)
endif
if get_option('memory-usage') > 0
add_project_arguments(
'-DLZ4_MEMORY_USAGE=@0@'.format(get_option('memory-usage')),
language: 'c'
)
endif
subdir('lib')
if get_option('programs')
subdir('programs')
endif
if get_option('tests')
subdir('tests')
endif
if get_option('contrib')
subdir('contrib')
endif
if get_option('examples')
subdir('examples')
endif

View File

@@ -0,0 +1,44 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
lz4_source_root = '../../../..'
sources = files(
lz4_source_root / 'programs/bench.c',
lz4_source_root / 'programs/datagen.c',
lz4_source_root / 'programs/lz4cli.c',
lz4_source_root / 'programs/lz4io.c',
)
lz4 = executable(
'lz4',
sources,
include_directories: include_directories(lz4_source_root / 'programs'),
dependencies: [liblz4_internal_dep],
export_dynamic: get_option('debug') and host_machine.system() == 'windows',
install: true
)
install_man(lz4_source_root / 'programs/lz4.1')
if meson.version().version_compare('>=0.61.0')
foreach alias : ['lz4c', 'lz4cat', 'unlz4']
install_symlink(
alias,
install_dir: get_option('bindir'),
pointing_to: 'lz4'
)
install_symlink(
'@0@.1'.format(alias),
install_dir: get_option('mandir') / 'man1',
pointing_to: 'lz4.1'
)
endforeach
endif

View File

@@ -0,0 +1,52 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
lz4_source_root = '../../../..'
exes = {
'fullbench': {
'sources': files(lz4_source_root / 'tests/fullbench.c'),
'include_directories': include_directories(lz4_source_root / 'programs'),
},
'fuzzer': {
'sources': files(lz4_source_root / 'tests/fuzzer.c'),
'include_directories': include_directories(lz4_source_root / 'programs'),
},
'frametest': {
'sources': files(lz4_source_root / 'tests/frametest.c'),
'include_directories': include_directories(lz4_source_root / 'programs'),
},
'roundTripTest': {
'sources': files(lz4_source_root / 'tests/roundTripTest.c'),
},
'datagen': {
'sources': files(lz4_source_root / 'tests/datagencli.c'),
'objects': lz4.extract_objects(lz4_source_root / 'programs/datagen.c'),
'include_directories': include_directories(lz4_source_root / 'programs'),
},
'checkFrame': {
'sources': files(lz4_source_root / 'tests/checkFrame.c'),
'include_directories': include_directories(lz4_source_root / 'programs'),
},
'checkTag': {
'sources': files(lz4_source_root / 'tests/checkTag.c'),
},
}
foreach e, attrs : exes
executable(
e,
attrs.get('sources'),
objects: attrs.get('objects', []),
dependencies: [liblz4_internal_dep],
include_directories: attrs.get('include_directories', []),
install: false
)
endforeach

View File

@@ -0,0 +1,24 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
option('debug-level', type: 'integer', min: 0, max: 7, value: 1,
description: 'Enable run-time debug. See lib/lz4hc.c')
option('unstable', type: 'boolean', value: false,
description: 'Expose unstable interfaces')
option('programs', type: 'boolean', value: false,
description: 'Enable programs build')
option('tests', type: 'boolean', value: false,
description: 'Enable tests build')
option('contrib', type: 'boolean', value: false,
description: 'Enable contrib build')
option('examples', type: 'boolean', value: false,
description: 'Enable examples build')
option('memory-usage', type: 'integer', min: 0, value: 0,
description: 'See LZ4_MEMORY_USAGE. 0 means use the LZ4 default')