diff options
Diffstat (limited to 'build/meson/meson')
-rw-r--r-- | build/meson/meson/contrib/gen_manual/meson.build | 42 | ||||
-rw-r--r-- | build/meson/meson/contrib/meson.build | 11 | ||||
-rw-r--r-- | build/meson/meson/examples/meson.build | 32 | ||||
-rw-r--r-- | build/meson/meson/lib/meson.build | 87 | ||||
-rw-r--r-- | build/meson/meson/meson.build | 126 | ||||
-rw-r--r-- | build/meson/meson/ossfuzz/meson.build | 35 | ||||
-rw-r--r-- | build/meson/meson/programs/meson.build | 74 | ||||
-rw-r--r-- | build/meson/meson/tests/meson.build | 158 |
8 files changed, 565 insertions, 0 deletions
diff --git a/build/meson/meson/contrib/gen_manual/meson.build b/build/meson/meson/contrib/gen_manual/meson.build new file mode 100644 index 0000000..c4349aa --- /dev/null +++ b/build/meson/meson/contrib/gen_manual/meson.build @@ -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', native: true) + +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, + meson.project_version(), + '@INPUT@', + '@OUTPUT@', + ], + install: false + ) +endforeach diff --git a/build/meson/meson/contrib/meson.build b/build/meson/meson/contrib/meson.build new file mode 100644 index 0000000..ef780fb --- /dev/null +++ b/build/meson/meson/contrib/meson.build @@ -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') diff --git a/build/meson/meson/examples/meson.build b/build/meson/meson/examples/meson.build new file mode 100644 index 0000000..65f54ca --- /dev/null +++ b/build/meson/meson/examples/meson.build @@ -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 diff --git a/build/meson/meson/lib/meson.build b/build/meson/meson/lib/meson.build new file mode 100644 index 0000000..4acf614 --- /dev/null +++ b/build/meson/meson/lib/meson.build @@ -0,0 +1,87 @@ +# ############################################################################# +# 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' +) + +if get_option('unstable') + sources += files(lz4_source_root / 'lib/lz4file.c') +endif + +c_args = [] + +if host_machine.system() == 'windows' and get_option('default_library') != 'static' + c_args += '-DLZ4_DLL_EXPORT=1' +endif + +liblz4 = library( + 'lz4', + sources, + c_args: c_args, + install: true, + version: meson.project_version(), + gnu_symbol_visibility: 'hidden' +) + +liblz4_dep = declare_dependency( + link_with: liblz4, + compile_args: compile_args, + include_directories: include_directories(lz4_source_root / 'lib') +) + +meson.override_dependency('liblz4', liblz4_dep) + +if get_option('tests') or get_option('programs') or get_option('examples') or get_option('ossfuzz') + if get_option('default_library') == 'shared' + liblz4_internal = static_library( + 'lz4-internal', + objects: liblz4.extract_all_objects(recursive: true), + gnu_symbol_visibility: 'hidden' + ) + elif get_option('default_library') == 'static' + liblz4_internal = liblz4 + elif get_option('default_library') == 'both' + liblz4_internal = liblz4.get_static_lib() + endif + + liblz4_internal_dep = declare_dependency( + link_with: liblz4_internal, + compile_args: compile_args, + include_directories: include_directories(lz4_source_root / 'lib') + ) +endif + +pkgconfig.generate( + liblz4, + name: 'lz4', + filebase: 'liblz4', + description: 'extremely fast lossless compression algorithm library', + version: meson.project_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') + if get_option('unstable') + install_headers(lz4_source_root / 'lib/lz4file.h') + endif +endif diff --git a/build/meson/meson/meson.build b/build/meson/meson/meson.build new file mode 100644 index 0000000..3bea06d --- /dev/null +++ b/build/meson/meson/meson.build @@ -0,0 +1,126 @@ +# ############################################################################# +# 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') + +fs = import('fs') +pkgconfig = import('pkgconfig') + +lz4_source_root = '../../..' + +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 + +compile_args = [] + +if not get_option('align-test') + add_project_arguments('-DLZ4_ALIGN_TEST=0', language: 'c') +endif + +if get_option('disable-memory-allocation') + if get_option('default_library') != 'static' + error('Memory allocation can only be disabled in static builds') + endif + + add_project_arguments('-DLZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION') + compile_args += '-DLZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION' +endif + +add_project_arguments( + '-DLZ4_DISTANCE_MAX=@0@'.format(get_option('distance-max')), + language: 'c' +) +compile_args += '-DLZ4_DISTANCE_MAX=@0@'.format(get_option('distance-max')) + +if not get_option('fast-dec-loop').auto() + add_project_arguments( + '-DLZ4_FAST_DEC_LOOP=@0@'.format( + get_option('fast-dec-loop').enabled() ? 1 : 0 + ), + language: 'c' + ) +endif + +if get_option('force-sw-bitcount') + add_project_arguments('-DLZ4_FORCE_SW_BITCOUNT', language: 'c') +endif + +if get_option('freestanding') + add_project_arguments('-DLZ4_FREESTANDING=1', language: 'c') + compile_args += '-DLZ4_FREESTANDING=1' +endif + +if get_option('memory-usage') > 0 + add_project_arguments( + '-DLZ4_MEMORY_USAGE=@0@'.format(get_option('memory-usage')), + language: 'c' + ) + compile_args += '-DLZ4_MEMORY_USAGE=@0@'.format(get_option('memory-usage')) +endif + +if get_option('unstable') + add_project_arguments('-DLZ4_STATIC_LINKING_ONLY', language: 'c') + compile_args += '-DLZ4_STATIC_LINKING_ONLY' + if get_option('default_library') != 'static' + add_project_arguments('-DLZ4_PUBLISH_STATIC_FUNCTIONS', language: 'c') + compile_args += '-DLZ4_PUBLISH_STATIC_FUNCTIONS' + + add_project_arguments('-DLZ4F_PUBLISH_STATIC_FUNCTIONS', language: 'c') + compile_args += '-DLZ4F_PUBLISH_STATIC_FUNCTIONS' + endif +endif + +if get_option('user-memory-functions') + add_project_arguments('-DLZ4_USER_MEMORY_FUNCTIONS', language: 'c') +endif + +run_env = environment() + +subdir('lib') + +if get_option('programs') + subdir('programs') +else + lz4 = disabler() + lz4cat = disabler() + unlz4 = disabler() +endif + +if get_option('tests') + subdir('tests') +endif + +if get_option('contrib') + subdir('contrib') +endif + +if get_option('examples') + subdir('examples') +endif + +if get_option('ossfuzz') + subdir('ossfuzz') +endif diff --git a/build/meson/meson/ossfuzz/meson.build b/build/meson/meson/ossfuzz/meson.build new file mode 100644 index 0000000..9945d8c --- /dev/null +++ b/build/meson/meson/ossfuzz/meson.build @@ -0,0 +1,35 @@ +fuzzers = [ + 'compress_frame_fuzzer', + 'compress_fuzzer', + 'compress_hc_fuzzer', + 'decompress_frame_fuzzer', + 'decompress_fuzzer', + 'round_trip_frame_uncompressed_fuzzer', + 'round_trip_fuzzer', + 'round_trip_hc_fuzzer', + 'round_trip_stream_fuzzer' +] + +c_args = cc.get_supported_arguments( + '-Wno-unused-function', + '-Wno-sign-compare', + '-Wno-declaration-after-statement' +) + +foreach f : fuzzers + lib = static_library( + f, + lz4_source_root / 'ossfuzz/@0@.c'.format(f), + lz4_source_root / 'ossfuzz/lz4_helpers.c', + lz4_source_root / 'ossfuzz/fuzz_data_producer.c', + c_args: c_args, + dependencies: [liblz4_internal_dep] + ) + + executable( + f, + lz4_source_root / 'ossfuzz/standaloneengine.c', + link_with: lib, + dependencies: [liblz4_internal_dep] + ) +endforeach diff --git a/build/meson/meson/programs/meson.build b/build/meson/meson/programs/meson.build new file mode 100644 index 0000000..a8bc18a --- /dev/null +++ b/build/meson/meson/programs/meson.build @@ -0,0 +1,74 @@ +# ############################################################################# +# 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 +) + +lz4cat = custom_target( + 'lz4cat', + input: lz4, + output: 'lz4cat', + command: [ + 'ln', + '--symbolic', + '--force', + fs.name(lz4.full_path()), + '@OUTPUT@' + ] +) + +unlz4 = custom_target( + 'unlz4', + input: lz4, + output: 'unlz4', + command: [ + 'ln', + '--symbolic', + '--force', + fs.name(lz4.full_path()), + '@OUTPUT@' + ] +) + +meson.override_find_program('lz4', lz4) + +run_env.prepend('PATH', meson.current_build_dir()) + +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 diff --git a/build/meson/meson/tests/meson.build b/build/meson/meson/tests/meson.build new file mode 100644 index 0000000..df47b83 --- /dev/null +++ b/build/meson/meson/tests/meson.build @@ -0,0 +1,158 @@ +# ############################################################################# +# 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 = '../../../..' + +fuzzer_time = 90 +test_exes = { + 'abiTest': { + 'sources': files(lz4_source_root / 'tests/abiTest.c'), + 'test': false, + }, + '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'), + 'test': false, + }, + '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'), + }, + 'decompress-partial-usingDict.c': { + 'sources': files(lz4_source_root / 'tests/decompress-partial-usingDict.c'), + }, + 'decompress-partial.c': { + 'sources': files(lz4_source_root / 'tests/decompress-partial.c'), + }, + 'frametest': { + 'sources': files(lz4_source_root / 'tests/frametest.c'), + 'include_directories': include_directories(lz4_source_root / 'programs'), + 'args': ['-v', '-T@0@s'.format(fuzzer_time)], + 'test': false, + }, + 'freestanding': { + 'sources': files(lz4_source_root / 'tests/freestanding.c'), + 'c_args': ['-ffreestanding', '-Wno-unused-parameter', '-Wno-declaration-after-statement'], + 'link_args': ['-nostdlib'], + 'build': cc.get_id() in ['gcc', 'clang'] and + host_machine.system() == 'linux' and host_machine.cpu_family() == 'x86_64', + 'override_options': ['optimization=1'], + }, + 'fullbench': { + 'sources': files(lz4_source_root / 'tests/fullbench.c'), + 'include_directories': include_directories(lz4_source_root / 'programs'), + 'args': ['--no-prompt', '-i1', files(lz4_source_root / 'tests/COPYING')], + 'test': false, + }, + 'fuzzer': { + 'sources': files(lz4_source_root / 'tests/fuzzer.c'), + 'include_directories': include_directories(lz4_source_root / 'programs'), + 'args': ['-T@0@s'.format(fuzzer_time)], + 'test': false, + }, + 'roundTripTest': { + 'sources': files(lz4_source_root / 'tests/roundTripTest.c'), + 'test': false, + }, +} + +targets = {} + +foreach e, attrs : test_exes + if not attrs.get('build', true) + targets += {e: disabler()} + continue + endif + + t = executable( + e, + attrs.get('sources'), + c_args: attrs.get('c_args', []), + link_args: attrs.get('link_args', []), + objects: attrs.get('objects', []), + dependencies: [liblz4_internal_dep], + include_directories: attrs.get('include_directories', []), + install: false, + override_options: attrs.get('override_options', []) + ) + + targets += {e: t} + + if not attrs.get('test', true) + continue + endif + + test( + e, + t, + args: attrs.get('params', []), + timeout: 120 + ) +endforeach + +fs = import('fs') + +run_env.prepend('PATH', meson.current_build_dir()) + +test_scripts = { + 'lz4-basic': { + 'depends': [lz4, lz4cat, unlz4, targets['datagen']], + }, + 'lz4-dict': { + 'depends': [lz4, targets['datagen']], + }, + 'lz4-contentSize': { + 'depends': [lz4, targets['datagen']], + }, + 'lz4-fast-hugefile': { + 'depends': [lz4, targets['datagen']], + }, + 'lz4-frame-concatenation': { + 'depends': [lz4, targets['datagen']], + }, + 'lz4-multiple': { + 'depends': [lz4, targets['datagen']], + }, + 'lz4-multiple-legacy': { + 'depends': [lz4, targets['datagen']], + }, + 'lz4-opt-parser': { + 'depends': [lz4, targets['datagen']], + }, + 'lz4-skippable': { + 'depends': [lz4], + }, + 'lz4-sparse': { + 'depends': [lz4, targets['datagen']], + }, + 'lz4-testmode': { + 'depends': [lz4, targets['datagen']], + }, + 'lz4hc-hugefile': { + 'depends': [lz4, targets['datagen']], + }, +} + +foreach s, attrs : test_scripts + script = find_program(lz4_source_root / 'tests/test-@0@.sh'.format(s)) + + test( + '@0@'.format(s), + script, + depends: attrs.get('depends', []), + workdir: fs.parent(script.full_path()), + env: run_env, + timeout: 360 + ) +endforeach |