diff options
Diffstat (limited to 'contrib/meson')
-rw-r--r-- | contrib/meson/GetLz4LibraryVersion.py (renamed from contrib/meson/meson/GetLz4LibraryVersion.py) | 0 | ||||
-rw-r--r-- | contrib/meson/meson.build | 10 | ||||
-rw-r--r-- | contrib/meson/meson/contrib/gen_manual/meson.build | 4 | ||||
-rw-r--r-- | contrib/meson/meson/lib/meson.build | 24 | ||||
-rw-r--r-- | contrib/meson/meson/meson.build | 99 | ||||
-rw-r--r-- | contrib/meson/meson/ossfuzz/meson.build | 35 | ||||
-rw-r--r-- | contrib/meson/meson/programs/meson.build | 30 | ||||
-rw-r--r-- | contrib/meson/meson/tests/meson.build | 139 | ||||
-rw-r--r-- | contrib/meson/meson_options.txt | 36 |
9 files changed, 315 insertions, 62 deletions
diff --git a/contrib/meson/meson/GetLz4LibraryVersion.py b/contrib/meson/GetLz4LibraryVersion.py index d8abfcb..d8abfcb 100644 --- a/contrib/meson/meson/GetLz4LibraryVersion.py +++ b/contrib/meson/GetLz4LibraryVersion.py diff --git a/contrib/meson/meson.build b/contrib/meson/meson.build index 39672c8..fc6408a 100644 --- a/contrib/meson/meson.build +++ b/contrib/meson/meson.build @@ -13,15 +13,19 @@ project( 'lz4', - ['c'], + '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' + version: run_command( + find_program('GetLz4LibraryVersion.py'), + '../../lib/lz4.h', + check: true + ).stdout().strip(), + meson_version: '>=0.58.0' ) subdir('meson') diff --git a/contrib/meson/meson/contrib/gen_manual/meson.build b/contrib/meson/meson/contrib/gen_manual/meson.build index 84a95a9..c4349aa 100644 --- a/contrib/meson/meson/contrib/gen_manual/meson.build +++ b/contrib/meson/meson/contrib/gen_manual/meson.build @@ -10,7 +10,7 @@ lz4_source_root = '../../../../..' -add_languages('cpp') +add_languages('cpp', native: true) sources = files( lz4_source_root / 'contrib/gen_manual/gen_manual.cpp' @@ -33,7 +33,7 @@ foreach mp : manual_pages output: '@0@_manual.html'.format(mp), command: [ gen_manual, - lz4_version, + meson.project_version(), '@INPUT@', '@OUTPUT@', ], diff --git a/contrib/meson/meson/lib/meson.build b/contrib/meson/meson/lib/meson.build index 469cd09..f37eec2 100644 --- a/contrib/meson/meson/lib/meson.build +++ b/contrib/meson/meson/lib/meson.build @@ -17,33 +17,32 @@ sources = files( 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 -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, + c_args: c_args, install: true, - version: lz4_version, + 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') ) -if get_option('tests') or get_option('programs') or get_option('examples') +if get_option('tests') or get_option('programs') or get_option('examples') or get_option('ossfuzz') liblz4_internal = static_library( 'lz4-internal', objects: liblz4.extract_all_objects(recursive: true), @@ -52,6 +51,7 @@ if get_option('tests') or get_option('programs') or get_option('examples') liblz4_internal_dep = declare_dependency( link_with: liblz4_internal, + compile_args: compile_args, include_directories: include_directories(lz4_source_root / 'lib') ) endif @@ -61,7 +61,7 @@ pkgconfig.generate( name: 'lz4', filebase: 'liblz4', description: 'extremely fast lossless compression algorithm library', - version: lz4_version, + version: meson.project_version(), url: 'http://www.lz4.org/' ) @@ -74,3 +74,7 @@ install_headers( if get_option('default_library') != 'shared' install_headers(lz4_source_root / 'lib/lz4frame_static.h') endif + +if get_option('unstable') + install_headers(lz4_source_root / 'lib/lz4file.h') +endif diff --git a/contrib/meson/meson/meson.build b/contrib/meson/meson/meson.build index 9e8b8c6..3bea06d 100644 --- a/contrib/meson/meson/meson.build +++ b/contrib/meson/meson/meson.build @@ -10,48 +10,103 @@ cc = meson.get_compiler('c') +fs = import('fs') 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')), - ] + 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', + 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') @@ -65,3 +120,7 @@ endif if get_option('examples') subdir('examples') endif + +if get_option('ossfuzz') + subdir('ossfuzz') +endif diff --git a/contrib/meson/meson/ossfuzz/meson.build b/contrib/meson/meson/ossfuzz/meson.build new file mode 100644 index 0000000..9945d8c --- /dev/null +++ b/contrib/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/contrib/meson/meson/programs/meson.build b/contrib/meson/meson/programs/meson.build index f9d5bf1..a8bc18a 100644 --- a/contrib/meson/meson/programs/meson.build +++ b/contrib/meson/meson/programs/meson.build @@ -26,6 +26,36 @@ lz4 = executable( 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') diff --git a/contrib/meson/meson/tests/meson.build b/contrib/meson/meson/tests/meson.build index 18479e4..71db2e6 100644 --- a/contrib/meson/meson/tests/meson.build +++ b/contrib/meson/meson/tests/meson.build @@ -10,43 +10,148 @@ lz4_source_root = '../../../..' -exes = { - 'fullbench': { - 'sources': files(lz4_source_root / 'tests/fullbench.c'), +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'), }, - 'fuzzer': { - 'sources': files(lz4_source_root / 'tests/fuzzer.c'), + '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, }, - 'roundTripTest': { - 'sources': files(lz4_source_root / 'tests/roundTripTest.c'), + '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'], + 'override_options': ['optimization=1'] }, - 'datagen': { - 'sources': files(lz4_source_root / 'tests/datagencli.c'), - 'objects': lz4.extract_objects(lz4_source_root / 'programs/datagen.c'), + '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, }, - 'checkFrame': { - 'sources': files(lz4_source_root / 'tests/checkFrame.c'), + '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, }, - 'checkTag': { - 'sources': files(lz4_source_root / 'tests/checkTag.c'), + 'roundTripTest': { + 'sources': files(lz4_source_root / 'tests/roundTripTest.c'), + 'test': false, }, } -foreach e, attrs : exes - executable( +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 + 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 diff --git a/contrib/meson/meson_options.txt b/contrib/meson/meson_options.txt index ccb32de..36eedbb 100644 --- a/contrib/meson/meson_options.txt +++ b/contrib/meson/meson_options.txt @@ -8,17 +8,33 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# +option('align-test', type: 'boolean', value: true, + description: 'See LZ4_ALIGN_TEST') +option('contrib', type: 'boolean', value: false, + description: 'Enable contrib') 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('disable-memory-allocation', type: 'boolean', value: false, + description: 'See LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION. Static builds only') +option('distance-max', type: 'integer', min: 0, max: 65535, value: 65535, + description: 'See LZ4_DISTANCE_MAX') option('examples', type: 'boolean', value: false, - description: 'Enable examples build') -option('memory-usage', type: 'integer', min: 0, value: 0, + description: 'Enable examples') +option('fast-dec-loop', type: 'feature', value: 'auto', + description: 'See LZ4_FAST_DEC_LOOP') +option('force-sw-bitcount', type: 'boolean', value: false, + description: 'See LZ4_FORCE_SW_BITCOUNT') +option('freestanding', type: 'boolean', value: false, + description: 'See LZ4_FREESTANDING') +option('memory-usage', type: 'integer', min: 0, max: 20, value: 0, description: 'See LZ4_MEMORY_USAGE. 0 means use the LZ4 default') +option('ossfuzz', type: 'boolean', value: true, + description: 'Enable ossfuzz') +option('programs', type: 'boolean', value: false, + description: 'Enable programs') +option('tests', type: 'boolean', value: false, + description: 'Enable tests') +option('unstable', type: 'boolean', value: false, + description: 'Expose unstable interfaces') +option('user-memory-functions', type: 'boolean', value: false, + description: 'See LZ4_USER_MEMORY_FUNCTIONS') |