diff options
author | Yann Collet <Cyan4973@users.noreply.github.com> | 2018-12-09 19:29:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-09 19:29:03 (GMT) |
commit | 077caefae6eb8c38e6264a41ae637499d2114235 (patch) | |
tree | 4a2ae168ca7f168b98d556a11655c1ad64da4a13 | |
parent | 3a510831c31500e94f9fd732b586ef7b92642d2c (diff) | |
parent | 58d8055da65f07972bf73162a5477229428b96bc (diff) | |
download | lz4-077caefae6eb8c38e6264a41ae637499d2114235.zip lz4-077caefae6eb8c38e6264a41ae637499d2114235.tar.gz lz4-077caefae6eb8c38e6264a41ae637499d2114235.tar.bz2 |
Merge pull request #613 from lzutao/fix_meson_tests
meson: Fix build and test problems
-rw-r--r-- | .travis.yml | 10 | ||||
-rw-r--r-- | contrib/meson/GetLz4LibraryVersion.py | 14 | ||||
-rw-r--r-- | contrib/meson/InstallSymlink.py | 53 | ||||
-rw-r--r-- | contrib/meson/README.md | 34 | ||||
-rw-r--r-- | contrib/meson/lib/meson.build | 4 | ||||
-rw-r--r-- | contrib/meson/meson.build | 62 | ||||
-rw-r--r-- | contrib/meson/programs/meson.build | 5 | ||||
-rw-r--r-- | contrib/meson/tests/meson.build | 20 |
8 files changed, 108 insertions, 94 deletions
diff --git a/.travis.yml b/.travis.yml index 043f932..66da011 100644 --- a/.travis.yml +++ b/.travis.yml @@ -168,10 +168,14 @@ script: && curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" && python3 get-pip.py --user && rm get-pip.py && pip3 install --user meson ninja - && meson --buildtype=debug -Dauto_features=enabled -Ddefault_library=both - -Dbuild_{programs,contrib,tests,examples}=true contrib/meson build + && export CC=clang CXX=clang++ + && meson --buildtype=debug + -Db_lundef=false + -Dauto_features=enabled + -Ddefault_library=both + -Dbuild_{programs,contrib,tests,examples}=true + contrib/meson build && cd "$_" - && ninja && DESTDIR=./staging ninja install && tree ./staging; travis_terminate "$?"; diff --git a/contrib/meson/GetLz4LibraryVersion.py b/contrib/meson/GetLz4LibraryVersion.py index e929f95..80b09c9 100644 --- a/contrib/meson/GetLz4LibraryVersion.py +++ b/contrib/meson/GetLz4LibraryVersion.py @@ -11,11 +11,6 @@ import re import sys -def usage(): - print('usage: python3 GetLz4LibraryVersion.py <path/to/lz4.h>') - sys.exit(1) - - def find_version(filepath): version_file_data = None with open(filepath) as fd: @@ -33,10 +28,11 @@ def find_version(filepath): def main(): - if len(sys.argv) < 2: - usage() - - filepath = sys.argv[1] + 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() + filepath = args.file version_tup = find_version(filepath) print('.'.join(version_tup)) diff --git a/contrib/meson/InstallSymlink.py b/contrib/meson/InstallSymlink.py index d7b1e5a..c1f13f5 100644 --- a/contrib/meson/InstallSymlink.py +++ b/contrib/meson/InstallSymlink.py @@ -7,42 +7,31 @@ # 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 errno -import os - -def mkdir_p(path, dir_mode=0o777): - try: - os.makedirs(path, mode=dir_mode) - except OSError as exc: # Python >2.5 - if exc.errno == errno.EEXIST and os.path.isdir(path): - pass - else: - raise +import os +import pathlib # since Python 3.4 -def InstallSymlink(src, dst, install_dir, dst_is_dir=False, dir_mode=0o777): - if not os.path.exists(install_dir): - mkdir_p(install_dir, dir_mode) - if not os.path.isdir(install_dir): - raise NotADirectoryError(install_dir) +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 = os.path.join(install_dir, dst) - if os.path.islink(new_dst) and os.readlink(new_dst) == src: - print('File exists: %r -> %r' % (dst, src)) + 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' % (new_dst, src)) - os.symlink(src, new_dst, dst_is_dir) + 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.\n', - usage='usage: InstallSymlink.py [-h] [-d] [-m MODE] src dst ' - 'install_dir\n\n' + parser = argparse.ArgumentParser(description='Install a symlink', + usage='InstallSymlink.py [-h] [-d] [-m MODE] src dst install_dir\n\n' 'example:\n' - '\tInstallSymlink.py libcrypto.so.1.0.0 libcrypt.so ' - '/usr/lib/x86_64-linux-gnu False') + '\tInstallSymlink.py dash sh /bin') parser.add_argument('src', help='target to link') parser.add_argument('dst', help='link name') parser.add_argument('install_dir', help='installation directory') @@ -56,16 +45,14 @@ def main(): src = args.src dst = args.dst - install_dir = args.install_dir dst_is_dir = args.isdir dir_mode = int(args.mode, 8) + install_dir = pathlib.Path(args.install_dir) - DESTDIR = os.environ.get('DESTDIR') - if DESTDIR: - install_dir = DESTDIR + install_dir if os.path.isabs(install_dir) \ - else os.path.join(DESTDIR, install_dir) - - InstallSymlink(src, dst, install_dir, dst_is_dir, dir_mode) + meson_destdir = os.environ.get('MESON_INSTALL_DESTDIR_PREFIX') + if meson_destdir: + install_dir = pathlib.Path(meson_destdir).joinpath(install_dir) + install_symlink(src, dst, install_dir, dst_is_dir, dir_mode) if __name__ == '__main__': diff --git a/contrib/meson/README.md b/contrib/meson/README.md new file mode 100644 index 0000000..4e55ab9 --- /dev/null +++ b/contrib/meson/README.md @@ -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 --buildtype=release -Ddefault_library=shared -Dbuild_programs=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). diff --git a/contrib/meson/lib/meson.build b/contrib/meson/lib/meson.build index 3810601..ff7a703 100644 --- a/contrib/meson/lib/meson.build +++ b/contrib/meson/lib/meson.build @@ -32,13 +32,13 @@ liblz4 = library('lz4', include_directories: liblz4_includes, c_args: liblz4_c_args, install: true, - soversion: lz4_libversion) + version: lz4_libversion) liblz4_dep = declare_dependency(link_with: liblz4, include_directories: liblz4_includes) pkgconfig.generate(name: 'lz4', - filebase: 'lz4', + filebase: 'liblz4', libraries: [liblz4], description: 'extremely fast lossless compression algorithm library', version: lz4_libversion, diff --git a/contrib/meson/meson.build b/contrib/meson/meson.build index f1ca503..d618eb4 100644 --- a/contrib/meson/meson.build +++ b/contrib/meson/meson.build @@ -17,6 +17,7 @@ project('lz4', ['c'], cc = meson.get_compiler('c') pkgconfig = import('pkgconfig') python3 = import('python').find_installation() +c_std = get_option('c_std') host_machine_os = host_machine.system() os_windows = 'windows' @@ -31,26 +32,30 @@ compiler_clang = 'clang' compiler_msvc = 'msvc' lz4_version = meson.project_version() -lz4_libversion = '' -c_std = get_option('c_std') +lz4_h_file = join_paths(meson.current_source_dir(), '../../lib/lz4.h') +GetLz4LibraryVersion_py = files('GetLz4LibraryVersion.py') +r = run_command(python3, GetLz4LibraryVersion_py, lz4_h_file) +if r.returncode() == 0 + output = r.stdout().strip() + if output.version_compare('>@0@'.format(lz4_version)) + lz4_version = output + message('Project version is now: @0@'.format(lz4_version)) + endif +else + message('Cannot find project version in @0@'.format(lz4_h_file)) +endif + +lz4_libversion = lz4_version # ============================================================================= # Installation directories # ============================================================================= -if host_machine_os == os_windows - lz4_prefix = '.' - lz4_bindir = 'bin' - lz4_datadir = 'share' - lz4_mandir = join_paths(lz4_datadir, 'man') -else - lz4_prefix = get_option('prefix') - lz4_bindir = join_paths(lz4_prefix, get_option('bindir')) - lz4_datadir = join_paths(lz4_prefix, get_option('datadir')) - lz4_mandir = join_paths(lz4_prefix, get_option('mandir')) -endif - +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()) # ============================================================================= @@ -73,30 +78,6 @@ build_examples = get_option('build_examples') #feature_multi_thread = get_option('multi_thread') # ============================================================================= -# Helper scripts for Meson -# ============================================================================= - -GetLz4LibraryVersion_py = files('GetLz4LibraryVersion.py') - -# ============================================================================= -# Getting project version from lz4.h -# ============================================================================= - -lz4_h_file = join_paths(meson.current_source_dir(), 'lib/lz4.h') -r = run_command(python3, GetLz4LibraryVersion_py, lz4_h_file) -if r.returncode() == 0 - output = r.stdout().strip() - if output.version_compare('>@0@'.format(lz4_version)) - lz4_version = output - message('Project version is now: @0@'.format(lz4_version)) - endif -endif - -if host_machine_os != os_windows - lz4_libversion = lz4_version -endif - -# ============================================================================= # Dependencies # ============================================================================= @@ -112,9 +93,8 @@ add_project_arguments(['-DXXH_NAMESPACE=LZ4_'], language: 'c') if [compiler_gcc, compiler_clang].contains(cc_id) common_warning_flags = [] - if buildtype == 'release' - common_warning_flags = ['-Werror'] - endif + # 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' diff --git a/contrib/meson/programs/meson.build b/contrib/meson/programs/meson.build index b5c3228..2d39b59 100644 --- a/contrib/meson/programs/meson.build +++ b/contrib/meson/programs/meson.build @@ -43,9 +43,10 @@ install_man(join_paths(lz4_root_dir, 'programs/lz4.1')) InstallSymlink_py = '../InstallSymlink.py' lz4_man1_dir = join_paths(lz4_mandir, 'man1') -man1_EXT = host_machine_os != os_windows ? '.1.gz' : '.1' +bin_EXT = host_machine_os == os_windows ? '.exe' : '' +man1_EXT = '.1.gz' # Meson automatically compresses manpages foreach f : ['lz4c', 'lz4cat', 'unlz4'] - meson.add_install_script(InstallSymlink_py, 'lz4', f, lz4_bindir) + 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/tests/meson.build b/contrib/meson/tests/meson.build index 82e2813..392bcf2 100644 --- a/contrib/meson/tests/meson.build +++ b/contrib/meson/tests/meson.build @@ -15,7 +15,7 @@ lib_dir_inc = include_directories(join_paths(lz4_root_dir, 'lib')) # Test flags # ============================================================================= -TEST_FILES = join_paths(lz4_root_dir, 'tests/COPYING') +TEST_FILES = join_paths(meson.current_source_dir(), lz4_root_dir, 'tests/COPYING') FUZZER_TIME = '-T90s' NB_LOOPS = '-i1' @@ -76,6 +76,18 @@ checkTag = executable('checkTag', # Tests (Use "meson test --list" to list all tests) # ============================================================================= -test('test-fullbench', fullbench, args: ['--no-prompt', NB_LOOPS, TEST_FILES]) -test('test-fuzzer', fuzzer, args: [FUZZER_TIME]) -test('test-frametest', frametest, args: [FUZZER_TIME]) +# 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) |