From f7278087319917339826613cb7d0e1e9ba263f09 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 28 Nov 2018 02:47:04 +0700 Subject: [PATCH 01/41] Minor fix for meson build Use files function instead of constructing path with meson.current_source_dir() --- contrib/meson/contrib/gen_html/meson.build | 2 +- contrib/meson/meson.build | 9 ++++++++- contrib/meson/meson_options.txt | 2 +- contrib/meson/programs/meson.build | 3 --- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/contrib/meson/contrib/gen_html/meson.build b/contrib/meson/contrib/gen_html/meson.build index 086b8f058..38ed52761 100644 --- a/contrib/meson/contrib/gen_html/meson.build +++ b/contrib/meson/contrib/gen_html/meson.build @@ -16,7 +16,7 @@ contrib_gen_html_dir = join_paths(zstd_source_dir, 'contrib', 'gen_html') gen_html_includes = include_directories(programs_dir, library_dir, library_common_dir, - contrib_gen_html_dir ) + contrib_gen_html_dir) gen_html = executable('gen_html', join_paths(contrib_gen_html_dir, 'gen_html.cpp'), diff --git a/contrib/meson/meson.build b/contrib/meson/meson.build index b9ac88281..48f8d570d 100644 --- a/contrib/meson/meson.build +++ b/contrib/meson/meson.build @@ -52,10 +52,17 @@ enable_zlib = get_option('zlib_support') enable_lzma = get_option('lzma_support') # ============================================================================= -# Getting project version from zstd.h +# Helper scripts for Meson # ============================================================================= GetZstdLibraryVersion_py = files('GetZstdLibraryVersion.py') +CreateSymlink_py = files('CreateSymlink.py') +CopyFile_py = files('CopyFile.py') + +# ============================================================================= +# Getting project version from zstd.h +# ============================================================================= + zstd_h_file = join_paths(library_dir, 'zstd.h') r = run_command(python3, GetZstdLibraryVersion_py, zstd_h_file) if r.returncode() == 0 diff --git a/contrib/meson/meson_options.txt b/contrib/meson/meson_options.txt index 1d28c71a8..6e9358576 100644 --- a/contrib/meson/meson_options.txt +++ b/contrib/meson/meson_options.txt @@ -9,7 +9,7 @@ # ############################################################################# option('multithread_support', type: 'boolean', value: true, - description: 'Enable multithreading when pthread is detected') + description: 'Enable multi-threading when pthread is detected') option('legacy_support', type: 'string', value: '4', description: 'Support any legacy format: true or false, or 7 to 1 for v0.7+ to v0.1+') option('build_programs', type: 'boolean', value: true, diff --git a/contrib/meson/programs/meson.build b/contrib/meson/programs/meson.build index 63ea328ae..8130ab152 100644 --- a/contrib/meson/programs/meson.build +++ b/contrib/meson/programs/meson.build @@ -61,8 +61,6 @@ executable('zstd-frugal', # Program symlinks # ============================================================================= -CreateSymlink_py = join_paths(meson.current_source_dir(), '..', 'CreateSymlink.py') - foreach f : [ 'zstdcat', 'unzstd' ] custom_target(f, output : f, @@ -89,7 +87,6 @@ endif zstd_man1_dir = join_paths(zstd_mandir, 'man1') zstd_1_file = join_paths(programs_dir, 'zstd.1') -CopyFile_py = join_paths(meson.current_source_dir(), '..', 'CopyFile.py') custom_target('zstd.1', output : 'zstd.1', From 8a160680d17b9719c4aea275af401a03ddfcb92d Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 28 Nov 2018 11:49:52 +0700 Subject: [PATCH 02/41] Update legacy support to 5 --- contrib/meson/lib/meson.build | 9 ++++----- contrib/meson/meson_options.txt | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/contrib/meson/lib/meson.build b/contrib/meson/lib/meson.build index b5d6778dd..bc0220584 100644 --- a/contrib/meson/lib/meson.build +++ b/contrib/meson/lib/meson.build @@ -58,7 +58,7 @@ if legacy_support == '0' endif if legacy_support != 'false' if legacy_support == 'true' - legacy_support = '1' + legacy_support = '5' endif legacy_int = legacy_support.to_int() if legacy_int < 0 or legacy_int >= 8 @@ -108,12 +108,11 @@ libzstd = library('zstd', soversion: '1') pkgconfig.generate(name: 'libzstd', - description: 'fast lossless compression algorithm library', - version: zstd_version, filebase: 'libzstd', libraries: [libzstd], - #subdirs: ['.'] - ) + description: 'fast lossless compression algorithm library', + version: zstd_version, + url: 'http://www.zstd.net/') install_headers(join_paths(library_dir, 'zstd.h'), join_paths(library_deprecated_dir, 'zbuff.h'), diff --git a/contrib/meson/meson_options.txt b/contrib/meson/meson_options.txt index 6e9358576..066be6a32 100644 --- a/contrib/meson/meson_options.txt +++ b/contrib/meson/meson_options.txt @@ -10,7 +10,7 @@ option('multithread_support', type: 'boolean', value: true, description: 'Enable multi-threading when pthread is detected') -option('legacy_support', type: 'string', value: '4', +option('legacy_support', type: 'string', value: '5', description: 'Support any legacy format: true or false, or 7 to 1 for v0.7+ to v0.1+') option('build_programs', type: 'boolean', value: true, description: 'Enable programs build') From 5a36a57cf5b710d82679cffd64f51080c14fe4c0 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 28 Nov 2018 11:57:53 +0700 Subject: [PATCH 03/41] Bump to 1.3.8 and fix run_command function The run_command is run from an unspecified directory. Therefore we cannot assume which directory it is running our command. --- contrib/meson/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/meson/meson.build b/contrib/meson/meson.build index 48f8d570d..bd7eeff73 100644 --- a/contrib/meson/meson.build +++ b/contrib/meson/meson.build @@ -14,7 +14,7 @@ project('zstd', default_options : ['c_std=c99', 'cpp_std=c++11', 'buildtype=release'], - version: '1.3.7', + version: '1.3.8', # for install_man meson_version: '>=0.47.0') @@ -63,7 +63,7 @@ CopyFile_py = files('CopyFile.py') # Getting project version from zstd.h # ============================================================================= -zstd_h_file = join_paths(library_dir, 'zstd.h') +zstd_h_file = join_paths(meson.current_source_dir(), library_dir, 'zstd.h') r = run_command(python3, GetZstdLibraryVersion_py, zstd_h_file) if r.returncode() == 0 output = r.stdout().strip() From c9f01443027a40ff0153df94968d6f221d3efb2b Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 28 Nov 2018 12:16:09 +0700 Subject: [PATCH 04/41] Fix meson tests build --- contrib/meson/meson.build | 1 + contrib/meson/tests/meson.build | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/contrib/meson/meson.build b/contrib/meson/meson.build index bd7eeff73..1e0a2ec40 100644 --- a/contrib/meson/meson.build +++ b/contrib/meson/meson.build @@ -103,6 +103,7 @@ endif # ============================================================================= subdir('lib') + if enable_programs subdir('programs') endif diff --git a/contrib/meson/tests/meson.build b/contrib/meson/tests/meson.build index cc9e1ee10..c64ae7a7a 100644 --- a/contrib/meson/tests/meson.build +++ b/contrib/meson/tests/meson.build @@ -31,7 +31,7 @@ fullbench_sources = [datagen_c_file, util_c_file, benchfn_c_file, join_paths(programs_dir, 'benchzstd.c'), - join_paths(programs_dir, 'fullbench.c')] + join_paths(tests_dir, 'fullbench.c')] fullbench = executable('fullbench', fullbench_sources, include_directories: test_includes, @@ -49,10 +49,10 @@ fuzzer = executable('fuzzer', install: false) test('fuzzer', fuzzer) -paramgrill_sources = [benchfn_c_file +paramgrill_sources = [benchfn_c_file, join_paths(programs_dir, 'benchzstd.c'), - datagen_c_file - util_c_file + datagen_c_file, + util_c_file, join_paths(tests_dir, 'paramgrill.c')] if host_machine.system() != 'windows' paramgrill = executable('paramgrill', @@ -60,6 +60,6 @@ if host_machine.system() != 'windows' include_directories: test_includes, link_with: libzstd, dependencies: libm_dep, - install: false ) + install: false) test('paramgrill', paramgrill) endif From 337f914dc8e551916b164ddbb91dd77ac9afffbd Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 28 Nov 2018 14:26:57 +0700 Subject: [PATCH 05/41] Fix lib soversion and no install cover.h header --- contrib/meson/lib/meson.build | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contrib/meson/lib/meson.build b/contrib/meson/lib/meson.build index bc0220584..0c8a750a6 100644 --- a/contrib/meson/lib/meson.build +++ b/contrib/meson/lib/meson.build @@ -67,7 +67,7 @@ if legacy_support != 'false' add_project_arguments('-DZSTD_LEGACY_SUPPORT=@0@'.format(legacy_int), language: 'c') libzstd_includes += [ include_directories(library_legacy_dir) ] - # See ZSTD_LEGACY_SUPPORT of programs/README.md + # See ZSTD_LEGACY_SUPPORT of lib/README.md message('Enable legacy support back to version 0.@0@'.format(legacy_int)) if legacy_int <= 1 libzstd_sources += join_paths(library_legacy_dir, 'zstd_v01.c') @@ -105,7 +105,7 @@ libzstd = library('zstd', include_directories: libzstd_includes, dependencies: libzstd_deps, install: true, - soversion: '1') + soversion: zstd_version) pkgconfig.generate(name: 'libzstd', filebase: 'libzstd', @@ -117,5 +117,4 @@ pkgconfig.generate(name: 'libzstd', install_headers(join_paths(library_dir, 'zstd.h'), join_paths(library_deprecated_dir, 'zbuff.h'), join_paths(library_dictbuilder_dir, 'zdict.h'), - join_paths(library_dictbuilder_dir, 'cover.h'), join_paths(library_common_dir, 'zstd_errors.h')) From 0a25b13aae4c1c669e5ea7ced3fe687b1d255c71 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 28 Nov 2018 13:06:18 +0700 Subject: [PATCH 06/41] Init CI test for meson build Do not use ccache: Build error in gcc-8 --- .travis.yml | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 226acaa37..777e5ad86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,13 @@ language: c dist: trusty sudo: required + addons: apt: update: true matrix: + fast_finish: true include: # Ubuntu 14.04 - env: Cmd='make test' @@ -49,6 +51,10 @@ matrix: - if: tag =~ ^v[0-9]\.[0-9] env: Cmd='make -C tests checkTag && tests/checkTag $TRAVIS_BRANCH' + - env: INSTALL_SYSTEM='meson' + allow_failures: + - env: INSTALL_SYSTEM='meson' + git: depth: 1 @@ -59,9 +65,25 @@ branches: - travisTest script: - - JOB_NUMBER=$(echo $TRAVIS_JOB_NUMBER | sed -e 's:[0-9][0-9]*\.\(.*\):\1:') - - echo JOB_NUMBER=$JOB_NUMBER TRAVIS_BRANCH=$TRAVIS_BRANCH TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST - - export FUZZERTEST=-T2mn; - export ZSTREAM_TESTTIME=-T2mn; - export DECODECORPUS_TESTTIME=-T1mn; - sh -c "$Cmd" || travis_terminate 1; + - JOB_NUMBER=$(printf '%s' "${TRAVIS_JOB_NUMBER}" | sed -E 's@[0-9]+\.([0-9]+)@\1@') + - printf 'JOB_NUMBER=%s TRAVIS_BRANCH=%s TRAVIS_EVENT_TYPE=%s TRAVIS_PULL_REQUEST=%s\n' + "${JOB_NUMBER}" "${TRAVIS_BRANCH}" "${TRAVIS_EVENT_TYPE}" "${TRAVIS_PULL_REQUEST}" + - if [ "${INSTALL_SYSTEM}" = meson ]; then + sudo apt-get install -qq python3.5 wget tree + && wget https://bootstrap.pypa.io/get-pip.py + && python3.5 get-pip.py --user + && rm get-pip.py + && pip3.5 install --user meson ninja; + mkdir contrib/meson/build; + pushd "$_"; + meson --buildtype=debug -Dbuild_contrib=true -Dbuild_tests=true .. + && ninja + && DESTDIR=./staging ninja install + && tree ./staging; + popd; + else + export FUZZERTEST=-T2mn; + export ZSTREAM_TESTTIME=-T2mn; + export DECODECORPUS_TESTTIME=-T1mn; + sh -c "${Cmd}" || travis_terminate 1; + fi From 3175188407ea8d02587f4c3bc0137af22876d42d Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 28 Nov 2018 21:59:35 +0700 Subject: [PATCH 07/41] No need these helpers --- contrib/meson/CopyFile.py | 35 --------------------------------- contrib/meson/CreateSymlink.py | 36 ---------------------------------- 2 files changed, 71 deletions(-) delete mode 100644 contrib/meson/CopyFile.py delete mode 100644 contrib/meson/CreateSymlink.py diff --git a/contrib/meson/CopyFile.py b/contrib/meson/CopyFile.py deleted file mode 100644 index 6c0288ee4..000000000 --- a/contrib/meson/CopyFile.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python3 -# ############################################################################# -# Copyright (c) 2018-present lzutao -# 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 os -import sys -import shutil - - -def usage(): - print('usage: python3 CreateSymlink.py ') - print('Copy the file named src to a file named dst') - sys.exit(1) - - -def main(): - if len(sys.argv) < 3: - usage() - src = sys.argv[1] - dst = sys.argv[2] - - if os.path.exists(dst): - print ('File already exists: %r' % (dst)) - return - - shutil.copy2(src, dst) - - -if __name__ == '__main__': - main() diff --git a/contrib/meson/CreateSymlink.py b/contrib/meson/CreateSymlink.py deleted file mode 100644 index d0f9918ab..000000000 --- a/contrib/meson/CreateSymlink.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python3 -# ############################################################################# -# Copyright (c) 2018-present lzutao -# 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 os -import sys - - -def usage(): - print('usage: python3 CreateSymlink.py [dst is dir: True or False]') - sys.exit(1) - - -def main(): - if len(sys.argv) < 3: - usage() - src = sys.argv[1] - dst = sys.argv[2] - is_dir = False - if len(sys.argv) == 4: - is_dir = bool(sys.argv[3]) - - if os.path.islink(dst) and os.readlink(dst) == src: - print ('File exists: %r -> %r' % (dst, src)) - return - - os.symlink(src, dst, is_dir) - - -if __name__ == '__main__': - main() From ef2e76193710797101c133ed73119d553448abcc Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 28 Nov 2018 22:31:16 +0700 Subject: [PATCH 08/41] Helper script to install symlink in meson --- contrib/meson/InstallSymlink.py | 72 +++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 contrib/meson/InstallSymlink.py diff --git a/contrib/meson/InstallSymlink.py b/contrib/meson/InstallSymlink.py new file mode 100644 index 000000000..d7b1e5a0b --- /dev/null +++ b/contrib/meson/InstallSymlink.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +# ############################################################################# +# Copyright (c) 2018-present lzutao +# 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 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 + + +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) + + 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)) + return + print('Installing symlink %r -> %r' % (new_dst, src)) + os.symlink(src, new_dst, 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' + 'example:\n' + '\tInstallSymlink.py libcrypto.so.1.0.0 libcrypt.so ' + '/usr/lib/x86_64-linux-gnu False') + parser.add_argument('src', help='target to link') + parser.add_argument('dst', help='link name') + parser.add_argument('install_dir', help='installation directory') + parser.add_argument('-d', '--isdir', + action='store_true', + help='dst is a directory') + parser.add_argument('-m', '--mode', + help='directory mode on creating if not exist', + default='0o777') + args = parser.parse_args() + + src = args.src + dst = args.dst + install_dir = args.install_dir + dst_is_dir = args.isdir + dir_mode = int(args.mode, 8) + + 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) + + +if __name__ == '__main__': + main() From d79df2a370897dea8dad7457f3e35fe92d003f6a Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 28 Nov 2018 22:32:37 +0700 Subject: [PATCH 09/41] Apply new InstallSymlink script --- contrib/meson/meson.build | 2 -- contrib/meson/programs/meson.build | 45 ++++++------------------------ 2 files changed, 9 insertions(+), 38 deletions(-) diff --git a/contrib/meson/meson.build b/contrib/meson/meson.build index 1e0a2ec40..065c5e1b9 100644 --- a/contrib/meson/meson.build +++ b/contrib/meson/meson.build @@ -56,8 +56,6 @@ enable_lzma = get_option('lzma_support') # ============================================================================= GetZstdLibraryVersion_py = files('GetZstdLibraryVersion.py') -CreateSymlink_py = files('CreateSymlink.py') -CopyFile_py = files('CopyFile.py') # ============================================================================= # Getting project version from zstd.h diff --git a/contrib/meson/programs/meson.build b/contrib/meson/programs/meson.build index 8130ab152..b29c31217 100644 --- a/contrib/meson/programs/meson.build +++ b/contrib/meson/programs/meson.build @@ -61,24 +61,12 @@ executable('zstd-frugal', # Program symlinks # ============================================================================= -foreach f : [ 'zstdcat', 'unzstd' ] - custom_target(f, - output : f, - input: zstd, - command : [python3, CreateSymlink_py, '@PLAINNAME@', '@OUTPUT@'], - build_always_stale: false, - install : true, - install_dir: zstd_bindir) -endforeach +InstallSymlink_py = join_paths('..', 'InstallSymlink.py') +meson.add_install_script(InstallSymlink_py, 'zstd', 'zstdcat', zstd_bindir) +meson.add_install_script(InstallSymlink_py, 'zstd', 'unzstd', zstd_bindir) if enable_multithread - custom_target('zstdmt', - output : 'zstdmt', - input: zstd, - command : [python3, CreateSymlink_py, '@PLAINNAME@', '@OUTPUT@'], - build_always_stale: false, - install : true, - install_dir: zstd_bindir) + meson.add_install_script(InstallSymlink_py, 'zstd', 'zstdmt', zstd_bindir) endif # ============================================================================= @@ -86,25 +74,10 @@ endif # ============================================================================= zstd_man1_dir = join_paths(zstd_mandir, 'man1') -zstd_1_file = join_paths(programs_dir, 'zstd.1') -custom_target('zstd.1', - output : 'zstd.1', - input: zstd_1_file, - command : [python3, CopyFile_py, '@INPUT@', '@OUTPUT@'], - build_always_stale: false, - install : true, - install_dir: zstd_man1_dir) - -foreach f : [ 'zstdcat.1', 'unzstd.1' ] - custom_target(f, - output : f, - input: zstd_1_file, - command : [python3, CreateSymlink_py, '@PLAINNAME@', '@OUTPUT@'], - install : true, - build_always_stale: false, - install_dir: zstd_man1_dir) -endforeach - -install_man(join_paths(programs_dir, 'zstdgrep.1'), +install_man(join_paths(programs_dir, 'zstd.1'), + join_paths(programs_dir, 'zstdgrep.1'), join_paths(programs_dir, 'zstdless.1')) + +meson.add_install_script(InstallSymlink_py, 'zstd.1', 'zstdcat.1', zstd_man1_dir) +meson.add_install_script(InstallSymlink_py, 'zstd.1', 'unzstd.1', zstd_man1_dir) From 9c862c6a53fe60aaa5ba6424081e8d07c66460be Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 28 Nov 2018 23:59:42 +0700 Subject: [PATCH 10/41] Fix manpage symlinks [skip ci] --- contrib/meson/contrib/gen_html/meson.build | 8 +++----- contrib/meson/programs/meson.build | 5 +++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/contrib/meson/contrib/gen_html/meson.build b/contrib/meson/contrib/gen_html/meson.build index 38ed52761..d9185dfe4 100644 --- a/contrib/meson/contrib/gen_html/meson.build +++ b/contrib/meson/contrib/gen_html/meson.build @@ -21,16 +21,14 @@ gen_html_includes = include_directories(programs_dir, gen_html = executable('gen_html', join_paths(contrib_gen_html_dir, 'gen_html.cpp'), include_directories: gen_html_includes, - install: false ) + install: false) # Update zstd manual zstd_manual_html = custom_target('zstd_manual.html', output : 'zstd_manual.html', - command : [ - gen_html, + command : [gen_html, zstd_version, join_paths(meson.current_source_dir(), library_dir, 'zstd.h'), - '@OUTPUT@' - ], + '@OUTPUT@'], install : true, install_dir : zstd_docdir ) diff --git a/contrib/meson/programs/meson.build b/contrib/meson/programs/meson.build index b29c31217..1c77f7480 100644 --- a/contrib/meson/programs/meson.build +++ b/contrib/meson/programs/meson.build @@ -79,5 +79,6 @@ install_man(join_paths(programs_dir, 'zstd.1'), join_paths(programs_dir, 'zstdgrep.1'), join_paths(programs_dir, 'zstdless.1')) -meson.add_install_script(InstallSymlink_py, 'zstd.1', 'zstdcat.1', zstd_man1_dir) -meson.add_install_script(InstallSymlink_py, 'zstd.1', 'unzstd.1', zstd_man1_dir) +# Meson automatically compresses manpages to gz format +meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'zstdcat.1.gz', zstd_man1_dir) +meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'unzstd.1.gz', zstd_man1_dir) From 1985e427c70d1fa9454d83380d6427594ee5e180 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Nov 2018 00:09:24 +0700 Subject: [PATCH 11/41] Add manpage install warning [skip ci] We link new manpages with gz compressed format of the target manpage. I have not tested it on Windows. So just place a warning here. --- contrib/meson/programs/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/meson/programs/meson.build b/contrib/meson/programs/meson.build index 1c77f7480..59cf09a05 100644 --- a/contrib/meson/programs/meson.build +++ b/contrib/meson/programs/meson.build @@ -80,5 +80,6 @@ install_man(join_paths(programs_dir, 'zstd.1'), join_paths(programs_dir, 'zstdless.1')) # Meson automatically compresses manpages to gz format +# WARNING: This may fail on Windows. Test NEEDED. meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'zstdcat.1.gz', zstd_man1_dir) meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'unzstd.1.gz', zstd_man1_dir) From d3134a3ed3674088e952813945bf1b7c9c4b73f8 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Nov 2018 01:26:41 +0700 Subject: [PATCH 12/41] Rename meson variables --- contrib/meson/meson.build | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/contrib/meson/meson.build b/contrib/meson/meson.build index 065c5e1b9..a8df86b85 100644 --- a/contrib/meson/meson.build +++ b/contrib/meson/meson.build @@ -86,14 +86,14 @@ lzma_dep = dependency('lzma', required: false) if cxx.get_id() == 'gcc' or cxx.get_id() == 'clang' common_flags = [ '-DXXH_NAMESPACE=ZSTD_' ] - zstd_compilation_flags = [ '-Wextra', '-Wundef', '-Wshadow', '-Wcast-align', '-Wcast-qual' ] - cc_common_flags = cc.get_supported_arguments(zstd_compilation_flags) - cc_common_flags += cc.get_supported_arguments(['-Wstrict-prototypes']) - cc_common_flags += common_flags - cxx_common_flags = cxx.get_supported_arguments(zstd_compilation_flags) - cxx_common_flags += common_flags - add_project_arguments(cc_common_flags, language : 'c') - add_project_arguments(cxx_common_flags, language : 'cpp') + common_warning_flags = [ '-Wextra', '-Wundef', '-Wshadow', '-Wcast-align', '-Wcast-qual' ] + cc_compilation_flags = cc.get_supported_arguments(common_warning_flags) + cc_compilation_flags += cc.get_supported_arguments(['-Wstrict-prototypes']) + cc_compilation_flags += common_flags + cxx_compilation_flags = cxx.get_supported_arguments(common_warning_flags) + cxx_compilation_flags += common_flags + add_project_arguments(cc_compilation_flags, language : 'c') + add_project_arguments(cxx_compilation_flags, language : 'cpp') endif # ============================================================================= From 3f27e2a072638bf74d986644087d11c0a7c541cc Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Nov 2018 01:27:20 +0700 Subject: [PATCH 13/41] Install zstdmt.1 manpage [skip ci] --- contrib/meson/programs/meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/meson/programs/meson.build b/contrib/meson/programs/meson.build index 59cf09a05..ba47e0f97 100644 --- a/contrib/meson/programs/meson.build +++ b/contrib/meson/programs/meson.build @@ -83,3 +83,7 @@ install_man(join_paths(programs_dir, 'zstd.1'), # WARNING: This may fail on Windows. Test NEEDED. meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'zstdcat.1.gz', zstd_man1_dir) meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'unzstd.1.gz', zstd_man1_dir) + +if enable_multithread + meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'zstdmt.1.gz', zstd_man1_dir) +endif From f660825d9fd45050e9abb82ec99a53c0c7aacf78 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Nov 2018 01:50:24 +0700 Subject: [PATCH 14/41] Install missed zstdgrep and zstdless --- contrib/meson/programs/meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/meson/programs/meson.build b/contrib/meson/programs/meson.build index ba47e0f97..e9f1c518d 100644 --- a/contrib/meson/programs/meson.build +++ b/contrib/meson/programs/meson.build @@ -57,6 +57,10 @@ executable('zstd-frugal', c_args: [ '-DZSTD_NOBENCH', '-DZSTD_NODICT' ], install: true) +install_data(join_paths(programs_dir, 'zstdgrep'), + join_paths(programs_dir, 'zstdless'), + install_dir: zstd_bindir) + # ============================================================================= # Program symlinks # ============================================================================= From 6f3f1a8d3a5398c1f403d25659baa679181dbe80 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Nov 2018 10:54:01 +0700 Subject: [PATCH 15/41] No install zstd_manual.html --- contrib/meson/contrib/gen_html/meson.build | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/meson/contrib/gen_html/meson.build b/contrib/meson/contrib/gen_html/meson.build index d9185dfe4..9f02baf6e 100644 --- a/contrib/meson/contrib/gen_html/meson.build +++ b/contrib/meson/contrib/gen_html/meson.build @@ -30,5 +30,4 @@ zstd_manual_html = custom_target('zstd_manual.html', zstd_version, join_paths(meson.current_source_dir(), library_dir, 'zstd.h'), '@OUTPUT@'], - install : true, - install_dir : zstd_docdir ) + install : false) From 5c4965c351f3acfaebbe1297fddd729bd533997b Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Nov 2018 10:54:29 +0700 Subject: [PATCH 16/41] Add pedantic flag --- contrib/meson/contrib/pzstd/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/meson/contrib/pzstd/meson.build b/contrib/meson/contrib/pzstd/meson.build index 923990145..3531ace7d 100644 --- a/contrib/meson/contrib/pzstd/meson.build +++ b/contrib/meson/contrib/pzstd/meson.build @@ -25,7 +25,7 @@ pzstd_sources = [join_paths(programs_dir, 'util.c'), pzstd = executable('pzstd', pzstd_sources, - cpp_args: [ '-DNDEBUG', '-Wno-shadow' ], + cpp_args: [ '-DNDEBUG', '-Wno-shadow', '-pedantic' ], include_directories: pzstd_includes, link_with: libzstd, dependencies: [ thread_dep ], From c0e71cae554bf20054eb5623c33154c2002a1bfd Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Nov 2018 11:05:40 +0700 Subject: [PATCH 17/41] Add enable_lz4 build option and fix lzma dependency --- contrib/meson/meson.build | 4 +++- contrib/meson/meson_options.txt | 2 ++ contrib/meson/programs/meson.build | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/contrib/meson/meson.build b/contrib/meson/meson.build index a8df86b85..966c5008e 100644 --- a/contrib/meson/meson.build +++ b/contrib/meson/meson.build @@ -50,6 +50,7 @@ enable_contrib = get_option('build_contrib') enable_multithread = get_option('multithread_support') enable_zlib = get_option('zlib_support') enable_lzma = get_option('lzma_support') +enable_lz4 = get_option('lz4_support') # ============================================================================= # Helper scripts for Meson @@ -78,7 +79,8 @@ endif libm_dep = cc.find_library('m', required: true) thread_dep = dependency('threads', required: false) zlib_dep = dependency('zlib', required: false) -lzma_dep = dependency('lzma', required: false) +lzma_dep = dependency('liblzma', required: false) +lz4_dep = dependency('liblz4', required: false) # ============================================================================= # Compiler flags diff --git a/contrib/meson/meson_options.txt b/contrib/meson/meson_options.txt index 066be6a32..86a36523a 100644 --- a/contrib/meson/meson_options.txt +++ b/contrib/meson/meson_options.txt @@ -24,3 +24,5 @@ option('zlib_support', type: 'boolean', value: false, description: 'Enable zlib support') option('lzma_support', type: 'boolean', value: false, description: 'Enable lzma support') +option('lz4_support', type: 'boolean', value: false, + description: 'Enable lz4 support') diff --git a/contrib/meson/programs/meson.build b/contrib/meson/programs/meson.build index e9f1c518d..c96b6d458 100644 --- a/contrib/meson/programs/meson.build +++ b/contrib/meson/programs/meson.build @@ -38,6 +38,11 @@ if enable_lzma and lzma_dep.found() zstd_c_args += [ '-DZSTD_LZMACOMPRESS', '-DZSTD_LZMADECOMPRESS' ] endif +if enable_lz4 and lz4_dep.found() + zstd_deps += [ lz4_dep ] + zstd_c_args += [ '-DZSTD_LZ4COMPRESS', '-DZSTD_LZ4DECOMPRESS' ] +endif + zstd = executable('zstd', zstd_programs_sources, c_args: zstd_c_args, From beb13bd87ebea7e3f7bafaed8696e91f5359c649 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Nov 2018 11:45:57 +0700 Subject: [PATCH 18/41] Move contrib/meson to build/meson --- {contrib => build}/meson/GetZstdLibraryVersion.py | 0 {contrib => build}/meson/InstallSymlink.py | 0 {contrib => build}/meson/README.md | 0 {contrib => build}/meson/contrib/gen_html/meson.build | 0 {contrib => build}/meson/contrib/meson.build | 0 {contrib => build}/meson/contrib/pzstd/meson.build | 0 {contrib => build}/meson/lib/meson.build | 0 {contrib => build}/meson/meson.build | 0 {contrib => build}/meson/meson_options.txt | 0 {contrib => build}/meson/programs/meson.build | 0 {contrib => build}/meson/tests/meson.build | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename {contrib => build}/meson/GetZstdLibraryVersion.py (100%) rename {contrib => build}/meson/InstallSymlink.py (100%) rename {contrib => build}/meson/README.md (100%) rename {contrib => build}/meson/contrib/gen_html/meson.build (100%) rename {contrib => build}/meson/contrib/meson.build (100%) rename {contrib => build}/meson/contrib/pzstd/meson.build (100%) rename {contrib => build}/meson/lib/meson.build (100%) rename {contrib => build}/meson/meson.build (100%) rename {contrib => build}/meson/meson_options.txt (100%) rename {contrib => build}/meson/programs/meson.build (100%) rename {contrib => build}/meson/tests/meson.build (100%) diff --git a/contrib/meson/GetZstdLibraryVersion.py b/build/meson/GetZstdLibraryVersion.py similarity index 100% rename from contrib/meson/GetZstdLibraryVersion.py rename to build/meson/GetZstdLibraryVersion.py diff --git a/contrib/meson/InstallSymlink.py b/build/meson/InstallSymlink.py similarity index 100% rename from contrib/meson/InstallSymlink.py rename to build/meson/InstallSymlink.py diff --git a/contrib/meson/README.md b/build/meson/README.md similarity index 100% rename from contrib/meson/README.md rename to build/meson/README.md diff --git a/contrib/meson/contrib/gen_html/meson.build b/build/meson/contrib/gen_html/meson.build similarity index 100% rename from contrib/meson/contrib/gen_html/meson.build rename to build/meson/contrib/gen_html/meson.build diff --git a/contrib/meson/contrib/meson.build b/build/meson/contrib/meson.build similarity index 100% rename from contrib/meson/contrib/meson.build rename to build/meson/contrib/meson.build diff --git a/contrib/meson/contrib/pzstd/meson.build b/build/meson/contrib/pzstd/meson.build similarity index 100% rename from contrib/meson/contrib/pzstd/meson.build rename to build/meson/contrib/pzstd/meson.build diff --git a/contrib/meson/lib/meson.build b/build/meson/lib/meson.build similarity index 100% rename from contrib/meson/lib/meson.build rename to build/meson/lib/meson.build diff --git a/contrib/meson/meson.build b/build/meson/meson.build similarity index 100% rename from contrib/meson/meson.build rename to build/meson/meson.build diff --git a/contrib/meson/meson_options.txt b/build/meson/meson_options.txt similarity index 100% rename from contrib/meson/meson_options.txt rename to build/meson/meson_options.txt diff --git a/contrib/meson/programs/meson.build b/build/meson/programs/meson.build similarity index 100% rename from contrib/meson/programs/meson.build rename to build/meson/programs/meson.build diff --git a/contrib/meson/tests/meson.build b/build/meson/tests/meson.build similarity index 100% rename from contrib/meson/tests/meson.build rename to build/meson/tests/meson.build From 0669392937c5161d52247c118687318daf09f8e1 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Nov 2018 11:49:33 +0700 Subject: [PATCH 19/41] Update relevant files after moving meson to build/ Update meson build instructions --- .travis.yml | 2 +- README.md | 2 +- build/meson/README.md | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 777e5ad86..dbea289f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -74,7 +74,7 @@ script: && python3.5 get-pip.py --user && rm get-pip.py && pip3.5 install --user meson ninja; - mkdir contrib/meson/build; + mkdir build/meson/build; pushd "$_"; meson --buildtype=debug -Dbuild_contrib=true -Dbuild_tests=true .. && ninja diff --git a/README.md b/README.md index dc99dc0fd..c0b550572 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ By default, `CMAKE_BUILD_TYPE` is set to `Release`. #### Meson -A Meson project is provided within `contrib/meson`. +A Meson project is provided within `build/meson`. #### Visual Studio (Windows) diff --git a/build/meson/README.md b/build/meson/README.md index a2730faaa..f5818cc69 100644 --- a/build/meson/README.md +++ b/build/meson/README.md @@ -1,16 +1,23 @@ -This Meson project is provided with no guarantee and maintained +contrib/meson - Meson build system for zstandard +================================================ + +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 and maintained by Dima Krasner . It outputs one `libzstd`, either shared or static, depending on `default_library` option. -How to build -============ +## How to build -`cd` to this meson directory (`zstd/contrib/meson`) and type: +`cd` to this meson directory (`build/meson`) ```sh -meson --buildtype=release --strip --prefix=/usr builddir +meson --buildtype=release -D with-contrib=true -D with-tests=true -D with-contrib=true builddir cd builddir ninja # to build ninja install # to install @@ -22,7 +29,7 @@ You might want to install it in staging directory: DESTDIR=./staging ninja install ``` -To configure the build, use: +To configure build options, use: ```sh meson configure From 9ac9cbc9de892c5d960858a1249a99e1f39ed104 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Nov 2018 12:24:43 +0700 Subject: [PATCH 20/41] Enable debugging flag --- build/meson/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/meson/meson.build b/build/meson/meson.build index 966c5008e..18f44e0af 100644 --- a/build/meson/meson.build +++ b/build/meson/meson.build @@ -42,7 +42,7 @@ contrib_meson_dir = join_paths(zstd_source_dir, 'contrib', 'meson') # ============================================================================= # Project options # ============================================================================= - +enable_debug = get_option('debug') legacy_support = get_option('legacy_support') enable_programs = get_option('build_programs') enable_tests = get_option('build_tests') From 918e0d5c3668937ce10b7a971fe383b6eb2c03ad Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Nov 2018 12:52:35 +0700 Subject: [PATCH 21/41] Rename some meson build options to match autoconf convention --- .travis.yml | 2 +- build/meson/lib/meson.build | 12 ++++++------ build/meson/meson.build | 23 ++++++++++++----------- build/meson/meson_options.txt | 18 +++++++++--------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index dbea289f6..54d8e431a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -76,7 +76,7 @@ script: && pip3.5 install --user meson ninja; mkdir build/meson/build; pushd "$_"; - meson --buildtype=debug -Dbuild_contrib=true -Dbuild_tests=true .. + meson --buildtype=debug -D with-contrib=true -D with-tests=true -D with-contrib=true .. && ninja && DESTDIR=./staging ninja install && tree ./staging; diff --git a/build/meson/lib/meson.build b/build/meson/lib/meson.build index 0c8a750a6..8a693dc71 100644 --- a/build/meson/lib/meson.build +++ b/build/meson/lib/meson.build @@ -53,14 +53,14 @@ libzstd_sources = [join_paths(library_common_dir, 'entropy_common.c'), join_paths(library_deprecated_dir, 'zbuff_compress.c'), join_paths(library_deprecated_dir, 'zbuff_decompress.c')] -if legacy_support == '0' - legacy_support = 'false' +if with_legacy_support == '0' + with_legacy_support = 'false' endif -if legacy_support != 'false' - if legacy_support == 'true' - legacy_support = '5' +if with_legacy_support != 'false' + if with_legacy_support == 'true' + with_legacy_support = '5' endif - legacy_int = legacy_support.to_int() + legacy_int = with_legacy_support.to_int() if legacy_int < 0 or legacy_int >= 8 legacy_int = 0 endif diff --git a/build/meson/meson.build b/build/meson/meson.build index 18f44e0af..7b9b2520e 100644 --- a/build/meson/meson.build +++ b/build/meson/meson.build @@ -42,15 +42,16 @@ contrib_meson_dir = join_paths(zstd_source_dir, 'contrib', 'meson') # ============================================================================= # Project options # ============================================================================= + enable_debug = get_option('debug') -legacy_support = get_option('legacy_support') -enable_programs = get_option('build_programs') -enable_tests = get_option('build_tests') -enable_contrib = get_option('build_contrib') -enable_multithread = get_option('multithread_support') -enable_zlib = get_option('zlib_support') -enable_lzma = get_option('lzma_support') -enable_lz4 = get_option('lz4_support') +with_legacy_support = get_option('with-legacy-support') +with_programs = get_option('with-programs') +with_tests = get_option('with-tests') +with_contrib = get_option('with-contrib') +enable_multithread = get_option('enable-multithread') +enable_zlib = get_option('enable-zlib') +enable_lzma = get_option('enable-lzma') +enable_lz4 = get_option('enable-lz4') # ============================================================================= # Helper scripts for Meson @@ -104,14 +105,14 @@ endif subdir('lib') -if enable_programs +if with_programs subdir('programs') endif -if enable_tests +if with_tests subdir('tests') endif -if enable_contrib +if with_contrib subdir('contrib') endif diff --git a/build/meson/meson_options.txt b/build/meson/meson_options.txt index 86a36523a..dca6df809 100644 --- a/build/meson/meson_options.txt +++ b/build/meson/meson_options.txt @@ -8,21 +8,21 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# -option('multithread_support', type: 'boolean', value: true, +option('enable-multithread', type: 'boolean', value: true, description: 'Enable multi-threading when pthread is detected') -option('legacy_support', type: 'string', value: '5', +option('with-legacy-support', type: 'string', value: '5', description: 'Support any legacy format: true or false, or 7 to 1 for v0.7+ to v0.1+') -option('build_programs', type: 'boolean', value: true, +option('with-programs', type: 'boolean', value: true, description: 'Enable programs build') -option('build_contrib', type: 'boolean', value: false, +option('with-contrib', type: 'boolean', value: false, description: 'Enable contrib build') -option('build_tests', type: 'boolean', value: false, +option('with-tests', type: 'boolean', value: false, description: 'Enable tests build') -option('use_static_runtime', type: 'boolean', value: false, +option('enable-static-runtime', type: 'boolean', value: false, description: 'Link to static run-time libraries on MSVC') -option('zlib_support', type: 'boolean', value: false, +option('enable-zlib', type: 'boolean', value: false, description: 'Enable zlib support') -option('lzma_support', type: 'boolean', value: false, +option('enable-lzma', type: 'boolean', value: false, description: 'Enable lzma support') -option('lz4_support', type: 'boolean', value: false, +option('enable-lz4', type: 'boolean', value: false, description: 'Enable lz4 support') From c4fb45ffe8c8dae1205de108b2e8727d0b1ffcf7 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Nov 2018 13:15:18 +0700 Subject: [PATCH 22/41] Add comment about looking for dependencies --- build/meson/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/build/meson/meson.build b/build/meson/meson.build index 7b9b2520e..750e841cf 100644 --- a/build/meson/meson.build +++ b/build/meson/meson.build @@ -79,6 +79,7 @@ endif libm_dep = cc.find_library('m', required: true) thread_dep = dependency('threads', required: false) +# Arguments in dependency should be equivalent to those passed to pkg-config zlib_dep = dependency('zlib', required: false) lzma_dep = dependency('liblzma', required: false) lz4_dep = dependency('liblz4', required: false) From 8c59d94d7a5b23dff403628392d0b9fe5f388ca0 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Nov 2018 17:48:18 +0700 Subject: [PATCH 23/41] Build both shared and static lib on CI Rename INSTALL_SYSTEM to BUILD_SYSTEM --- .travis.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 54d8e431a..8a0170e04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,9 +51,9 @@ matrix: - if: tag =~ ^v[0-9]\.[0-9] env: Cmd='make -C tests checkTag && tests/checkTag $TRAVIS_BRANCH' - - env: INSTALL_SYSTEM='meson' + - env: BUILD_SYSTEM='meson' allow_failures: - - env: INSTALL_SYSTEM='meson' + - env: BUILD_SYSTEM='meson' git: depth: 1 @@ -68,7 +68,7 @@ script: - JOB_NUMBER=$(printf '%s' "${TRAVIS_JOB_NUMBER}" | sed -E 's@[0-9]+\.([0-9]+)@\1@') - printf 'JOB_NUMBER=%s TRAVIS_BRANCH=%s TRAVIS_EVENT_TYPE=%s TRAVIS_PULL_REQUEST=%s\n' "${JOB_NUMBER}" "${TRAVIS_BRANCH}" "${TRAVIS_EVENT_TYPE}" "${TRAVIS_PULL_REQUEST}" - - if [ "${INSTALL_SYSTEM}" = meson ]; then + - if [ "${BUILD_SYSTEM}" = meson ]; then sudo apt-get install -qq python3.5 wget tree && wget https://bootstrap.pypa.io/get-pip.py && python3.5 get-pip.py --user @@ -76,7 +76,8 @@ script: && pip3.5 install --user meson ninja; mkdir build/meson/build; pushd "$_"; - meson --buildtype=debug -D with-contrib=true -D with-tests=true -D with-contrib=true .. + meson --buildtype=debug -D with-contrib=true -D with-tests=true + -D with-contrib=true -D default_library=both .. && ninja && DESTDIR=./staging ninja install && tree ./staging; From 2337429e8d270a1d25c10467e6246ce9133478eb Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 30 Nov 2018 11:01:19 +0700 Subject: [PATCH 24/41] Change tabsize --- build/meson/GetZstdLibraryVersion.py | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/build/meson/GetZstdLibraryVersion.py b/build/meson/GetZstdLibraryVersion.py index 364edc5aa..5659a3283 100644 --- a/build/meson/GetZstdLibraryVersion.py +++ b/build/meson/GetZstdLibraryVersion.py @@ -12,34 +12,34 @@ import sys def usage(): - print('usage: python3 GetZstdLibraryVersion.py ') - sys.exit(1) + print('usage: python3 GetZstdLibraryVersion.py ') + sys.exit(1) def find_version(filepath): - version_file_data = None - with open(filepath) as fd: - version_file_data = fd.read() + version_file_data = None + with open(filepath) as fd: + version_file_data = fd.read() - patterns = r"""#\s*define\s+ZSTD_VERSION_MAJOR\s+([0-9]+) + patterns = r"""#\s*define\s+ZSTD_VERSION_MAJOR\s+([0-9]+) #\s*define\s+ZSTD_VERSION_MINOR\s+([0-9]+) #\s*define\s+ZSTD_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 RuntimeError("Unable to find version string.") + regex = re.compile(patterns, re.MULTILINE) + version_match = regex.search(version_file_data) + if version_match: + return version_match.groups() + raise RuntimeError("Unable to find version string.") def main(): - if len(sys.argv) < 2: - usage() + if len(sys.argv) < 2: + usage() - filepath = sys.argv[1] - version_tup = find_version(filepath) - print('.'.join(version_tup)) + filepath = sys.argv[1] + version_tup = find_version(filepath) + print('.'.join(version_tup)) if __name__ == '__main__': - main() + main() From 0a0683f5b2a0c0ed1ecbe6d27f9717c1ca176c5a Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 30 Nov 2018 15:30:45 +0700 Subject: [PATCH 25/41] Initial support for Windows build --- build/meson/contrib/gen_html/meson.build | 32 ++-- build/meson/contrib/pzstd/meson.build | 34 ++-- build/meson/lib/meson.build | 206 ++++++++++++----------- build/meson/meson.build | 88 +++++++--- build/meson/meson_options.txt | 26 +-- build/meson/programs/meson.build | 100 ++++++----- 6 files changed, 269 insertions(+), 217 deletions(-) diff --git a/build/meson/contrib/gen_html/meson.build b/build/meson/contrib/gen_html/meson.build index 9f02baf6e..a2fea9d52 100644 --- a/build/meson/contrib/gen_html/meson.build +++ b/build/meson/contrib/gen_html/meson.build @@ -7,27 +7,23 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# -zstd_source_dir = join_paths('..', '..', '..', '..') -library_dir = join_paths(zstd_source_dir, 'lib') -library_common_dir = join_paths(library_dir, 'common') -programs_dir = join_paths(zstd_source_dir, 'programs') -contrib_gen_html_dir = join_paths(zstd_source_dir, 'contrib', 'gen_html') +zstd_rootdir = '../../../..' -gen_html_includes = include_directories(programs_dir, - library_dir, - library_common_dir, - contrib_gen_html_dir) +gen_html_includes = include_directories(join_paths(zstd_rootdir, 'programs'), + join_paths(zstd_rootdir, 'lib'), + join_paths(zstd_rootdir, 'lib/common'), + join_paths(zstd_rootdir, 'contrib/gen_html')) gen_html = executable('gen_html', - join_paths(contrib_gen_html_dir, 'gen_html.cpp'), - include_directories: gen_html_includes, - install: false) + join_paths(zstd_rootdir, 'contrib/gen_html/gen_html.cpp'), + include_directories: gen_html_includes, + install: false) # Update zstd manual zstd_manual_html = custom_target('zstd_manual.html', - output : 'zstd_manual.html', - command : [gen_html, - zstd_version, - join_paths(meson.current_source_dir(), library_dir, 'zstd.h'), - '@OUTPUT@'], - install : false) + output : 'zstd_manual.html', + command : [gen_html, + zstd_version, + join_paths(meson.current_source_dir(), join_paths(zstd_rootdir, 'lib/zstd.h')), + '@OUTPUT@'], + install : false) diff --git a/build/meson/contrib/pzstd/meson.build b/build/meson/contrib/pzstd/meson.build index 3531ace7d..8f3822fd7 100644 --- a/build/meson/contrib/pzstd/meson.build +++ b/build/meson/contrib/pzstd/meson.build @@ -7,26 +7,18 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# -zstd_source_dir = join_paths('..', '..', '..', '..') -library_dir = join_paths(zstd_source_dir, 'lib') -library_common_dir = join_paths(library_dir, 'common') -programs_dir = join_paths(zstd_source_dir, 'programs') -contrib_pzstd_dir = join_paths(zstd_source_dir, 'contrib', 'pzstd') - -pzstd_includes = include_directories(programs_dir, - library_dir, - library_common_dir, - contrib_pzstd_dir) -pzstd_sources = [join_paths(programs_dir, 'util.c'), - join_paths(contrib_pzstd_dir, 'main.cpp'), - join_paths(contrib_pzstd_dir, 'Options.cpp'), - join_paths(contrib_pzstd_dir, 'Pzstd.cpp'), - join_paths(contrib_pzstd_dir, 'SkippableFrame.cpp')] +zstd_rootdir = '../../../..' +pzstd_includes = include_directories(join_paths(zstd_rootdir, 'programs'), + join_paths(zstd_rootdir, 'contrib/pzstd')) +pzstd_sources = [join_paths(zstd_rootdir, 'programs/util.c'), + join_paths(zstd_rootdir, 'contrib/pzstd/main.cpp'), + join_paths(zstd_rootdir, 'contrib/pzstd/Options.cpp'), + join_paths(zstd_rootdir, 'contrib/pzstd/Pzstd.cpp'), + join_paths(zstd_rootdir, 'contrib/pzstd/SkippableFrame.cpp')] pzstd = executable('pzstd', - pzstd_sources, - cpp_args: [ '-DNDEBUG', '-Wno-shadow', '-pedantic' ], - include_directories: pzstd_includes, - link_with: libzstd, - dependencies: [ thread_dep ], - install: true) + pzstd_sources, + cpp_args: [ '-DNDEBUG', '-Wno-shadow', '-pedantic' ], + include_directories: pzstd_includes, + dependencies: [ libzstd_dep, thread_dep ], + install: true) diff --git a/build/meson/lib/meson.build b/build/meson/lib/meson.build index 8a693dc71..5bfdbb074 100644 --- a/build/meson/lib/meson.build +++ b/build/meson/lib/meson.build @@ -8,113 +8,121 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# -zstd_source_dir = join_paths('..', '..', '..') -library_dir = join_paths(zstd_source_dir, 'lib') -library_common_dir = join_paths(library_dir, 'common') -library_compress_dir = join_paths(library_dir, 'compress') -library_decompress_dir = join_paths(library_dir, 'decompress') -library_dictbuilder_dir = join_paths(library_dir, 'dictBuilder') -library_deprecated_dir = join_paths(library_dir, 'deprecated') -library_legacy_dir = join_paths(library_dir, 'legacy') +zstd_rootdir = '../../..' -libzstd_includes = [include_directories(library_dir, - library_common_dir, - library_compress_dir, - library_decompress_dir, - library_dictbuilder_dir, - library_deprecated_dir)] +libzstd_includes = [include_directories(join_paths(zstd_rootdir,'lib'), + join_paths(zstd_rootdir, 'lib/common'), + join_paths(zstd_rootdir, 'lib/compress'), + join_paths(zstd_rootdir, 'lib/decompress'), + join_paths(zstd_rootdir, 'lib/dictBuilder'), + join_paths(zstd_rootdir, 'lib/deprecated'))] -libzstd_sources = [join_paths(library_common_dir, 'entropy_common.c'), - join_paths(library_common_dir, 'fse_decompress.c'), - join_paths(library_common_dir, 'threading.c'), - join_paths(library_common_dir, 'pool.c'), - join_paths(library_common_dir, 'zstd_common.c'), - join_paths(library_common_dir, 'error_private.c'), - join_paths(library_common_dir, 'xxhash.c'), - join_paths(library_compress_dir, 'hist.c'), - join_paths(library_compress_dir, 'fse_compress.c'), - join_paths(library_compress_dir, 'huf_compress.c'), - join_paths(library_compress_dir, 'zstd_compress.c'), - join_paths(library_compress_dir, 'zstdmt_compress.c'), - join_paths(library_compress_dir, 'zstd_fast.c'), - join_paths(library_compress_dir, 'zstd_double_fast.c'), - join_paths(library_compress_dir, 'zstd_lazy.c'), - join_paths(library_compress_dir, 'zstd_opt.c'), - join_paths(library_compress_dir, 'zstd_ldm.c'), - join_paths(library_decompress_dir, 'huf_decompress.c'), - join_paths(library_decompress_dir, 'zstd_decompress.c'), - join_paths(library_decompress_dir, 'zstd_decompress_block.c'), - join_paths(library_decompress_dir, 'zstd_ddict.c'), - join_paths(library_dictbuilder_dir, 'cover.c'), - join_paths(library_dictbuilder_dir, 'fastcover.c'), - join_paths(library_dictbuilder_dir, 'divsufsort.c'), - join_paths(library_dictbuilder_dir, 'zdict.c'), - join_paths(library_deprecated_dir, 'zbuff_common.c'), - join_paths(library_deprecated_dir, 'zbuff_compress.c'), - join_paths(library_deprecated_dir, 'zbuff_decompress.c')] +libzstd_sources = [join_paths(zstd_rootdir, 'lib/common/entropy_common.c'), + join_paths(zstd_rootdir, 'lib/common/fse_decompress.c'), + join_paths(zstd_rootdir, 'lib/common/threading.c'), + join_paths(zstd_rootdir, 'lib/common/pool.c'), + join_paths(zstd_rootdir, 'lib/common/zstd_common.c'), + join_paths(zstd_rootdir, 'lib/common/error_private.c'), + join_paths(zstd_rootdir, 'lib/common/xxhash.c'), + join_paths(zstd_rootdir, 'lib/compress/hist.c'), + join_paths(zstd_rootdir, 'lib/compress/fse_compress.c'), + join_paths(zstd_rootdir, 'lib/compress/huf_compress.c'), + join_paths(zstd_rootdir, 'lib/compress/zstd_compress.c'), + join_paths(zstd_rootdir, 'lib/compress/zstdmt_compress.c'), + join_paths(zstd_rootdir, 'lib/compress/zstd_fast.c'), + join_paths(zstd_rootdir, 'lib/compress/zstd_double_fast.c'), + join_paths(zstd_rootdir, 'lib/compress/zstd_lazy.c'), + join_paths(zstd_rootdir, 'lib/compress/zstd_opt.c'), + join_paths(zstd_rootdir, 'lib/compress/zstd_ldm.c'), + join_paths(zstd_rootdir, 'lib/decompress/huf_decompress.c'), + join_paths(zstd_rootdir, 'lib/decompress/zstd_decompress.c'), + join_paths(zstd_rootdir, 'lib/decompress/zstd_decompress_block.c'), + join_paths(zstd_rootdir, 'lib/decompress/zstd_ddict.c'), + join_paths(zstd_rootdir, 'lib/dictBuilder/cover.c'), + join_paths(zstd_rootdir, 'lib/dictBuilder/fastcover.c'), + join_paths(zstd_rootdir, 'lib/dictBuilder/divsufsort.c'), + join_paths(zstd_rootdir, 'lib/dictBuilder/zdict.c'), + join_paths(zstd_rootdir, 'lib/deprecated/zbuff_common.c'), + join_paths(zstd_rootdir, 'lib/deprecated/zbuff_compress.c'), + join_paths(zstd_rootdir, 'lib/deprecated/zbuff_decompress.c')] -if with_legacy_support == '0' - with_legacy_support = 'false' -endif -if with_legacy_support != 'false' - if with_legacy_support == 'true' - with_legacy_support = '5' - endif - legacy_int = with_legacy_support.to_int() - if legacy_int < 0 or legacy_int >= 8 - legacy_int = 0 - endif - add_project_arguments('-DZSTD_LEGACY_SUPPORT=@0@'.format(legacy_int), - language: 'c') - libzstd_includes += [ include_directories(library_legacy_dir) ] - # See ZSTD_LEGACY_SUPPORT of lib/README.md - message('Enable legacy support back to version 0.@0@'.format(legacy_int)) - if legacy_int <= 1 - libzstd_sources += join_paths(library_legacy_dir, 'zstd_v01.c') - endif - if legacy_int <= 2 - libzstd_sources += join_paths(library_legacy_dir, 'zstd_v02.c') - endif - if legacy_int <= 3 - libzstd_sources += join_paths(library_legacy_dir, 'zstd_v03.c') - endif - if legacy_int <= 4 - libzstd_sources += join_paths(library_legacy_dir, 'zstd_v04.c') - endif - if legacy_int <= 5 - libzstd_sources += join_paths(library_legacy_dir, 'zstd_v05.c') - endif - if legacy_int <= 6 - libzstd_sources += join_paths(library_legacy_dir, 'zstd_v06.c') - endif - if legacy_int <= 7 - libzstd_sources += join_paths(library_legacy_dir, 'zstd_v07.c') - endif -endif +# Explicit define legacy support +add_project_arguments('-DZSTD_LEGACY_SUPPORT=@0@'.format(with_legacy_support), + language: 'c') -if enable_multithread - message('Enable multi-threading support') - add_project_arguments('-DZSTD_MULTITHREAD', language: 'c') - libzstd_deps = [ thread_dep ] +if with_legacy_support == 0 + message('Legacy support: DISABLED') else - libzstd_deps = [] + # See ZSTD_LEGACY_SUPPORT of lib/README.md + message('Enable legacy support back to version 0.@0@'.format(with_legacy_support)) + + libzstd_includes += [ include_directories(join_paths(zstd_rootdir, 'lib/legacy')) ] + foreach i : [1, 2, 3, 4, 5, 6, 7] + if with_legacy_support <= i + libzstd_sources += join_paths(zstd_rootdir, 'lib/legacy/zstd_v0@0@.c'.format(i)) + endif + endforeach endif +libzstd_deps = [] +if enable_multithread + message('Enable multi-threading support') + add_project_arguments('-DZSTD_MULTITHREAD', language: 'c') + libzstd_deps = [ thread_dep ] +endif + +libzstd_c_args = [] +if cc_id == compiler_msvc + if default_library_type != 'static' + libzstd_sources += [windows_mod.compile_resources( + join_paths(zstd_rootdir, 'build/VS2010/libzstd-dll/libzstd-dll.rc'))] + libzstd_c_args += ['-DZSTD_DLL_EXPORT=1', + '-DZSTD_HEAPMODE=0', + '-D_CONSOLE', + '-D_CRT_SECURE_NO_WARNINGS'] + else + libzstd_c_args += ['-DZSTD_HEAPMODE=0', + '-D_CRT_SECURE_NO_WARNINGS'] + endif +endif + +mingw_ansi_stdio_flags = [] +if host_machine_os == os_windows and cc_id == compiler_gcc + mingw_ansi_stdio_flags = [ '-D__USE_MINGW_ANSI_STDIO' ] +endif +libzstd_c_args += mingw_ansi_stdio_flags + +libzstd_debug_cflags = [] +if enable_debug and meson_buildtype == 'debug' + if cc_id == compiler_gcc or cc_id == compiler_clang + libzstd_debug_cflags = ['-Wstrict-aliasing=1', '-Wswitch-enum', + '-Wdeclaration-after-statement', '-Wstrict-prototypes', + '-Wundef', '-Wpointer-arith', '-Wformat-security', '-Wvla', + '-Wformat=2', '-Winit-self', '-Wfloat-equal', '-Wwrite-strings', + '-Wredundant-decls', '-Wmissing-prototypes', '-Wc++-compat'] + endif +endif +libzstd_c_args += cc.get_supported_arguments(libzstd_debug_cflags) + libzstd = library('zstd', - libzstd_sources, - include_directories: libzstd_includes, - dependencies: libzstd_deps, - install: true, - soversion: zstd_version) + libzstd_sources, + include_directories: libzstd_includes, + c_args: libzstd_c_args, + dependencies: libzstd_deps, + install: true, + soversion: zstd_libversion) + +libzstd_dep = declare_dependency(link_with: libzstd, + include_directories: libzstd_includes) pkgconfig.generate(name: 'libzstd', - filebase: 'libzstd', - libraries: [libzstd], - description: 'fast lossless compression algorithm library', - version: zstd_version, - url: 'http://www.zstd.net/') + filebase: 'libzstd', + libraries: [libzstd], + description: 'fast lossless compression algorithm library', + version: zstd_libversion, + url: 'http://www.zstd.net/') -install_headers(join_paths(library_dir, 'zstd.h'), - join_paths(library_deprecated_dir, 'zbuff.h'), - join_paths(library_dictbuilder_dir, 'zdict.h'), - join_paths(library_common_dir, 'zstd_errors.h')) +install_headers(join_paths(zstd_rootdir, 'lib/zstd.h'), + join_paths(zstd_rootdir, 'lib/deprecated/zbuff.h'), + join_paths(zstd_rootdir, 'lib/dictBuilder/zdict.h'), + join_paths(zstd_rootdir, 'lib/common/zstd_errors.h')) diff --git a/build/meson/meson.build b/build/meson/meson.build index 750e841cf..f4c6f32d5 100644 --- a/build/meson/meson.build +++ b/build/meson/meson.build @@ -10,7 +10,7 @@ project('zstd', ['c', 'cpp'], - license: 'BSD', + license: ['BSD', 'GPLv2'], default_options : ['c_std=c99', 'cpp_std=c++11', 'buildtype=release'], @@ -22,36 +22,65 @@ cc = meson.get_compiler('c') cxx = meson.get_compiler('cpp') pkgconfig = import('pkgconfig') python3 = import('python').find_installation() +windows_mod = import('windows') + +host_machine_os = host_machine.system() +os_windows = 'windows' +os_linux = 'linux' +os_darwin = 'darwin' +os_freebsd = 'freebsd' +os_sun = 'sunos' + +cc_id = cc.get_id() +compiler_gcc = 'gcc' +compiler_clang = 'clang' +compiler_msvc = 'msvc' zstd_version = meson.project_version() +zstd_libversion = '' # ============================================================================= # Project directories # ============================================================================= -zstd_prefix = get_option('prefix') -zstd_bindir = join_paths(zstd_prefix, get_option('bindir')) -zstd_datadir = join_paths(zstd_prefix, get_option('datadir')) -zstd_docdir = join_paths(zstd_datadir, 'doc', meson.project_name()) -zstd_mandir = join_paths(zstd_prefix, get_option('mandir')) +zstd_rootdir = '../..' -zstd_source_dir = join_paths('..', '..') -library_dir = join_paths(zstd_source_dir, 'lib') -contrib_meson_dir = join_paths(zstd_source_dir, 'contrib', 'meson') +# ============================================================================= +# Installing directories +# ============================================================================= + +if host_machine_os == os_windows + zstd_prefix = '.' + zstd_bindir = 'bin' + zstd_datadir = 'share' + zstd_mandir = join_paths(zstd_datadir, 'man') +else + zstd_prefix = get_option('prefix') + zstd_bindir = join_paths(zstd_prefix, get_option('bindir')) + zstd_datadir = join_paths(zstd_prefix, get_option('datadir')) + zstd_mandir = join_paths(zstd_prefix, get_option('mandir')) +endif + +zstd_docdir = join_paths(zstd_datadir, 'doc', meson.project_name()) # ============================================================================= # Project options # ============================================================================= enable_debug = get_option('debug') +default_library_type = get_option('default_library') +meson_buildtype = get_option('buildtype') with_legacy_support = get_option('with-legacy-support') with_programs = get_option('with-programs') with_tests = get_option('with-tests') with_contrib = get_option('with-contrib') +with_debug_level = get_option('with-debug-level') enable_multithread = get_option('enable-multithread') +enable_static_runtime = get_option('enable-static-runtime') enable_zlib = get_option('enable-zlib') enable_lzma = get_option('enable-lzma') enable_lz4 = get_option('enable-lz4') +enable_backtrace = get_option('enable-backtrace') # ============================================================================= # Helper scripts for Meson @@ -63,7 +92,7 @@ GetZstdLibraryVersion_py = files('GetZstdLibraryVersion.py') # Getting project version from zstd.h # ============================================================================= -zstd_h_file = join_paths(meson.current_source_dir(), library_dir, 'zstd.h') +zstd_h_file = join_paths(meson.current_source_dir(), zstd_rootdir, 'lib/zstd.h') r = run_command(python3, GetZstdLibraryVersion_py, zstd_h_file) if r.returncode() == 0 output = r.stdout().strip() @@ -73,31 +102,42 @@ if r.returncode() == 0 endif endif +if host_machine_os != os_windows + zstd_libversion = zstd_version +endif + # ============================================================================= # Dependencies # ============================================================================= -libm_dep = cc.find_library('m', required: true) -thread_dep = dependency('threads', required: false) +libm_dep = cc.find_library('m', required: with_tests) +thread_dep = dependency('threads', required: enable_multithread) # Arguments in dependency should be equivalent to those passed to pkg-config -zlib_dep = dependency('zlib', required: false) -lzma_dep = dependency('liblzma', required: false) -lz4_dep = dependency('liblz4', required: false) +zlib_dep = dependency('zlib', required: enable_zlib) +lzma_dep = dependency('liblzma', required: enable_lzma) +lz4_dep = dependency('liblz4', required: enable_lz4) # ============================================================================= # Compiler flags # ============================================================================= -if cxx.get_id() == 'gcc' or cxx.get_id() == 'clang' - common_flags = [ '-DXXH_NAMESPACE=ZSTD_' ] +add_project_arguments('-DXXH_NAMESPACE=ZSTD_', language: [ 'c' ]) + +if [compiler_gcc, compiler_clang].contains(cc_id) common_warning_flags = [ '-Wextra', '-Wundef', '-Wshadow', '-Wcast-align', '-Wcast-qual' ] - cc_compilation_flags = cc.get_supported_arguments(common_warning_flags) - cc_compilation_flags += cc.get_supported_arguments(['-Wstrict-prototypes']) - cc_compilation_flags += common_flags - cxx_compilation_flags = cxx.get_supported_arguments(common_warning_flags) - cxx_compilation_flags += common_flags - add_project_arguments(cc_compilation_flags, language : 'c') - add_project_arguments(cxx_compilation_flags, language : 'cpp') + cc_compile_flags = cc.get_supported_arguments(common_warning_flags + [ '-Wstrict-prototypes' ]) + cxx_compile_flags = cxx.get_supported_arguments(common_warning_flags) + add_project_arguments(cc_compile_flags, language : 'c') + add_project_arguments(cxx_compile_flags, language : 'cpp') +elif cc_id == compiler_msvc + msvc_compile_flags = [ '/D_UNICODE', '/DUNICODE' ] + if enable_multithread + msvc_compile_flags += [ '/MP' ] + endif + if enable_static_runtime + msvc_compile_flags += [ '/MT' ] + endif + add_project_arguments(msvc_compile_flags, language: ['c', 'cpp']) endif # ============================================================================= diff --git a/build/meson/meson_options.txt b/build/meson/meson_options.txt index dca6df809..d4bac3c48 100644 --- a/build/meson/meson_options.txt +++ b/build/meson/meson_options.txt @@ -8,21 +8,25 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# -option('enable-multithread', type: 'boolean', value: true, - description: 'Enable multi-threading when pthread is detected') -option('with-legacy-support', type: 'string', value: '5', - description: 'Support any legacy format: true or false, or 7 to 1 for v0.7+ to v0.1+') +option('with-legacy-support', type: 'integer', min: 0, max: 7, value: '5', + description: 'Support any legacy format: 7 to 1 for v0.7+ to v0.1+') option('with-programs', type: 'boolean', value: true, - description: 'Enable programs build') + description: 'Enable programs build') option('with-contrib', type: 'boolean', value: false, - description: 'Enable contrib build') + description: 'Enable contrib build') option('with-tests', type: 'boolean', value: false, - description: 'Enable tests build') + description: 'Enable tests build') +option('with-debug-level', type: 'integer', min: 0, max: 9, value: 1, # Since 0.45.0 + description: 'Enable run-time debug. See lib/common/debug.h') +option('enable-multithread', type: 'boolean', value: true, + description: 'Enable multi-threading when pthread is detected') option('enable-static-runtime', type: 'boolean', value: false, - description: 'Link to static run-time libraries on MSVC') + description: 'Link to static run-time libraries on MSVC') option('enable-zlib', type: 'boolean', value: false, - description: 'Enable zlib support') + description: 'Enable zlib support') option('enable-lzma', type: 'boolean', value: false, - description: 'Enable lzma support') + description: 'Enable lzma support') option('enable-lz4', type: 'boolean', value: false, - description: 'Enable lz4 support') + description: 'Enable lz4 support') +option('enable-backtrace', type: 'boolean', value: false, + description: 'Display a stack backtrace when execution generates a runtime exception. Only in debug build mode.') diff --git a/build/meson/programs/meson.build b/build/meson/programs/meson.build index c96b6d458..8102eda15 100644 --- a/build/meson/programs/meson.build +++ b/build/meson/programs/meson.build @@ -8,74 +8,86 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# -zstd_source_dir = join_paths('..', '..', '..') -programs_dir = join_paths(zstd_source_dir, 'programs') +zstd_rootdir = '../../..' -zstdcli_c_file = join_paths(programs_dir, 'zstdcli.c') -util_c_file = join_paths(programs_dir, 'util.c') -fileio_c_file = join_paths(programs_dir, 'fileio.c') -zstd_programs_sources = [zstdcli_c_file, - util_c_file, - fileio_c_file, - join_paths(programs_dir, 'benchfn.c'), - join_paths(programs_dir, 'benchzstd.c'), - join_paths(programs_dir, 'datagen.c'), - join_paths(programs_dir, 'dibio.c')] +zstd_programs_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'), + join_paths(zstd_rootdir, 'programs/util.c'), + join_paths(zstd_rootdir, 'programs/fileio.c'), + join_paths(zstd_rootdir, 'programs/benchfn.c'), + join_paths(zstd_rootdir, 'programs/benchzstd.c'), + join_paths(zstd_rootdir, 'programs/datagen.c'), + join_paths(zstd_rootdir, 'programs/dibio.c')] -zstd_c_args = [] +zstd_c_args = libzstd_debug_cflags if enable_multithread - zstd_c_args += [ '-DZSTD_MULTITHREAD' ] + zstd_c_args += [ '-DZSTD_MULTITHREAD' ] endif -zstd_deps = [] +zstd_deps = [ libzstd_dep ] if enable_zlib and zlib_dep.found() - zstd_deps += [ zlib_dep ] - zstd_c_args += [ '-DZSTD_GZCOMPRESS', '-DZSTD_GZDECOMPRESS' ] + zstd_deps += [ zlib_dep ] + zstd_c_args += [ '-DZSTD_GZCOMPRESS', '-DZSTD_GZDECOMPRESS' ] endif if enable_lzma and lzma_dep.found() - zstd_deps += [ lzma_dep ] - zstd_c_args += [ '-DZSTD_LZMACOMPRESS', '-DZSTD_LZMADECOMPRESS' ] + zstd_deps += [ lzma_dep ] + zstd_c_args += [ '-DZSTD_LZMACOMPRESS', '-DZSTD_LZMADECOMPRESS' ] endif if enable_lz4 and lz4_dep.found() - zstd_deps += [ lz4_dep ] - zstd_c_args += [ '-DZSTD_LZ4COMPRESS', '-DZSTD_LZ4DECOMPRESS' ] + zstd_deps += [ lz4_dep ] + zstd_c_args += [ '-DZSTD_LZ4COMPRESS', '-DZSTD_LZ4DECOMPRESS' ] +endif + +export_dynamic_on_windows = false +# explicit backtrace enable/disable for Linux & Darwin +if not enable_backtrace + zstd_c_args += '-DBACKTRACE_ENABLE=0' +elif enable_debug and host_machine_os == os_windows # MinGW target + zstd_c_args += '-DBACKTRACE_ENABLE=1' + export_dynamic_on_windows = true +endif + +if cc_id == compiler_msvc + if default_library_type != 'static' + zstd_programs_sources += [windows_mod.compile_resources( + join_paths(zstd_rootdir, 'build/VS2010/zstd/zstd.rc'))] + endif endif zstd = executable('zstd', - zstd_programs_sources, - c_args: zstd_c_args, - include_directories: libzstd_includes, - link_with: libzstd, - dependencies: zstd_deps, - install: true) + zstd_programs_sources, + c_args: zstd_c_args, + dependencies: zstd_deps, + export_dynamic: export_dynamic_on_windows, # Since Meson 0.45.0 + install: true) -zstd_frugal_sources = [join_paths(programs_dir, 'zstdcli.c'), - util_c_file, - fileio_c_file] +zstd_frugal_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'), + join_paths(zstd_rootdir, 'programs/util.c'), + join_paths(zstd_rootdir, 'programs/fileio.c')] +# Minimal target, with only zstd compression and decompression. +# No bench. No legacy. executable('zstd-frugal', - zstd_frugal_sources, - include_directories: libzstd_includes, - link_with: libzstd, - c_args: [ '-DZSTD_NOBENCH', '-DZSTD_NODICT' ], - install: true) + zstd_frugal_sources, + dependencies: libzstd_dep, + c_args: [ '-DZSTD_NOBENCH', '-DZSTD_NODICT' ], + install: true) -install_data(join_paths(programs_dir, 'zstdgrep'), - join_paths(programs_dir, 'zstdless'), - install_dir: zstd_bindir) +install_data(join_paths(zstd_rootdir, 'programs/zstdgrep'), + join_paths(zstd_rootdir, 'programs/zstdless'), + install_dir: zstd_bindir) # ============================================================================= # Program symlinks # ============================================================================= -InstallSymlink_py = join_paths('..', 'InstallSymlink.py') +InstallSymlink_py = '../InstallSymlink.py' meson.add_install_script(InstallSymlink_py, 'zstd', 'zstdcat', zstd_bindir) meson.add_install_script(InstallSymlink_py, 'zstd', 'unzstd', zstd_bindir) if enable_multithread - meson.add_install_script(InstallSymlink_py, 'zstd', 'zstdmt', zstd_bindir) + meson.add_install_script(InstallSymlink_py, 'zstd', 'zstdmt', zstd_bindir) endif # ============================================================================= @@ -84,9 +96,9 @@ endif zstd_man1_dir = join_paths(zstd_mandir, 'man1') -install_man(join_paths(programs_dir, 'zstd.1'), - join_paths(programs_dir, 'zstdgrep.1'), - join_paths(programs_dir, 'zstdless.1')) +install_man(join_paths(zstd_rootdir, 'programs/zstd.1'), + join_paths(zstd_rootdir, 'programs/zstdgrep.1'), + join_paths(zstd_rootdir, 'programs/zstdless.1')) # Meson automatically compresses manpages to gz format # WARNING: This may fail on Windows. Test NEEDED. @@ -94,5 +106,5 @@ meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'zstdcat.1.gz', zstd_ma meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'unzstd.1.gz', zstd_man1_dir) if enable_multithread - meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'zstdmt.1.gz', zstd_man1_dir) + meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'zstdmt.1.gz', zstd_man1_dir) endif From c55d65b35db402b4f3838994226e7c52be7626a3 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 30 Nov 2018 16:15:33 +0700 Subject: [PATCH 26/41] Add clang cflags --- build/meson/meson.build | 83 +++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/build/meson/meson.build b/build/meson/meson.build index f4c6f32d5..f181fdc32 100644 --- a/build/meson/meson.build +++ b/build/meson/meson.build @@ -9,14 +9,14 @@ # ############################################################################# project('zstd', - ['c', 'cpp'], - license: ['BSD', 'GPLv2'], - default_options : ['c_std=c99', - 'cpp_std=c++11', - 'buildtype=release'], - version: '1.3.8', - # for install_man - meson_version: '>=0.47.0') + ['c', 'cpp'], + license: ['BSD', 'GPLv2'], + default_options : ['c_std=c99', + 'cpp_std=c++11', + 'buildtype=release'], + version: '1.3.8', + # for install_man + meson_version: '>=0.47.0') cc = meson.get_compiler('c') cxx = meson.get_compiler('cpp') @@ -46,19 +46,19 @@ zstd_libversion = '' zstd_rootdir = '../..' # ============================================================================= -# Installing directories +# Installation directories # ============================================================================= if host_machine_os == os_windows - zstd_prefix = '.' - zstd_bindir = 'bin' - zstd_datadir = 'share' - zstd_mandir = join_paths(zstd_datadir, 'man') + zstd_prefix = '.' + zstd_bindir = 'bin' + zstd_datadir = 'share' + zstd_mandir = join_paths(zstd_datadir, 'man') else - zstd_prefix = get_option('prefix') - zstd_bindir = join_paths(zstd_prefix, get_option('bindir')) - zstd_datadir = join_paths(zstd_prefix, get_option('datadir')) - zstd_mandir = join_paths(zstd_prefix, get_option('mandir')) + zstd_prefix = get_option('prefix') + zstd_bindir = join_paths(zstd_prefix, get_option('bindir')) + zstd_datadir = join_paths(zstd_prefix, get_option('datadir')) + zstd_mandir = join_paths(zstd_prefix, get_option('mandir')) endif zstd_docdir = join_paths(zstd_datadir, 'doc', meson.project_name()) @@ -95,15 +95,15 @@ GetZstdLibraryVersion_py = files('GetZstdLibraryVersion.py') zstd_h_file = join_paths(meson.current_source_dir(), zstd_rootdir, 'lib/zstd.h') r = run_command(python3, GetZstdLibraryVersion_py, zstd_h_file) if r.returncode() == 0 - output = r.stdout().strip() - if output.version_compare('>@0@'.format(zstd_version)) - zstd_version = output - message('Project version is now: @0@'.format(zstd_version)) - endif + output = r.stdout().strip() + if output.version_compare('>@0@'.format(zstd_version)) + zstd_version = output + message('Project version is now: @0@'.format(zstd_version)) + endif endif if host_machine_os != os_windows - zstd_libversion = zstd_version + zstd_libversion = zstd_version endif # ============================================================================= @@ -121,23 +121,26 @@ lz4_dep = dependency('liblz4', required: enable_lz4) # Compiler flags # ============================================================================= -add_project_arguments('-DXXH_NAMESPACE=ZSTD_', language: [ 'c' ]) +add_project_arguments('-DXXH_NAMESPACE=ZSTD_', language: ['c']) if [compiler_gcc, compiler_clang].contains(cc_id) - common_warning_flags = [ '-Wextra', '-Wundef', '-Wshadow', '-Wcast-align', '-Wcast-qual' ] - cc_compile_flags = cc.get_supported_arguments(common_warning_flags + [ '-Wstrict-prototypes' ]) - cxx_compile_flags = cxx.get_supported_arguments(common_warning_flags) - add_project_arguments(cc_compile_flags, language : 'c') - add_project_arguments(cxx_compile_flags, language : 'cpp') + common_warning_flags = [ '-Wextra', '-Wundef', '-Wshadow', '-Wcast-align', '-Wcast-qual' ] + if cc_id == compiler_clang + common_warning_flags += ['-Werror', '-Wconversion', '-Wno-sign-conversion', '-Wdocumentation'] + endif + cc_compile_flags = cc.get_supported_arguments(common_warning_flags + ['-Wstrict-prototypes']) + cxx_compile_flags = cxx.get_supported_arguments(common_warning_flags) + add_project_arguments(cc_compile_flags, language : 'c') + add_project_arguments(cxx_compile_flags, language : 'cpp') elif cc_id == compiler_msvc - msvc_compile_flags = [ '/D_UNICODE', '/DUNICODE' ] - if enable_multithread - msvc_compile_flags += [ '/MP' ] - endif - if enable_static_runtime - msvc_compile_flags += [ '/MT' ] - endif - add_project_arguments(msvc_compile_flags, language: ['c', 'cpp']) + msvc_compile_flags = [ '/D_UNICODE', '/DUNICODE' ] + if enable_multithread + msvc_compile_flags += '/MP' + endif + if enable_static_runtime + msvc_compile_flags += '/MT' + endif + add_project_arguments(msvc_compile_flags, language: ['c', 'cpp']) endif # ============================================================================= @@ -147,13 +150,13 @@ endif subdir('lib') if with_programs - subdir('programs') + subdir('programs') endif if with_tests - subdir('tests') + subdir('tests') endif if with_contrib - subdir('contrib') + subdir('contrib') endif From 39f49ac39f8f0bd357049a066bcf377749d5d2a5 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 30 Nov 2018 17:23:23 +0700 Subject: [PATCH 27/41] Add almost all test cases in tests/Makefile --- build/meson/tests/meson.build | 218 ++++++++++++++++++++++++------ build/meson/tests/valgrindTest.py | 90 ++++++++++++ 2 files changed, 263 insertions(+), 45 deletions(-) create mode 100644 build/meson/tests/valgrindTest.py diff --git a/build/meson/tests/meson.build b/build/meson/tests/meson.build index c64ae7a7a..4e127dec3 100644 --- a/build/meson/tests/meson.build +++ b/build/meson/tests/meson.build @@ -8,58 +8,186 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# -zstd_source_dir = join_paths('..', '..', '..') -programs_dir = join_paths(zstd_source_dir, 'programs') -tests_dir = join_paths(zstd_source_dir, 'tests') +zstd_rootdir = '../../..' -datagen_c_file = join_paths(programs_dir, 'datagen.c') -util_c_file = join_paths(programs_dir, 'util.c') -benchfn_c_file = join_paths(programs_dir, 'benchfn.c') +tests_supported_oses = [os_linux, 'gnu/kfreebsd', os_darwin, 'gnu', 'openbsd', + os_freebsd, 'netbsd', 'dragonfly', os_sun] -datagen_sources = [datagen_c_file, - join_paths(tests_dir, 'datagencli.c')] -test_includes = libzstd_includes + [include_directories(programs_dir)] +# ============================================================================= +# Test flags +# ============================================================================= +FUZZER_FLAGS = ['--no-big-tests'] +FUZZERTEST = '-T200s' +ZSTREAM_TESTTIME = '-T90s' +DECODECORPUS_TESTTIME = '-T30' +ZSTDRTTEST = ['--test-large-data'] + +# ============================================================================= +# Executables +# ============================================================================= + +test_includes = [ include_directories(join_paths(zstd_rootdir, 'programs')) ] + +datagen_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), + join_paths(zstd_rootdir, 'tests/datagencli.c')] datagen = executable('datagen', - datagen_sources, - include_directories: test_includes, - link_with: libzstd, - install: false) -test('datagen', datagen) + datagen_sources, + c_args: [ '-DNDEBUG' ], + include_directories: test_includes, + dependencies: libzstd_dep, + install: false) -fullbench_sources = [datagen_c_file, - util_c_file, - benchfn_c_file, - join_paths(programs_dir, 'benchzstd.c'), - join_paths(tests_dir, 'fullbench.c')] +fullbench_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), + join_paths(zstd_rootdir, 'programs/util.c'), + join_paths(zstd_rootdir, 'programs/benchfn.c'), + join_paths(zstd_rootdir, 'programs/benchzstd.c'), + join_paths(zstd_rootdir, 'tests/fullbench.c')] fullbench = executable('fullbench', - fullbench_sources, - include_directories: test_includes, - link_with: libzstd, - install: false) -test('fullbench', fullbench) + fullbench_sources, + include_directories: test_includes, + dependencies: libzstd_dep, + install: false) -fuzzer_sources = [datagen_c_file, - util_c_file, - join_paths(tests_dir, 'fuzzer.c')] +fuzzer_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), + join_paths(zstd_rootdir, 'programs/util.c'), + join_paths(zstd_rootdir, 'tests/fuzzer.c')] fuzzer = executable('fuzzer', - fuzzer_sources, - include_directories: test_includes, - link_with: libzstd, - install: false) -test('fuzzer', fuzzer) + fuzzer_sources, + include_directories: test_includes, + dependencies: libzstd_dep, + install: false) -paramgrill_sources = [benchfn_c_file, - join_paths(programs_dir, 'benchzstd.c'), - datagen_c_file, - util_c_file, - join_paths(tests_dir, 'paramgrill.c')] -if host_machine.system() != 'windows' - paramgrill = executable('paramgrill', - paramgrill_sources, - include_directories: test_includes, - link_with: libzstd, - dependencies: libm_dep, - install: false) - test('paramgrill', paramgrill) +zbufftest_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), + join_paths(zstd_rootdir, 'programs/util.c'), + join_paths(zstd_rootdir, 'tests/zbufftest.c')] +zbufftest = executable('zbufftest', + zbufftest_sources, + c_args: ['-Wno-deprecated-declarations'], + include_directories: test_includes, + dependencies: libzstd_dep, + install: false) + +zstreamtest_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), + join_paths(zstd_rootdir, 'programs/util.c'), + join_paths(zstd_rootdir, 'tests/seqgen.c'), + join_paths(zstd_rootdir, 'tests/zstreamtest.c')] +zstreamtest = executable('zstreamtest', + zstreamtest_sources, + include_directories: test_includes, + dependencies: libzstd_dep, + install: false) + +paramgrill_sources = [join_paths(zstd_rootdir, 'programs/benchfn.c'), + join_paths(zstd_rootdir, 'programs/benchzstd.c'), + join_paths(zstd_rootdir, 'programs/datagen.c'), + join_paths(zstd_rootdir, 'programs/util.c'), + join_paths(zstd_rootdir, 'tests/paramgrill.c')] +paramgrill = executable('paramgrill', + paramgrill_sources, + include_directories: test_includes, + dependencies: [ libzstd_dep, libm_dep ], + install: false) + +roundTripCrash_sources = [join_paths(zstd_rootdir, 'tests/roundTripCrash.c')] +roundTripCrash = executable('roundTripCrash', + roundTripCrash_sources, + dependencies: [ libzstd_dep ], + install: false) + +longmatch_sources = [join_paths(zstd_rootdir, 'tests/longmatch.c')] +longmatch = executable('longmatch', + longmatch_sources, + dependencies: [ libzstd_dep ], + install: false) + +invalidDictionaries_sources = [join_paths(zstd_rootdir, 'tests/invalidDictionaries.c')] +invalidDictionaries = executable('invalidDictionaries', + invalidDictionaries_sources, + dependencies: [ libzstd_dep ], + install: false) + +legacy_sources = [join_paths(zstd_rootdir, 'tests/legacy.c')] +legacy = executable('legacy', + legacy_sources, + c_args: '-DZSTD_LEGACY_SUPPORT=4', + dependencies: [ libzstd_dep ], + install: false) + +decodecorpus_sources = [join_paths(zstd_rootdir, 'programs/util.c'), + join_paths(zstd_rootdir, 'tests/decodecorpus.c')] +decodecorpus = executable('decodecorpus', + decodecorpus_sources, + include_directories: test_includes, + dependencies: [ libzstd_dep, libm_dep ], + install: false) + +symbols_sources = [join_paths(zstd_rootdir, 'tests/symbols.c')] +symbols = executable('symbols', + symbols_sources, + include_directories: test_includes, + c_args: host_machine_os == os_windows ? '-DZSTD_DLL_IMPORT=1' : [], + dependencies: [ libzstd_dep ], + install: false) + +poolTests_sources = [join_paths(zstd_rootdir, 'programs/util.c'), + join_paths(zstd_rootdir, 'tests/poolTests.c'), + join_paths(zstd_rootdir, 'lib/common/pool.c'), + join_paths(zstd_rootdir, 'lib/common/threading.c'), + join_paths(zstd_rootdir, 'lib/common/zstd_common.c'), + join_paths(zstd_rootdir, 'lib/common/error_private.c')] +poolTests = executable('poolTests', + poolTests_sources, + include_directories: test_includes, + dependencies: [ libzstd_dep ], + install: false) + +checkTag_sources = [join_paths(zstd_rootdir, 'tests/checkTag.c')] +checkTag = executable('checkTag', + checkTag_sources, + dependencies: [ libzstd_dep ], + install: false) + +# ============================================================================= +# Tests (Use "meson test --list" to list all tests) +# ============================================================================= + +if tests_supported_oses.contains(host_machine_os) + valgrind_prog = find_program('valgrind', ['/usr/bin/valgrind'], required: true) + valgrindTest_py = files('valgrindTest.py') + test('valgrindTest', + valgrindTest_py, + args: [valgrind_prog.path(), zstd, datagen, fuzzer, fullbench], + depends: [zstd, datagen, fuzzer, fullbench], + timeout: 600) # Timeout should work on HDD drive endif + +if host_machine_os != os_windows + playTests_sh = find_program(join_paths(zstd_rootdir, 'tests/playTests.sh'), required: true) + test('test-zstd', + playTests_sh, + args: ZSTDRTTEST, + env: ['ZSTD=' + zstd.full_path()], + depends: [datagen], + timeout: 600) # Timeout should work on HDD drive +endif + +test('test-fullbench-1', fullbench, args: ['-i1'], + depends: [fullbench, datagen]) +test('test-fullbench-2', fullbench, args: ['-i1', '-P0'], + depends: [fullbench, datagen]) + +if enable_zlib + test('test-fuzzer', fuzzer, args: ['-v', FUZZERTEST] + FUZZER_FLAGS) +endif + +test('test-zbuff', zbufftest, args: [ZSTREAM_TESTTIME]) +test('test-zstream-1', zstreamtest, args: ['-v', ZSTREAM_TESTTIME] + FUZZER_FLAGS) +test('test-zstream-2', zstreamtest, args: ['-mt', '-t1', ZSTREAM_TESTTIME] + FUZZER_FLAGS) +test('test-zstream-3', zstreamtest, args: ['--newapi', '-t1', ZSTREAM_TESTTIME] + FUZZER_FLAGS) +test('test-longmatch', longmatch) +test('test-invalidDictionaries', invalidDictionaries) +test('test-symbols', symbols) +test('test-legacy', legacy) +test('test-decodecorpus', decodecorpus, args: ['-t', DECODECORPUS_TESTTIME]) +test('test-poolTests', poolTests) diff --git a/build/meson/tests/valgrindTest.py b/build/meson/tests/valgrindTest.py new file mode 100644 index 000000000..218f7458b --- /dev/null +++ b/build/meson/tests/valgrindTest.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 +# ############################################################################# +# Copyright (c) 2018-present lzutao +# 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 os +import subprocess +import tempfile + + +def valgrindTest(valgrind, datagen, fuzzer, zstd, fullbench): + VALGRIND_ARGS = [valgrind, '--leak-check=full', '--show-leak-kinds=all', '--error-exitcode=1'] + + print('\n ---- valgrind tests : memory analyzer ----') + + subprocess.check_call([*VALGRIND_ARGS, datagen, '-g50M'], stdout=subprocess.DEVNULL) + + if subprocess.call([*VALGRIND_ARGS, zstd], + stdout=subprocess.DEVNULL) == 0: + raise subprocess.CalledProcessError('zstd without argument should have failed') + + with subprocess.Popen([datagen, '-g80'], stdout=subprocess.PIPE) as p1, \ + subprocess.Popen([*VALGRIND_ARGS, zstd, '-', '-c'], + stdin=p1.stdout, + stdout=subprocess.DEVNULL) as p2: + p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. + p2.communicate() + if p2.returncode != 0: + raise subprocess.CalledProcessError() + + with subprocess.Popen([datagen, '-g16KB'], stdout=subprocess.PIPE) as p1, \ + subprocess.Popen([*VALGRIND_ARGS, zstd, '-vf', '-', '-c'], + stdin=p1.stdout, + stdout=subprocess.DEVNULL) as p2: + p1.stdout.close() + p2.communicate() + if p2.returncode != 0: + raise subprocess.CalledProcessError() + + with tempfile.NamedTemporaryFile() as tmp_fd: + with subprocess.Popen([datagen, '-g2930KB'], stdout=subprocess.PIPE) as p1, \ + subprocess.Popen([*VALGRIND_ARGS, zstd, '-5', '-vf', '-', '-o', tmp_fd.name], + stdin=p1.stdout) as p2: + p1.stdout.close() + p2.communicate() + if p2.returncode != 0: + raise subprocess.CalledProcessError() + + subprocess.check_call([*VALGRIND_ARGS, zstd, '-vdf', tmp_fd.name, '-c'], + stdout=subprocess.DEVNULL) + + with subprocess.Popen([datagen, '-g64MB'], stdout=subprocess.PIPE) as p1, \ + subprocess.Popen([*VALGRIND_ARGS, zstd, '-vf', '-', '-c'], + stdin=p1.stdout, + stdout=subprocess.DEVNULL) as p2: + p1.stdout.close() + p2.communicate() + if p2.returncode != 0: + raise subprocess.CalledProcessError() + + subprocess.check_call([*VALGRIND_ARGS, fuzzer, '-T1mn', '-t1']) + subprocess.check_call([*VALGRIND_ARGS, fullbench, '-i1']) + + +def main(): + import argparse + parser = argparse.ArgumentParser(description='Valgrind tests : memory analyzer') + parser.add_argument('valgrind', help='valgrind path') + parser.add_argument('zstd', help='zstd path') + parser.add_argument('datagen', help='datagen path') + parser.add_argument('fuzzer', help='fuzzer path') + parser.add_argument('fullbench', help='fullbench path') + + args = parser.parse_args() + + valgrind = args.valgrind + zstd = args.zstd + datagen = args.datagen + fuzzer = args.fuzzer + fullbench = args.fullbench + + valgrindTest(valgrind, datagen, fuzzer, zstd, fullbench) + + +if __name__ == '__main__': + main() From 24bc513ea16e1e6e53e42d351dfec4035755fd8f Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 30 Nov 2018 21:05:03 +0700 Subject: [PATCH 28/41] meson: Change build options' name --- build/meson/lib/meson.build | 13 ++++---- build/meson/meson.build | 54 ++++++++++++++++++-------------- build/meson/meson_options.txt | 36 +++++++++++---------- build/meson/programs/meson.build | 16 +++++----- build/meson/tests/meson.build | 4 +-- 5 files changed, 67 insertions(+), 56 deletions(-) diff --git a/build/meson/lib/meson.build b/build/meson/lib/meson.build index 5bfdbb074..c39a65530 100644 --- a/build/meson/lib/meson.build +++ b/build/meson/lib/meson.build @@ -47,25 +47,25 @@ libzstd_sources = [join_paths(zstd_rootdir, 'lib/common/entropy_common.c'), join_paths(zstd_rootdir, 'lib/deprecated/zbuff_decompress.c')] # Explicit define legacy support -add_project_arguments('-DZSTD_LEGACY_SUPPORT=@0@'.format(with_legacy_support), +add_project_arguments('-DZSTD_LEGACY_SUPPORT=@0@'.format(legacy_level), language: 'c') -if with_legacy_support == 0 +if legacy_level == 0 message('Legacy support: DISABLED') else # See ZSTD_LEGACY_SUPPORT of lib/README.md - message('Enable legacy support back to version 0.@0@'.format(with_legacy_support)) + message('Enable legacy support back to version 0.@0@'.format(legacy_level)) libzstd_includes += [ include_directories(join_paths(zstd_rootdir, 'lib/legacy')) ] foreach i : [1, 2, 3, 4, 5, 6, 7] - if with_legacy_support <= i + if legacy_level <= i libzstd_sources += join_paths(zstd_rootdir, 'lib/legacy/zstd_v0@0@.c'.format(i)) endif endforeach endif libzstd_deps = [] -if enable_multithread +if use_multi_thread message('Enable multi-threading support') add_project_arguments('-DZSTD_MULTITHREAD', language: 'c') libzstd_deps = [ thread_dep ] @@ -93,7 +93,8 @@ endif libzstd_c_args += mingw_ansi_stdio_flags libzstd_debug_cflags = [] -if enable_debug and meson_buildtype == 'debug' +if use_debug + libzstd_c_args += '-DDEBUGLEVEL=@0@'.format(debug_level) if cc_id == compiler_gcc or cc_id == compiler_clang libzstd_debug_cflags = ['-Wstrict-aliasing=1', '-Wswitch-enum', '-Wdeclaration-after-statement', '-Wstrict-prototypes', diff --git a/build/meson/meson.build b/build/meson/meson.build index f181fdc32..c36c9425a 100644 --- a/build/meson/meson.build +++ b/build/meson/meson.build @@ -15,7 +15,6 @@ project('zstd', 'cpp_std=c++11', 'buildtype=release'], version: '1.3.8', - # for install_man meson_version: '>=0.47.0') cc = meson.get_compiler('c') @@ -67,20 +66,23 @@ zstd_docdir = join_paths(zstd_datadir, 'doc', meson.project_name()) # Project options # ============================================================================= -enable_debug = get_option('debug') -default_library_type = get_option('default_library') -meson_buildtype = get_option('buildtype') -with_legacy_support = get_option('with-legacy-support') -with_programs = get_option('with-programs') -with_tests = get_option('with-tests') -with_contrib = get_option('with-contrib') -with_debug_level = get_option('with-debug-level') -enable_multithread = get_option('enable-multithread') -enable_static_runtime = get_option('enable-static-runtime') -enable_zlib = get_option('enable-zlib') -enable_lzma = get_option('enable-lzma') -enable_lz4 = get_option('enable-lz4') -enable_backtrace = get_option('enable-backtrace') +# Built-in options +use_debug = get_option('debug') + +# Custom options +debug_level = get_option('debug_level') +legacy_level = get_option('legacy_level') +use_backtrace = get_option('backtrace') +use_static_runtime = get_option('static_runtime') + +build_programs = get_option('build_programs') +build_contrib = get_option('build_contrib') +build_tests = get_option('build_tests') + +feature_multi_thread = get_option('multi_thread') +feature_zlib = get_option('zlib') +feature_lzma = get_option('lzma') +feature_lz4 = get_option('lz4') # ============================================================================= # Helper scripts for Meson @@ -110,12 +112,16 @@ endif # Dependencies # ============================================================================= -libm_dep = cc.find_library('m', required: with_tests) -thread_dep = dependency('threads', required: enable_multithread) +libm_dep = cc.find_library('m', required: build_tests) +thread_dep = dependency('threads', required: feature_multi_thread) +use_multi_thread = thread_dep.found() # Arguments in dependency should be equivalent to those passed to pkg-config -zlib_dep = dependency('zlib', required: enable_zlib) -lzma_dep = dependency('liblzma', required: enable_lzma) -lz4_dep = dependency('liblz4', required: enable_lz4) +zlib_dep = dependency('zlib', required: feature_zlib) +use_zlib = zlib_dep.found() +lzma_dep = dependency('liblzma', required: feature_lzma) +use_lzma = lzma_dep.found() +lz4_dep = dependency('liblz4', required: feature_lz4) +use_lz4 = lz4_dep.found() # ============================================================================= # Compiler flags @@ -134,7 +140,7 @@ if [compiler_gcc, compiler_clang].contains(cc_id) add_project_arguments(cxx_compile_flags, language : 'cpp') elif cc_id == compiler_msvc msvc_compile_flags = [ '/D_UNICODE', '/DUNICODE' ] - if enable_multithread + if use_multi_thread msvc_compile_flags += '/MP' endif if enable_static_runtime @@ -149,14 +155,14 @@ endif subdir('lib') -if with_programs +if build_programs subdir('programs') endif -if with_tests +if build_tests subdir('tests') endif -if with_contrib +if build_contrib subdir('contrib') endif diff --git a/build/meson/meson_options.txt b/build/meson/meson_options.txt index d4bac3c48..349d915c7 100644 --- a/build/meson/meson_options.txt +++ b/build/meson/meson_options.txt @@ -8,25 +8,29 @@ # in the COPYING file in the root directory of this source tree). # ############################################################################# -option('with-legacy-support', type: 'integer', min: 0, max: 7, value: '5', +# Read guidelines from https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting + +option('legacy_level', type: 'integer', min: 0, max: 7, value: '5', description: 'Support any legacy format: 7 to 1 for v0.7+ to v0.1+') -option('with-programs', type: 'boolean', value: true, - description: 'Enable programs build') -option('with-contrib', type: 'boolean', value: false, - description: 'Enable contrib build') -option('with-tests', type: 'boolean', value: false, - description: 'Enable tests build') -option('with-debug-level', type: 'integer', min: 0, max: 9, value: 1, # Since 0.45.0 +option('debug_level', type: 'integer', min: 0, max: 9, value: 1, description: 'Enable run-time debug. See lib/common/debug.h') -option('enable-multithread', type: 'boolean', value: true, - description: 'Enable multi-threading when pthread is detected') -option('enable-static-runtime', type: 'boolean', value: false, +option('backtrace', type: 'boolean', value: false, + description: 'Display a stack backtrace when execution generates a runtime exception') +option('static_runtime', type: 'boolean', value: false, description: 'Link to static run-time libraries on MSVC') -option('enable-zlib', type: 'boolean', value: false, + +option('build_programs', type: 'boolean', value: true, + description: 'Enable programs build') +option('build_tests', type: 'boolean', value: false, + description: 'Enable tests build') +option('build_contrib', type: 'boolean', value: false, + description: 'Enable contrib build') + +option('multi_thread', type: 'feature', value: 'enabled', + description: 'Enable multi-threading when pthread is detected') +option('zlib', type: 'feature', value: 'auto', description: 'Enable zlib support') -option('enable-lzma', type: 'boolean', value: false, +option('lzma', type: 'feature', value: 'auto', description: 'Enable lzma support') -option('enable-lz4', type: 'boolean', value: false, +option('lz4', type: 'feature', value: 'auto', description: 'Enable lz4 support') -option('enable-backtrace', type: 'boolean', value: false, - description: 'Display a stack backtrace when execution generates a runtime exception. Only in debug build mode.') diff --git a/build/meson/programs/meson.build b/build/meson/programs/meson.build index 8102eda15..f538aa556 100644 --- a/build/meson/programs/meson.build +++ b/build/meson/programs/meson.build @@ -19,31 +19,31 @@ zstd_programs_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'), join_paths(zstd_rootdir, 'programs/dibio.c')] zstd_c_args = libzstd_debug_cflags -if enable_multithread +if use_multi_thread zstd_c_args += [ '-DZSTD_MULTITHREAD' ] endif zstd_deps = [ libzstd_dep ] -if enable_zlib and zlib_dep.found() +if use_zlib zstd_deps += [ zlib_dep ] zstd_c_args += [ '-DZSTD_GZCOMPRESS', '-DZSTD_GZDECOMPRESS' ] endif -if enable_lzma and lzma_dep.found() +if use_lzma zstd_deps += [ lzma_dep ] zstd_c_args += [ '-DZSTD_LZMACOMPRESS', '-DZSTD_LZMADECOMPRESS' ] endif -if enable_lz4 and lz4_dep.found() +if use_lz4 zstd_deps += [ lz4_dep ] zstd_c_args += [ '-DZSTD_LZ4COMPRESS', '-DZSTD_LZ4DECOMPRESS' ] endif export_dynamic_on_windows = false # explicit backtrace enable/disable for Linux & Darwin -if not enable_backtrace +if not use_backtrace zstd_c_args += '-DBACKTRACE_ENABLE=0' -elif enable_debug and host_machine_os == os_windows # MinGW target +elif use_debug and host_machine_os == os_windows # MinGW target zstd_c_args += '-DBACKTRACE_ENABLE=1' export_dynamic_on_windows = true endif @@ -86,7 +86,7 @@ InstallSymlink_py = '../InstallSymlink.py' meson.add_install_script(InstallSymlink_py, 'zstd', 'zstdcat', zstd_bindir) meson.add_install_script(InstallSymlink_py, 'zstd', 'unzstd', zstd_bindir) -if enable_multithread +if use_multi_thread meson.add_install_script(InstallSymlink_py, 'zstd', 'zstdmt', zstd_bindir) endif @@ -105,6 +105,6 @@ install_man(join_paths(zstd_rootdir, 'programs/zstd.1'), meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'zstdcat.1.gz', zstd_man1_dir) meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'unzstd.1.gz', zstd_man1_dir) -if enable_multithread +if use_multi_thread meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'zstdmt.1.gz', zstd_man1_dir) endif diff --git a/build/meson/tests/meson.build b/build/meson/tests/meson.build index 4e127dec3..c8772e761 100644 --- a/build/meson/tests/meson.build +++ b/build/meson/tests/meson.build @@ -139,7 +139,7 @@ poolTests_sources = [join_paths(zstd_rootdir, 'programs/util.c'), poolTests = executable('poolTests', poolTests_sources, include_directories: test_includes, - dependencies: [ libzstd_dep ], + dependencies: [ libzstd_dep, thread_dep ], install: false) checkTag_sources = [join_paths(zstd_rootdir, 'tests/checkTag.c')] @@ -177,7 +177,7 @@ test('test-fullbench-1', fullbench, args: ['-i1'], test('test-fullbench-2', fullbench, args: ['-i1', '-P0'], depends: [fullbench, datagen]) -if enable_zlib +if use_zlib test('test-fuzzer', fuzzer, args: ['-v', FUZZERTEST] + FUZZER_FLAGS) endif From ff1bca3fbd4c427f7bd4671eaf40cd9778fa281e Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 30 Nov 2018 21:10:06 +0700 Subject: [PATCH 29/41] ci: Use new meson auto_features option * Install lz4 dep from Ubuntu repo * Use curl instead of wget * Use xenial for meson and make meson build first * Unset Travis preset CC and CXX value for meson to use ccache * Be more verbose with "set -x" --- .travis.yml | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8a0170e04..1ed148d0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,7 +51,8 @@ matrix: - if: tag =~ ^v[0-9]\.[0-9] env: Cmd='make -C tests checkTag && tests/checkTag $TRAVIS_BRANCH' - - env: BUILD_SYSTEM='meson' + - dist: xenial + env: BUILD_SYSTEM='meson' allow_failures: - env: BUILD_SYSTEM='meson' @@ -69,22 +70,25 @@ script: - printf 'JOB_NUMBER=%s TRAVIS_BRANCH=%s TRAVIS_EVENT_TYPE=%s TRAVIS_PULL_REQUEST=%s\n' "${JOB_NUMBER}" "${TRAVIS_BRANCH}" "${TRAVIS_EVENT_TYPE}" "${TRAVIS_PULL_REQUEST}" - if [ "${BUILD_SYSTEM}" = meson ]; then - sudo apt-get install -qq python3.5 wget tree - && wget https://bootstrap.pypa.io/get-pip.py - && python3.5 get-pip.py --user + set -x; + sudo apt-get install -qq liblz4-dev valgrind tree + && curl -o get-pip.py 'https://bootstrap.pypa.io/get-pip.py' + && python3 get-pip.py --user && rm get-pip.py - && pip3.5 install --user meson ninja; - mkdir build/meson/build; - pushd "$_"; - meson --buildtype=debug -D with-contrib=true -D with-tests=true - -D with-contrib=true -D default_library=both .. + && pip3 install --user meson ninja + && unset CC CXX + && meson --buildtype=debug + -Dauto_features=enabled + -Dbuild_{programs,tests,contrib}=true + -Ddefault_library=both build/meson + builddir + && cd "$_" && ninja && DESTDIR=./staging ninja install && tree ./staging; - popd; - else - export FUZZERTEST=-T2mn; - export ZSTREAM_TESTTIME=-T2mn; - export DECODECORPUS_TESTTIME=-T1mn; - sh -c "${Cmd}" || travis_terminate 1; + travis_terminate "$?"; fi + - export FUZZERTEST=-T2mn; + export ZSTREAM_TESTTIME=-T2mn; + export DECODECORPUS_TESTTIME=-T1mn; + sh -c "${Cmd}" || travis_terminate 1; From 8d5252b68d651981e4dfdb535fde10854c140a47 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 30 Nov 2018 21:31:58 +0700 Subject: [PATCH 30/41] meson: Remove redundant join_paths function --- build/meson/contrib/gen_html/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/meson/contrib/gen_html/meson.build b/build/meson/contrib/gen_html/meson.build index a2fea9d52..cabff209d 100644 --- a/build/meson/contrib/gen_html/meson.build +++ b/build/meson/contrib/gen_html/meson.build @@ -24,6 +24,6 @@ zstd_manual_html = custom_target('zstd_manual.html', output : 'zstd_manual.html', command : [gen_html, zstd_version, - join_paths(meson.current_source_dir(), join_paths(zstd_rootdir, 'lib/zstd.h')), + join_paths(meson.current_source_dir(), zstd_rootdir, 'lib/zstd.h'), '@OUTPUT@'], install : false) From 519b2de6f7f8940aa4a8793db8f57f369070b962 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sat, 1 Dec 2018 09:11:26 +0700 Subject: [PATCH 31/41] Update README --- build/meson/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/meson/README.md b/build/meson/README.md index f5818cc69..dae503fef 100644 --- a/build/meson/README.md +++ b/build/meson/README.md @@ -1,5 +1,5 @@ -contrib/meson - Meson build system for zstandard -================================================ +Meson build system for zstandard +================================ Meson is a build system designed to optimize programmer productivity. It aims to do this by providing simple, out-of-the-box support for From cbf2a924dd504e155dfeb6f6bc9708cc8c2dc1d9 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sat, 1 Dec 2018 13:07:08 +0700 Subject: [PATCH 32/41] meson: Cleanup installing symlinks --- build/meson/programs/meson.build | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/build/meson/programs/meson.build b/build/meson/programs/meson.build index f538aa556..c97bc653d 100644 --- a/build/meson/programs/meson.build +++ b/build/meson/programs/meson.build @@ -79,32 +79,23 @@ install_data(join_paths(zstd_rootdir, 'programs/zstdgrep'), install_dir: zstd_bindir) # ============================================================================= -# Program symlinks +# Programs and manpages installing # ============================================================================= -InstallSymlink_py = '../InstallSymlink.py' -meson.add_install_script(InstallSymlink_py, 'zstd', 'zstdcat', zstd_bindir) -meson.add_install_script(InstallSymlink_py, 'zstd', 'unzstd', zstd_bindir) - -if use_multi_thread - meson.add_install_script(InstallSymlink_py, 'zstd', 'zstdmt', zstd_bindir) -endif - -# ============================================================================= -# Manpages -# ============================================================================= - -zstd_man1_dir = join_paths(zstd_mandir, 'man1') - install_man(join_paths(zstd_rootdir, 'programs/zstd.1'), join_paths(zstd_rootdir, 'programs/zstdgrep.1'), join_paths(zstd_rootdir, 'programs/zstdless.1')) -# Meson automatically compresses manpages to gz format -# WARNING: This may fail on Windows. Test NEEDED. -meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'zstdcat.1.gz', zstd_man1_dir) -meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'unzstd.1.gz', zstd_man1_dir) +InstallSymlink_py = '../InstallSymlink.py' +zstd_man1_dir = join_paths(zstd_mandir, 'man1') +man1_EXT = host_machine_os != os_windows ? '.1.gz' : '' + +foreach f : ['zstdcat', 'unzstd'] + meson.add_install_script(InstallSymlink_py, 'zstd', f, zstd_bindir) + meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, f + man1_EXT, zstd_man1_dir) +endforeach if use_multi_thread - meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'zstdmt.1.gz', zstd_man1_dir) + meson.add_install_script(InstallSymlink_py, 'zstd', 'zstdmt', zstd_bindir) + meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, 'zstdmt' + man1_EXT, zstd_man1_dir) endif From 7da18bc85a759f7b41ac754ef611a1024ee89b79 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 2 Dec 2018 00:18:00 +0700 Subject: [PATCH 33/41] Add missed .1 extension for manpage [skip ci] --- build/meson/programs/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/meson/programs/meson.build b/build/meson/programs/meson.build index c97bc653d..333ad8e8b 100644 --- a/build/meson/programs/meson.build +++ b/build/meson/programs/meson.build @@ -88,7 +88,7 @@ install_man(join_paths(zstd_rootdir, 'programs/zstd.1'), InstallSymlink_py = '../InstallSymlink.py' zstd_man1_dir = join_paths(zstd_mandir, 'man1') -man1_EXT = host_machine_os != os_windows ? '.1.gz' : '' +man1_EXT = host_machine_os != os_windows ? '.1.gz' : '.1' foreach f : ['zstdcat', 'unzstd'] meson.add_install_script(InstallSymlink_py, 'zstd', f, zstd_bindir) From 38728b4518ff9f674ad9911f02301af73d7518ea Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 2 Dec 2018 22:31:18 +0700 Subject: [PATCH 34/41] Use argparse instead of manually parsing [skip ci] --- build/meson/GetZstdLibraryVersion.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/build/meson/GetZstdLibraryVersion.py b/build/meson/GetZstdLibraryVersion.py index 5659a3283..53c61008a 100644 --- a/build/meson/GetZstdLibraryVersion.py +++ b/build/meson/GetZstdLibraryVersion.py @@ -11,11 +11,6 @@ import re import sys -def usage(): - print('usage: python3 GetZstdLibraryVersion.py ') - sys.exit(1) - - def find_version(filepath): version_file_data = None with open(filepath) as fd: @@ -29,14 +24,15 @@ def find_version(filepath): version_match = regex.search(version_file_data) if version_match: return version_match.groups() - raise RuntimeError("Unable to find version string.") + raise Exception("Unable to find version string.") def main(): - if len(sys.argv) < 2: - usage() - - filepath = sys.argv[1] + import argparse + parser = argparse.ArgumentParser(description='Print zstd version from lib/zstd.h') + parser.add_argument('file', help='path to lib/zstd.h') + args = parser.parse_args() + filepath = args.file version_tup = find_version(filepath) print('.'.join(version_tup)) From 23d751507e4b2ef99dc27cc6f691835b52dc9b50 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 2 Dec 2018 22:33:25 +0700 Subject: [PATCH 35/41] meson: Use -werror build option instead of adding -Werror [skip ci] --- build/meson/meson.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/meson/meson.build b/build/meson/meson.build index c36c9425a..2e1f9d06b 100644 --- a/build/meson/meson.build +++ b/build/meson/meson.build @@ -68,6 +68,7 @@ zstd_docdir = join_paths(zstd_datadir, 'doc', meson.project_name()) # Built-in options use_debug = get_option('debug') +buildtype = get_option('buildtype') # Custom options debug_level = get_option('debug_level') @@ -132,7 +133,9 @@ add_project_arguments('-DXXH_NAMESPACE=ZSTD_', language: ['c']) if [compiler_gcc, compiler_clang].contains(cc_id) common_warning_flags = [ '-Wextra', '-Wundef', '-Wshadow', '-Wcast-align', '-Wcast-qual' ] if cc_id == compiler_clang - common_warning_flags += ['-Werror', '-Wconversion', '-Wno-sign-conversion', '-Wdocumentation'] + # Should use Meson's own --werror build option + #common_warning_flags += '-Werror' + common_warning_flags += ['-Wconversion', '-Wno-sign-conversion', '-Wdocumentation'] endif cc_compile_flags = cc.get_supported_arguments(common_warning_flags + ['-Wstrict-prototypes']) cxx_compile_flags = cxx.get_supported_arguments(common_warning_flags) From 838de084390dd612c33999ffa39b9b4dac1107bf Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 2 Dec 2018 22:45:46 +0700 Subject: [PATCH 36/41] meson: Fix soversion --- build/meson/lib/meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/meson/lib/meson.build b/build/meson/lib/meson.build index c39a65530..bce6b7c56 100644 --- a/build/meson/lib/meson.build +++ b/build/meson/lib/meson.build @@ -111,7 +111,8 @@ libzstd = library('zstd', c_args: libzstd_c_args, dependencies: libzstd_deps, install: true, - soversion: zstd_libversion) + version: zstd_libversion, + soversion: '1') libzstd_dep = declare_dependency(link_with: libzstd, include_directories: libzstd_includes) From 437ec5f47fc60fd8372a5c6517ea36c38fc3955a Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 2 Dec 2018 22:48:11 +0700 Subject: [PATCH 37/41] meson helper: Use Python conventional name for naming function [skip ci] --- build/meson/InstallSymlink.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/build/meson/InstallSymlink.py b/build/meson/InstallSymlink.py index d7b1e5a0b..6dd151530 100644 --- a/build/meson/InstallSymlink.py +++ b/build/meson/InstallSymlink.py @@ -21,7 +21,7 @@ def mkdir_p(path, dir_mode=0o777): raise -def InstallSymlink(src, dst, install_dir, dst_is_dir=False, dir_mode=0o777): +def install_symlink(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): @@ -38,8 +38,7 @@ def InstallSymlink(src, dst, install_dir, dst_is_dir=False, dir_mode=0o777): 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' + 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') @@ -65,7 +64,7 @@ def main(): 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) + install_symlink(src, dst, install_dir, dst_is_dir, dir_mode) if __name__ == '__main__': From 65507666bb468c4708359b8dfa7146e7113d624a Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 3 Dec 2018 00:36:40 +0700 Subject: [PATCH 38/41] Use -Dlegacy_level build option to control ZSTD_LEGACY_SUPPORT macro in test --- build/meson/tests/meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/meson/tests/meson.build b/build/meson/tests/meson.build index c8772e761..e35575d00 100644 --- a/build/meson/tests/meson.build +++ b/build/meson/tests/meson.build @@ -110,7 +110,8 @@ invalidDictionaries = executable('invalidDictionaries', legacy_sources = [join_paths(zstd_rootdir, 'tests/legacy.c')] legacy = executable('legacy', legacy_sources, - c_args: '-DZSTD_LEGACY_SUPPORT=4', + # Use -Dlegacy_level build option to control it + #c_args: '-DZSTD_LEGACY_SUPPORT=4', dependencies: [ libzstd_dep ], install: false) From 25311d24c6565f027f25e5a81e55e78be816b4db Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 3 Dec 2018 00:57:10 +0700 Subject: [PATCH 39/41] meson: Use clang for faster build --- .travis.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1ed148d0b..8cb40b1e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -72,18 +72,17 @@ script: - if [ "${BUILD_SYSTEM}" = meson ]; then set -x; sudo apt-get install -qq liblz4-dev valgrind tree - && curl -o get-pip.py 'https://bootstrap.pypa.io/get-pip.py' - && python3 get-pip.py --user - && rm get-pip.py + && curl -o ~/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' + && python3 ~/get-pip.py --user && pip3 install --user meson ninja - && unset CC CXX + && export CC=clang CXX=clang++ && meson --buildtype=debug - -Dauto_features=enabled - -Dbuild_{programs,tests,contrib}=true - -Ddefault_library=both build/meson - builddir + -Db_lundef=false + -Dauto_features=enabled + -Dbuild_{programs,tests,contrib}=true + -Ddefault_library=both + build/meson builddir && cd "$_" - && ninja && DESTDIR=./staging ninja install && tree ./staging; travis_terminate "$?"; From 9d6cf606f8b0cdb2f2101484f44ca9bff24eb47d Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 3 Dec 2018 03:23:09 +0700 Subject: [PATCH 40/41] meson: Update tests timeout to run properly --- build/meson/tests/meson.build | 54 +++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/build/meson/tests/meson.build b/build/meson/tests/meson.build index e35575d00..aa9cd86f4 100644 --- a/build/meson/tests/meson.build +++ b/build/meson/tests/meson.build @@ -173,22 +173,46 @@ if host_machine_os != os_windows timeout: 600) # Timeout should work on HDD drive endif -test('test-fullbench-1', fullbench, args: ['-i1'], - depends: [fullbench, datagen]) -test('test-fullbench-2', fullbench, args: ['-i1', '-P0'], - depends: [fullbench, datagen]) +test('test-fullbench-1', + fullbench, + args: ['-i1'], + depends: [datagen], + timeout: 60) +test('test-fullbench-2', + fullbench, + args: ['-i1', '-P0'], + depends: [datagen], + timeout: 60) if use_zlib - test('test-fuzzer', fuzzer, args: ['-v', FUZZERTEST] + FUZZER_FLAGS) + test('test-fuzzer', + fuzzer, + args: ['-v', FUZZERTEST] + FUZZER_FLAGS, + timeout: 240) endif -test('test-zbuff', zbufftest, args: [ZSTREAM_TESTTIME]) -test('test-zstream-1', zstreamtest, args: ['-v', ZSTREAM_TESTTIME] + FUZZER_FLAGS) -test('test-zstream-2', zstreamtest, args: ['-mt', '-t1', ZSTREAM_TESTTIME] + FUZZER_FLAGS) -test('test-zstream-3', zstreamtest, args: ['--newapi', '-t1', ZSTREAM_TESTTIME] + FUZZER_FLAGS) -test('test-longmatch', longmatch) -test('test-invalidDictionaries', invalidDictionaries) -test('test-symbols', symbols) -test('test-legacy', legacy) -test('test-decodecorpus', decodecorpus, args: ['-t', DECODECORPUS_TESTTIME]) -test('test-poolTests', poolTests) +test('test-zbuff', + zbufftest, + args: [ZSTREAM_TESTTIME], + timeout: 120) +test('test-zstream-1', + zstreamtest, + args: ['-v', ZSTREAM_TESTTIME] + FUZZER_FLAGS, + timeout: 120) +test('test-zstream-2', + zstreamtest, + args: ['-mt', '-t1', ZSTREAM_TESTTIME] + FUZZER_FLAGS, + timeout: 120) +test('test-zstream-3', + zstreamtest, + args: ['--newapi', '-t1', ZSTREAM_TESTTIME] + FUZZER_FLAGS, + timeout: 120) +test('test-longmatch', longmatch, timeout: 36) +test('test-invalidDictionaries', invalidDictionaries) # should be fast +test('test-symbols', symbols) # should be fast +test('test-legacy', legacy) # should be fast +test('test-decodecorpus', + decodecorpus, + args: ['-t', DECODECORPUS_TESTTIME], + timeout: 60) +test('test-poolTests', poolTests) # should be fast From f8975236555a2712e75783b80d1019998f54b118 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 3 Dec 2018 11:02:42 +0700 Subject: [PATCH 41/41] meson: Update usage of InstallSymlink helper --- build/meson/InstallSymlink.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build/meson/InstallSymlink.py b/build/meson/InstallSymlink.py index 6dd151530..9c68cb33e 100644 --- a/build/meson/InstallSymlink.py +++ b/build/meson/InstallSymlink.py @@ -29,19 +29,19 @@ def install_symlink(src, dst, install_dir, dst_is_dir=False, dir_mode=0o777): 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)) + print('File exists: {!r} -> {!r}'.format(new_dst, src)) return - print('Installing symlink %r -> %r' % (new_dst, src)) + print('Installing symlink {!r} -> {!r}'.format(new_dst, src)) os.symlink(src, new_dst, dst_is_dir) def main(): import argparse - parser = argparse.ArgumentParser(description='Install a symlink.\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\n' + '\tDESTDIR=./staging InstallSymlink.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')