diff options
-rw-r--r-- | .github/workflows/ci.yml | 9 | ||||
-rw-r--r-- | contrib/meson/meson.build | 16 | ||||
-rw-r--r-- | contrib/meson/meson/InstallSymlink.py | 55 | ||||
-rw-r--r-- | contrib/meson/meson/contrib/gen_manual/meson.build | 57 | ||||
-rw-r--r-- | contrib/meson/meson/contrib/meson.build | 1 | ||||
-rw-r--r-- | contrib/meson/meson/examples/meson.build | 61 | ||||
-rw-r--r-- | contrib/meson/meson/lib/meson.build | 91 | ||||
-rw-r--r-- | contrib/meson/meson/meson.build | 113 | ||||
-rw-r--r-- | contrib/meson/meson/programs/meson.build | 78 | ||||
-rw-r--r-- | contrib/meson/meson/tests/meson.build | 129 | ||||
-rw-r--r-- | contrib/meson/meson_options.txt | 20 |
11 files changed, 244 insertions, 386 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c0afb1..a458a19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -620,11 +620,10 @@ jobs: --buildtype=debug -Db_lundef=false -Dauto_features=enabled - -Ddefault_library=both - -Dbin_programs=true - -Dbin_contrib=true - -Dbin_tests=true - -Dbin_examples=true + -Dprograms=true + -Dcontrib=true + -Dtests=true + -Dexamples=true contrib/meson build - name: staging diff --git a/contrib/meson/meson.build b/contrib/meson/meson.build index d1e97d9..39672c8 100644 --- a/contrib/meson/meson.build +++ b/contrib/meson/meson.build @@ -11,11 +11,17 @@ # 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', 'GPLv2'], - default_options : ['c_std=c99', - 'buildtype=release'], +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.47.0') + meson_version: '>=0.49.0' +) subdir('meson') diff --git a/contrib/meson/meson/InstallSymlink.py b/contrib/meson/meson/InstallSymlink.py deleted file mode 100644 index 3f2998c..0000000 --- a/contrib/meson/meson/InstallSymlink.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/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). -# ############################################################################# -# This file should be synced with https://github.com/lzutao/meson-symlink - -import os -import pathlib # since Python 3.4 - - -def install_symlink(src, dst, install_dir, dst_is_dir=False, dir_mode=0o777): - if not install_dir.exists(): - install_dir.mkdir(mode=dir_mode, parents=True, exist_ok=True) - if not install_dir.is_dir(): - raise NotADirectoryError(install_dir) - - new_dst = install_dir.joinpath(dst) - if new_dst.is_symlink() and os.readlink(new_dst) == src: - print('File exists: {!r} -> {!r}'.format(new_dst, src)) - return - print('Installing symlink {!r} -> {!r}'.format(new_dst, src)) - new_dst.symlink_to(src, target_is_directory=dst_is_dir) - - -def main(): - import argparse - parser = argparse.ArgumentParser(description='Install a symlink', - usage='{0} [-h] [-d] [-m MODE] source dest install_dir\n\n' - 'example:\n' - ' {0} dash sh /bin'.format(pathlib.Path(__file__).name)) - parser.add_argument('source', help='target to link') - parser.add_argument('dest', help='link name') - parser.add_argument('install_dir', help='installation directory') - parser.add_argument('-d', '--isdir', - action='store_true', - help='dest is a directory') - parser.add_argument('-m', '--mode', - help='directory mode on creating if not exist', - default='0o755') - args = parser.parse_args() - - dir_mode = int(args.mode, 8) - - meson_destdir = os.environ.get('MESON_INSTALL_DESTDIR_PREFIX', default='') - install_dir = pathlib.Path(meson_destdir, args.install_dir) - install_symlink(args.source, args.dest, install_dir, args.isdir, dir_mode) - - -if __name__ == '__main__': - main() diff --git a/contrib/meson/meson/contrib/gen_manual/meson.build b/contrib/meson/meson/contrib/gen_manual/meson.build index a872bd6..84a95a9 100644 --- a/contrib/meson/meson/contrib/gen_manual/meson.build +++ b/contrib/meson/meson/contrib/gen_manual/meson.build @@ -1,5 +1,6 @@ # ############################################################################# -# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# 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 @@ -7,37 +8,35 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# -lz4_root_dir = '../../../../..' +lz4_source_root = '../../../../..' add_languages('cpp') -cxx = meson.get_compiler('cpp') -gen_manual_includes = include_directories(join_paths(lz4_root_dir, 'contrib/gen_manual')) +sources = files( + lz4_source_root / 'contrib/gen_manual/gen_manual.cpp' +) -gen_manual_cppflags = cxx.get_supported_arguments(['-Wextra', '-Wcast-qual', - '-Wcast-align', '-Wshadow', '-Wstrict-aliasing=1', '-Wswitch-enum', - '-Wno-comment']) - -gen_manual = executable('gen_manual', - join_paths(lz4_root_dir, 'contrib/gen_manual/gen_manual.cpp'), - cpp_args: gen_manual_cppflags, - include_directories: gen_manual_includes, +gen_manual = executable( + 'gen_manual', + sources, native: true, - install: false) + install: false +) + +manual_pages = ['lz4', 'lz4frame'] -# Update lz4 manual -lz4_manual_html = custom_target('lz4_manual.html', - output : 'lz4_manual.html', - command : [gen_manual, - lz4_version, - join_paths(meson.current_source_dir(), lz4_root_dir, 'lib/lz4.h'), - '@OUTPUT@'], - install : false) -# Update lz4frame manual -lz4_manual_html = custom_target('lz4frame_manual.html', - output : 'lz4frame_manual.html', - command : [gen_manual, - lz4_version, - join_paths(meson.current_source_dir(), lz4_root_dir, 'lib/lz4frame.h'), - '@OUTPUT@'], - install : false) +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 diff --git a/contrib/meson/meson/contrib/meson.build b/contrib/meson/meson/contrib/meson.build index 5249a4c..ef780fb 100644 --- a/contrib/meson/meson/contrib/meson.build +++ b/contrib/meson/meson/contrib/meson.build @@ -1,5 +1,6 @@ # ############################################################################# # 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 diff --git a/contrib/meson/meson/examples/meson.build b/contrib/meson/meson/examples/meson.build index 493049d..791bd94 100644 --- a/contrib/meson/meson/examples/meson.build +++ b/contrib/meson/meson/examples/meson.build @@ -1,5 +1,6 @@ # ############################################################################# -# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# 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 @@ -7,43 +8,25 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# -lz4_root_dir = '../../../..' +lz4_source_root = '../../../..' -#examples_c_args = ['-Wextra', '-Wundef', '-Wshadow', '-Wcast-align', '-Wstrict-prototypes'] +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', +} -printVersion = executable('printVersion', - join_paths(lz4_root_dir, 'examples/printVersion.c'), - dependencies: liblz4_dep, - install: false) -doubleBuffer = executable('doubleBuffer', - join_paths(lz4_root_dir, 'examples/blockStreaming_doubleBuffer.c'), - dependencies: liblz4_dep, - install: false) -dictionaryRandomAccess = executable('dictionaryRandomAccess', - join_paths(lz4_root_dir, 'examples/dictionaryRandomAccess.c'), - dependencies: liblz4_dep, - install: false) -ringBuffer = executable('ringBuffer', - join_paths(lz4_root_dir, 'examples/blockStreaming_ringBuffer.c'), - dependencies: liblz4_dep, - install: false) -ringBufferHC = executable('ringBufferHC', - join_paths(lz4_root_dir, 'examples/HCStreaming_ringBuffer.c'), - dependencies: liblz4_dep, - install: false) -lineCompress = executable('lineCompress', - join_paths(lz4_root_dir, 'examples/blockStreaming_lineByLine.c'), - dependencies: liblz4_dep, - install: false) -frameCompress = executable('frameCompress', - join_paths(lz4_root_dir, 'examples/frameCompress.c'), - dependencies: liblz4_dep, - install: false) -compressFunctions = executable('compressFunctions', - join_paths(lz4_root_dir, 'examples/compress_functions.c'), - dependencies: liblz4_dep, - install: false) -simpleBuffer = executable('simpleBuffer', - join_paths(lz4_root_dir, 'examples/simple_buffer.c'), - dependencies: liblz4_dep, - install: false) +foreach e, src : examples + executable( + e, + lz4_source_root / 'examples' / src, + dependencies: liblz4_dep, + install: false + ) +endforeach diff --git a/contrib/meson/meson/lib/meson.build b/contrib/meson/meson/lib/meson.build index 131edcb..9318667 100644 --- a/contrib/meson/meson/lib/meson.build +++ b/contrib/meson/meson/lib/meson.build @@ -1,5 +1,6 @@ # ############################################################################# -# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# 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 @@ -7,51 +8,69 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# -lz4_root_dir = '../../../..' - -liblz4_includes = [include_directories(join_paths(lz4_root_dir, 'lib'))] -liblz4_sources = [join_paths(lz4_root_dir, 'lib/lz4.c'), - join_paths(lz4_root_dir, 'lib/lz4frame.c'), - join_paths(lz4_root_dir, 'lib/lz4hc.c'), - join_paths(lz4_root_dir, 'lib/xxhash.c')] -liblz4_c_args = [] - -liblz4_debug_cflags = [] -if use_debug - liblz4_c_args += '-DLZ4_DEBUG=@0@'.format(debug_level) - if [compiler_gcc, compiler_clang].contains(cc_id) - liblz4_debug_cflags = ['-Wextra', '-Wcast-qual', '-Wcast-align', '-Wshadow', - '-Wswitch-enum', '-Wdeclaration-after-statement', '-Wstrict-prototypes', - '-Wundef', '-Wpointer-arith', '-Wstrict-aliasing=1'] - endif +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 default_library != 'static' + c_args += '-DLZ4_DLL_EXPORT=1' endif -liblz4_c_args += cc.get_supported_arguments(liblz4_debug_cflags) -if host_machine_os == os_windows and default_library != 'static' - liblz4_c_args += '-DLZ4_DLL_EXPORT=1' +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', - liblz4_sources, - include_directories: liblz4_includes, - c_args: liblz4_c_args, +liblz4 = library( + 'lz4', + sources, install: true, - version: lz4_libversion) + version: lz4_version, + gnu_symbol_visibility: 'hidden' +) + +liblz4_dep = declare_dependency( + link_with: liblz4, + include_directories: include_directories(lz4_source_root / 'lib') +) -liblz4_dep = declare_dependency(link_with: liblz4, - include_directories: liblz4_includes) +if get_option('tests') or get_option('programs') + 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, +pkgconfig.generate( + liblz4, name: 'lz4', filebase: 'liblz4', description: 'extremely fast lossless compression algorithm library', - version: lz4_libversion, - url: 'http://www.lz4.org/') + version: lz4_version, + url: 'http://www.lz4.org/' +) -install_headers(join_paths(lz4_root_dir, 'lib/lz4.h'), - join_paths(lz4_root_dir, 'lib/lz4hc.h'), - join_paths(lz4_root_dir, 'lib/lz4frame.h')) +install_headers( + lz4_source_root / 'lib/lz4.h', + lz4_source_root / 'lib/lz4hc.h', + lz4_source_root / 'lib/lz4frame.h' +) -if default_library != 'shared' - install_headers(join_paths(lz4_root_dir, 'lib/lz4frame_static.h')) +if get_option('default_library') != 'shared' + install_headers(lz4_source_root / 'lib/lz4frame_static.h') endif diff --git a/contrib/meson/meson/meson.build b/contrib/meson/meson/meson.build index 2cfd48c..9e8b8c6 100644 --- a/contrib/meson/meson/meson.build +++ b/contrib/meson/meson/meson.build @@ -1,5 +1,6 @@ # ############################################################################# -# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# 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 @@ -8,105 +9,59 @@ # ############################################################################# cc = meson.get_compiler('c') -pkgconfig = import('pkgconfig') -c_std = get_option('c_std') -default_library = get_option('default_library') -host_machine_os = host_machine.system() -os_windows = 'windows' -os_linux = 'linux' -os_darwin = 'darwin' -os_freebsd = 'freebsd' -os_sun = 'sunos' +pkgconfig = import('pkgconfig') -cc_id = cc.get_id() -compiler_gcc = 'gcc' -compiler_clang = 'clang' -compiler_msvc = 'msvc' +lz4_source_root = '../../..' lz4_version = meson.project_version() -lz4_h_file = join_paths(meson.current_source_dir(), '../../../lib/lz4.h') -GetLz4LibraryVersion_py = find_program('GetLz4LibraryVersion.py', native : true) +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)) -lz4_libversion = lz4_version - -# ============================================================================= -# Installation directories -# ============================================================================= - -lz4_prefix = get_option('prefix') -lz4_bindir = get_option('bindir') -lz4_datadir = get_option('datadir') -lz4_mandir = get_option('mandir') -lz4_docdir = join_paths(lz4_datadir, 'doc', meson.project_name()) - -# ============================================================================= -# Project options -# ============================================================================= - -buildtype = get_option('buildtype') - -# Built-in options -use_debug = get_option('debug') - -# Custom options -debug_level = get_option('debug_level') -use_backtrace = get_option('backtrace') - -bin_programs = get_option('bin_programs') -bin_contrib = get_option('bin_contrib') -bin_tests = get_option('bin_tests') -bin_examples = get_option('bin_examples') -#feature_multi_thread = get_option('multi_thread') - -# ============================================================================= -# Dependencies -# ============================================================================= - -#libm_dep = cc.find_library('m', required: bin_tests) -#thread_dep = dependency('threads', required: feature_multi_thread) -#use_multi_thread = thread_dep.found() - -# ============================================================================= -# Compiler flags -# ============================================================================= - -add_project_arguments(['-DXXH_NAMESPACE=LZ4_'], language: 'c') - -if [compiler_gcc, compiler_clang].contains(cc_id) - common_warning_flags = [] - # Should use Meson's own --werror build option - #common_warning_flags += ['-Werror'] - if c_std == 'c89' or c_std == 'gnu89' - common_warning_flags += ['-pedantic', '-Wno-long-long', '-Wno-variadic-macros'] - elif c_std == 'c99' or c_std == 'gnu99' - common_warning_flags += ['-pedantic'] - endif - cc_compile_flags = cc.get_supported_arguments(common_warning_flags) - add_project_arguments(cc_compile_flags, language: 'c') +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 -# ============================================================================= -# Subdirs -# ============================================================================= +if get_option('memory-usage') > 0 + add_project_arguments( + '-DLZ4_MEMORY_USAGE=@0@'.format(get_option('memory-usage')), + language: 'c' + ) +endif subdir('lib') -if bin_programs +if get_option('programs') subdir('programs') endif -if bin_tests +if get_option('tests') subdir('tests') endif -if bin_contrib +if get_option('contrib') subdir('contrib') endif -if bin_examples +if get_option('examples') subdir('examples') endif diff --git a/contrib/meson/meson/programs/meson.build b/contrib/meson/meson/programs/meson.build index 705dbf5..f9d5bf1 100644 --- a/contrib/meson/meson/programs/meson.build +++ b/contrib/meson/meson/programs/meson.build @@ -1,5 +1,6 @@ # ############################################################################# -# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# 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 @@ -7,46 +8,37 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# -lz4_root_dir = '../../../..' - -lz4_includes = include_directories(join_paths(lz4_root_dir, 'programs')) -lz4_sources = [join_paths(lz4_root_dir, 'programs/bench.c'), - join_paths(lz4_root_dir, 'programs/datagen.c'), - join_paths(lz4_root_dir, 'programs/lz4cli.c'), - join_paths(lz4_root_dir, 'programs/lz4io.c')] -lz4_c_args = [] - -export_dynamic_on_windows = false -# explicit backtrace enable/disable for Linux & Darwin -if not use_backtrace - lz4_c_args += '-DBACKTRACE_ENABLE=0' -elif use_debug and host_machine_os == os_windows # MinGW target - lz4_c_args += '-DBACKTRACE_ENABLE=1' - export_dynamic_on_windows = true +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 - -lz4_deps = [ liblz4_dep ] - -lz4 = executable('lz4', - lz4_sources, - include_directories: lz4_includes, - c_args: lz4_c_args, - dependencies: lz4_deps, - export_dynamic: export_dynamic_on_windows, # Since Meson 0.45.0 - install: true) - -# ============================================================================= -# Programs and manpages installing -# ============================================================================= - -install_man(join_paths(lz4_root_dir, 'programs/lz4.1')) - -InstallSymlink_py = '../InstallSymlink.py' -lz4_man1_dir = join_paths(lz4_mandir, 'man1') -bin_EXT = host_machine_os == os_windows ? '.exe' : '' -man1_EXT = meson.version().version_compare('>=0.49.0') ? '.1' : '.1.gz' - -foreach f : ['lz4c', 'lz4cat', 'unlz4'] - meson.add_install_script(InstallSymlink_py, 'lz4' + bin_EXT, f + bin_EXT, lz4_bindir) - meson.add_install_script(InstallSymlink_py, 'lz4' + man1_EXT, f + man1_EXT, lz4_man1_dir) -endforeach diff --git a/contrib/meson/meson/tests/meson.build b/contrib/meson/meson/tests/meson.build index 7800475..18479e4 100644 --- a/contrib/meson/meson/tests/meson.build +++ b/contrib/meson/meson/tests/meson.build @@ -1,5 +1,6 @@ # ############################################################################# -# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# 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 @@ -7,87 +8,45 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# -lz4_root_dir = '../../../..' -programs_dir_inc = include_directories(join_paths(lz4_root_dir, 'programs')) -lib_dir_inc = include_directories(join_paths(lz4_root_dir, 'lib')) - -# ============================================================================= -# Test flags -# ============================================================================= - -TEST_FILES = join_paths(meson.current_source_dir(), lz4_root_dir, 'tests/COPYING') -FUZZER_TIME = '-T90s' -NB_LOOPS = '-i1' - -# ============================================================================= -# Executables -# ============================================================================= - -fullbench_sources = [join_paths(lz4_root_dir, 'tests/fullbench.c')] -fullbench = executable('fullbench', - fullbench_sources, - include_directories: programs_dir_inc, - dependencies: liblz4_dep, - install: false) - -fuzzer_sources = [join_paths(lz4_root_dir, 'tests/fuzzer.c')] -fuzzer = executable('fuzzer', - fuzzer_sources, - c_args: ['-D_DEFAULT_SOURCE', '-D_BSD_SOURCE'], # since glibc 2.19 - include_directories: programs_dir_inc, - dependencies: liblz4_dep, - install: false) - -frametest_sources = [join_paths(lz4_root_dir, 'tests/frametest.c')] -frametest = executable('frametest', - frametest_sources, - include_directories: programs_dir_inc, - dependencies: liblz4_dep, - install: false) - -roundTripTest_sources = [join_paths(lz4_root_dir, 'tests/roundTripTest.c')] -roundTripTest = executable('roundTripTest', - roundTripTest_sources, - dependencies: [ liblz4_dep ], - install: false) - -datagen_sources = [join_paths(lz4_root_dir, 'tests/datagencli.c')] -datagen = executable('datagen', - datagen_sources, - objects: lz4.extract_objects(join_paths(lz4_root_dir, 'programs/datagen.c')), - include_directories: lz4_includes, - dependencies: [ liblz4_dep ], - install: false) - -checkFrame_sources = [join_paths(lz4_root_dir, 'tests/checkFrame.c')] -checkFrame = executable('checkFrame', - checkFrame_sources, - include_directories: programs_dir_inc, - dependencies: [ liblz4_dep ], - install: false) - -checkTag_sources = [join_paths(lz4_root_dir, 'tests/checkTag.c')] -checkTag = executable('checkTag', - checkTag_sources, - include_directories: lib_dir_inc, - install: false) - -# ============================================================================= -# Tests (Use "meson test --list" to list all tests) -# ============================================================================= - -# XXX: (Need TEST) These timeouts (in seconds) when running on a HDD should be -# at least six times bigger than on a SSD - -test('test-fullbench', - fullbench, - args: ['--no-prompt', NB_LOOPS, TEST_FILES], - timeout: 420) # Should enough when running on HDD -test('test-fuzzer', - fuzzer, - args: [FUZZER_TIME], - timeout: 100) -test('test-frametest', - frametest, - args: [FUZZER_TIME], - timeout: 100) +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 diff --git a/contrib/meson/meson_options.txt b/contrib/meson/meson_options.txt index a409c2d..ccb32de 100644 --- a/contrib/meson/meson_options.txt +++ b/contrib/meson/meson_options.txt @@ -1,5 +1,6 @@ # ############################################################################# # 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 @@ -7,18 +8,17 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# -# Read guidelines from https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting - -option('debug_level', type: 'integer', min: 0, max: 7, value: 1, +option('debug-level', type: 'integer', min: 0, max: 7, value: 1, description: 'Enable run-time debug. See lib/lz4hc.c') -option('backtrace', type: 'boolean', value: false, - description: 'Display a stack backtrace when execution generates a runtime exception') - -option('bin_programs', type: 'boolean', value: false, +option('unstable', type: 'boolean', value: false, + description: 'Expose unstable interfaces') +option('programs', type: 'boolean', value: false, description: 'Enable programs build') -option('bin_tests', type: 'boolean', value: false, +option('tests', type: 'boolean', value: false, description: 'Enable tests build') -option('bin_contrib', type: 'boolean', value: false, +option('contrib', type: 'boolean', value: false, description: 'Enable contrib build') -option('bin_examples', type: 'boolean', value: false, +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') |