Move contrib/meson to build/meson

This commit is contained in:
Lzu Tao
2018-12-01 23:18:59 +07:00
parent c0e71cae55
commit beb13bd87e
11 changed files with 0 additions and 0 deletions
-45
View File
@@ -1,45 +0,0 @@
#!/usr/bin/env python3
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
import re
import sys
def usage():
print('usage: python3 GetZstdLibraryVersion.py <path/to/zstd.h>')
sys.exit(1)
def find_version(filepath):
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]+)
#\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.")
def main():
if len(sys.argv) < 2:
usage()
filepath = sys.argv[1]
version_tup = find_version(filepath)
print('.'.join(version_tup))
if __name__ == '__main__':
main()
-72
View File
@@ -1,72 +0,0 @@
#!/usr/bin/env python3
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
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()
-31
View File
@@ -1,31 +0,0 @@
This Meson project is provided with no guarantee and maintained
by Dima Krasner <dima@dimakrasner.com>.
It outputs one `libzstd`, either shared or static, depending on
`default_library` option.
How to build
============
`cd` to this meson directory (`zstd/contrib/meson`) and type:
```sh
meson --buildtype=release --strip --prefix=/usr builddir
cd builddir
ninja # to build
ninja install # to install
```
You might want to install it in staging directory:
```sh
DESTDIR=./staging ninja install
```
To configure the build, use:
```sh
meson configure
```
See [man meson(1)](https://manpages.debian.org/testing/meson/meson.1.en.html).
@@ -1,33 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
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')
gen_html_includes = include_directories(programs_dir,
library_dir,
library_common_dir,
contrib_gen_html_dir)
gen_html = executable('gen_html',
join_paths(contrib_gen_html_dir, '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)
-12
View File
@@ -1,12 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present Dima Krasner <dima@dimakrasner.com>
# lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
subdir('pzstd')
subdir('gen_html')
-32
View File
@@ -1,32 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
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')]
pzstd = executable('pzstd',
pzstd_sources,
cpp_args: [ '-DNDEBUG', '-Wno-shadow', '-pedantic' ],
include_directories: pzstd_includes,
link_with: libzstd,
dependencies: [ thread_dep ],
install: true)
-120
View File
@@ -1,120 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present Dima Krasner <dima@dimakrasner.com>
# lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
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')
libzstd_includes = [include_directories(library_dir,
library_common_dir,
library_compress_dir,
library_decompress_dir,
library_dictbuilder_dir,
library_deprecated_dir)]
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')]
if legacy_support == '0'
legacy_support = 'false'
endif
if legacy_support != 'false'
if legacy_support == 'true'
legacy_support = '5'
endif
legacy_int = 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
if enable_multithread
message('Enable multi-threading support')
add_project_arguments('-DZSTD_MULTITHREAD', language: 'c')
libzstd_deps = [ thread_dep ]
else
libzstd_deps = []
endif
libzstd = library('zstd',
libzstd_sources,
include_directories: libzstd_includes,
dependencies: libzstd_deps,
install: true,
soversion: zstd_version)
pkgconfig.generate(name: 'libzstd',
filebase: 'libzstd',
libraries: [libzstd],
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'),
join_paths(library_dictbuilder_dir, 'zdict.h'),
join_paths(library_common_dir, 'zstd_errors.h'))
-117
View File
@@ -1,117 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present Dima Krasner <dima@dimakrasner.com>
# lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
project('zstd',
['c', 'cpp'],
license: 'BSD',
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')
pkgconfig = import('pkgconfig')
python3 = import('python').find_installation()
zstd_version = meson.project_version()
# =============================================================================
# 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_source_dir = join_paths('..', '..')
library_dir = join_paths(zstd_source_dir, 'lib')
contrib_meson_dir = join_paths(zstd_source_dir, 'contrib', 'meson')
# =============================================================================
# Project options
# =============================================================================
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')
# =============================================================================
# Helper scripts for Meson
# =============================================================================
GetZstdLibraryVersion_py = files('GetZstdLibraryVersion.py')
# =============================================================================
# Getting project version from 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()
if output.version_compare('>@0@'.format(zstd_version))
zstd_version = output
message('Project version is now: @0@'.format(zstd_version))
endif
endif
# =============================================================================
# Dependencies
# =============================================================================
libm_dep = cc.find_library('m', required: true)
thread_dep = dependency('threads', required: false)
zlib_dep = dependency('zlib', required: false)
lzma_dep = dependency('liblzma', required: false)
lz4_dep = dependency('liblz4', required: false)
# =============================================================================
# Compiler flags
# =============================================================================
if cxx.get_id() == 'gcc' or cxx.get_id() == 'clang'
common_flags = [ '-DXXH_NAMESPACE=ZSTD_' ]
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
# =============================================================================
# Subdirs
# =============================================================================
subdir('lib')
if enable_programs
subdir('programs')
endif
if enable_tests
subdir('tests')
endif
if enable_contrib
subdir('contrib')
endif
-28
View File
@@ -1,28 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present Dima Krasner <dima@dimakrasner.com>
# lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
option('multithread_support', type: 'boolean', value: true,
description: 'Enable multi-threading when pthread is detected')
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')
option('build_contrib', type: 'boolean', value: false,
description: 'Enable contrib build')
option('build_tests', type: 'boolean', value: false,
description: 'Enable tests build')
option('use_static_runtime', type: 'boolean', value: false,
description: 'Link to static run-time libraries on MSVC')
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')
-98
View File
@@ -1,98 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present Dima Krasner <dima@dimakrasner.com>
# lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
zstd_source_dir = join_paths('..', '..', '..')
programs_dir = join_paths(zstd_source_dir, 'programs')
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_c_args = []
if enable_multithread
zstd_c_args += [ '-DZSTD_MULTITHREAD' ]
endif
zstd_deps = []
if enable_zlib and zlib_dep.found()
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' ]
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,
include_directories: libzstd_includes,
link_with: libzstd,
dependencies: zstd_deps,
install: true)
zstd_frugal_sources = [join_paths(programs_dir, 'zstdcli.c'),
util_c_file,
fileio_c_file]
executable('zstd-frugal',
zstd_frugal_sources,
include_directories: libzstd_includes,
link_with: libzstd,
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
# =============================================================================
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
meson.add_install_script(InstallSymlink_py, 'zstd', 'zstdmt', zstd_bindir)
endif
# =============================================================================
# Manpages
# =============================================================================
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'))
# 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)
if enable_multithread
meson.add_install_script(InstallSymlink_py, 'zstd.1.gz', 'zstdmt.1.gz', zstd_man1_dir)
endif
-65
View File
@@ -1,65 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present Dima Krasner <dima@dimakrasner.com>
# lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
zstd_source_dir = join_paths('..', '..', '..')
programs_dir = join_paths(zstd_source_dir, 'programs')
tests_dir = join_paths(zstd_source_dir, 'tests')
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')
datagen_sources = [datagen_c_file,
join_paths(tests_dir, 'datagencli.c')]
test_includes = libzstd_includes + [include_directories(programs_dir)]
datagen = executable('datagen',
datagen_sources,
include_directories: test_includes,
link_with: libzstd,
install: false)
test('datagen', datagen)
fullbench_sources = [datagen_c_file,
util_c_file,
benchfn_c_file,
join_paths(programs_dir, 'benchzstd.c'),
join_paths(tests_dir, 'fullbench.c')]
fullbench = executable('fullbench',
fullbench_sources,
include_directories: test_includes,
link_with: libzstd,
install: false)
test('fullbench', fullbench)
fuzzer_sources = [datagen_c_file,
util_c_file,
join_paths(tests_dir, 'fuzzer.c')]
fuzzer = executable('fuzzer',
fuzzer_sources,
include_directories: test_includes,
link_with: libzstd,
install: false)
test('fuzzer', fuzzer)
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)
endif