From c1f25eaec0f8fde1782f55995f7d8095fdc931e2 Mon Sep 17 00:00:00 2001 From: Dima Krasner Date: Thu, 16 Feb 2017 19:35:56 +0200 Subject: [PATCH 1/5] Added a Meson project --- build/README.md | 1 + build/meson/meson.build | 70 +++++++++++++++++++++++++++++++++++ build/meson/meson_options.txt | 1 + 3 files changed, 72 insertions(+) create mode 100644 build/meson/meson.build create mode 100644 build/meson/meson_options.txt diff --git a/build/README.md b/build/README.md index c4abe9ef..ca88e5cf 100644 --- a/build/README.md +++ b/build/README.md @@ -5,6 +5,7 @@ Projects for various integrated development environments (IDE) The following projects are included with the zstd distribution: - `cmake` - CMake project contributed by Artyom Dymchenko +- `meson` - Meson project contributed by Dima Krasner - `VS2005` - Visual Studio 2005 project - `VS2008` - Visual Studio 2008 project - `VS2010` - Visual Studio 2010 project (which also works well with Visual Studio 2012, 2013, 2015) diff --git a/build/meson/meson.build b/build/meson/meson.build new file mode 100644 index 00000000..b17128bd --- /dev/null +++ b/build/meson/meson.build @@ -0,0 +1,70 @@ +project('zstd', 'c', license: 'BSD') + +libm = meson.get_compiler('c').find_library('m', required: true) + +lib_dir = join_paths(meson.source_root(), '..', '..', 'lib') +common_dir = join_paths(lib_dir, 'common') +compress_dir = join_paths(lib_dir, 'compress') +decompress_dir = join_paths(lib_dir, 'decompress') +dictbuilder_dir = join_paths(lib_dir, 'dictBuilder') +deprecated_dir = join_paths(lib_dir, 'deprecated') + +lib_srcs = [join_paths(common_dir, 'entropy_common.c'), join_paths(common_dir, 'fse_decompress.c'), join_paths(common_dir, 'threading.c'), join_paths(common_dir, 'pool.c'), join_paths(common_dir, 'zstd_common.c'), join_paths(common_dir, 'error_private.c'), join_paths(common_dir, 'xxhash.c'), join_paths(compress_dir, 'fse_compress.c'), join_paths(compress_dir, 'huf_compress.c'), join_paths(compress_dir, 'zstd_compress.c'), join_paths(compress_dir, 'zstdmt_compress.c'), join_paths(decompress_dir, 'huf_decompress.c'), join_paths(decompress_dir, 'zstd_decompress.c'), join_paths(dictbuilder_dir, 'cover.c'), join_paths(dictbuilder_dir, 'divsufsort.c'), join_paths(dictbuilder_dir, 'zdict.c'), join_paths(deprecated_dir, 'zbuff_common.c'), join_paths(deprecated_dir, 'zbuff_compress.c'), join_paths(deprecated_dir, 'zbuff_decompress.c')] + +libzstd_includes = [include_directories(common_dir, dictbuilder_dir, compress_dir, lib_dir)] + +if get_option('legacy_support') + message('Enabling legacy support') + libzstd_cflags = ['-DZSTD_LEGACY_SUPPORT=1'] + + legacy_dir = join_paths(lib_dir, 'legacy') + libzstd_includes += [include_directories(legacy_dir)] + lib_srcs += [join_paths(legacy_dir, 'zstd_v01.c'), join_paths(legacy_dir, 'zstd_v02.c'), join_paths(legacy_dir, 'zstd_v03.c'), join_paths(legacy_dir, 'zstd_v04.c'), join_paths(legacy_dir, 'zstd_v05.c'), join_paths(legacy_dir, 'zstd_v06.c'), join_paths(legacy_dir, 'zstd_v07.c')] +else + libzstd_cflags = [] +endif + +libzstd = library('zstd', + lib_srcs, + include_directories: libzstd_includes, + c_args: libzstd_cflags, + install: true) + +programs_dir = join_paths(meson.source_root(), '..', '..', 'programs') + +zstd = executable('zstd', + join_paths(programs_dir, 'bench.c'), join_paths(programs_dir, 'datagen.c'), join_paths(programs_dir, 'dibio.c'), join_paths(programs_dir, 'fileio.c'), join_paths(programs_dir, 'zstdcli.c'), + include_directories: libzstd_includes, + c_args: ['-DZSTD_NODICT', '-DZSTD_NOBENCH'], + link_with: libzstd, + install: true) + +tests_dir = join_paths(meson.source_root(), '..', '..', 'tests') +datagen_c = join_paths(programs_dir, 'datagen.c') +test_includes = libzstd_includes + [include_directories(programs_dir)] + +fullbench = executable('fullbench', + datagen_c, join_paths(tests_dir, 'fullbench.c'), + include_directories: test_includes, + link_with: libzstd) +test('fullbench', fullbench) + +fuzzer = executable('fuzzer', + datagen_c, join_paths(tests_dir, 'fuzzer.c'), + include_directories: test_includes, + link_with: libzstd) +test('fuzzer', fuzzer) + +if target_machine.system() != 'windows' + paramgrill = executable('paramgrill', + datagen_c, join_paths(tests_dir, 'paramgrill.c'), + include_directories: test_includes, + link_with: libzstd, + dependencies: libm) + test('paramgrill', paramgrill) + + datagen = executable('datagen', + datagen_c, join_paths(tests_dir, 'datagencli.c'), + include_directories: test_includes, + link_with: libzstd) +endif diff --git a/build/meson/meson_options.txt b/build/meson/meson_options.txt new file mode 100644 index 00000000..0b3d62a3 --- /dev/null +++ b/build/meson/meson_options.txt @@ -0,0 +1 @@ +option('legacy_support', type: 'boolean', value: false) From faaded197611de64be10fd6e53db192e5d0e90f8 Mon Sep 17 00:00:00 2001 From: Dima Krasner Date: Fri, 17 Feb 2017 12:27:13 +0200 Subject: [PATCH 2/5] Added multi-threaded library support --- build/meson/meson.build | 14 +++++++++++--- build/meson/meson_options.txt | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/build/meson/meson.build b/build/meson/meson.build index b17128bd..0f9d3117 100644 --- a/build/meson/meson.build +++ b/build/meson/meson.build @@ -9,7 +9,7 @@ decompress_dir = join_paths(lib_dir, 'decompress') dictbuilder_dir = join_paths(lib_dir, 'dictBuilder') deprecated_dir = join_paths(lib_dir, 'deprecated') -lib_srcs = [join_paths(common_dir, 'entropy_common.c'), join_paths(common_dir, 'fse_decompress.c'), join_paths(common_dir, 'threading.c'), join_paths(common_dir, 'pool.c'), join_paths(common_dir, 'zstd_common.c'), join_paths(common_dir, 'error_private.c'), join_paths(common_dir, 'xxhash.c'), join_paths(compress_dir, 'fse_compress.c'), join_paths(compress_dir, 'huf_compress.c'), join_paths(compress_dir, 'zstd_compress.c'), join_paths(compress_dir, 'zstdmt_compress.c'), join_paths(decompress_dir, 'huf_decompress.c'), join_paths(decompress_dir, 'zstd_decompress.c'), join_paths(dictbuilder_dir, 'cover.c'), join_paths(dictbuilder_dir, 'divsufsort.c'), join_paths(dictbuilder_dir, 'zdict.c'), join_paths(deprecated_dir, 'zbuff_common.c'), join_paths(deprecated_dir, 'zbuff_compress.c'), join_paths(deprecated_dir, 'zbuff_decompress.c')] +libzstd_srcs = [join_paths(common_dir, 'entropy_common.c'), join_paths(common_dir, 'fse_decompress.c'), join_paths(common_dir, 'threading.c'), join_paths(common_dir, 'pool.c'), join_paths(common_dir, 'zstd_common.c'), join_paths(common_dir, 'error_private.c'), join_paths(common_dir, 'xxhash.c'), join_paths(compress_dir, 'fse_compress.c'), join_paths(compress_dir, 'huf_compress.c'), join_paths(compress_dir, 'zstd_compress.c'), join_paths(compress_dir, 'zstdmt_compress.c'), join_paths(decompress_dir, 'huf_decompress.c'), join_paths(decompress_dir, 'zstd_decompress.c'), join_paths(dictbuilder_dir, 'cover.c'), join_paths(dictbuilder_dir, 'divsufsort.c'), join_paths(dictbuilder_dir, 'zdict.c'), join_paths(deprecated_dir, 'zbuff_common.c'), join_paths(deprecated_dir, 'zbuff_compress.c'), join_paths(deprecated_dir, 'zbuff_decompress.c')] libzstd_includes = [include_directories(common_dir, dictbuilder_dir, compress_dir, lib_dir)] @@ -19,15 +19,23 @@ if get_option('legacy_support') legacy_dir = join_paths(lib_dir, 'legacy') libzstd_includes += [include_directories(legacy_dir)] - lib_srcs += [join_paths(legacy_dir, 'zstd_v01.c'), join_paths(legacy_dir, 'zstd_v02.c'), join_paths(legacy_dir, 'zstd_v03.c'), join_paths(legacy_dir, 'zstd_v04.c'), join_paths(legacy_dir, 'zstd_v05.c'), join_paths(legacy_dir, 'zstd_v06.c'), join_paths(legacy_dir, 'zstd_v07.c')] + libzstd_srcs += [join_paths(legacy_dir, 'zstd_v01.c'), join_paths(legacy_dir, 'zstd_v02.c'), join_paths(legacy_dir, 'zstd_v03.c'), join_paths(legacy_dir, 'zstd_v04.c'), join_paths(legacy_dir, 'zstd_v05.c'), join_paths(legacy_dir, 'zstd_v06.c'), join_paths(legacy_dir, 'zstd_v07.c')] else libzstd_cflags = [] endif +if get_option('multithread') + add_global_arguments('-DZSTD_MULTITHREAD', language: 'c') + libzstd_deps = [dependency('threads')] +else + libzstd_deps = [] +endif + libzstd = library('zstd', - lib_srcs, + libzstd_srcs, include_directories: libzstd_includes, c_args: libzstd_cflags, + dependencies: libzstd_deps, install: true) programs_dir = join_paths(meson.source_root(), '..', '..', 'programs') diff --git a/build/meson/meson_options.txt b/build/meson/meson_options.txt index 0b3d62a3..0a12f43e 100644 --- a/build/meson/meson_options.txt +++ b/build/meson/meson_options.txt @@ -1 +1,2 @@ +option('multithread', type: 'boolean', value: false) option('legacy_support', type: 'boolean', value: false) From da145123c5f90586cd42973e92efbe9fcb0debf6 Mon Sep 17 00:00:00 2001 From: Dima Krasner Date: Fri, 17 Feb 2017 12:29:23 +0200 Subject: [PATCH 3/5] Updated the README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6336d900..7782972d 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,10 @@ A `cmake` project generator is provided within `build/cmake`. It can generate Makefiles or other build scripts to create `zstd` binary, and `libzstd` dynamic and static libraries. +#### Meson + +A Meson project is provided within `build/meson`. + #### Visual (Windows) Going into `build` directory, you will find additional possibilities : From 4c05b09f27041d177623b640950123936c4e1345 Mon Sep 17 00:00:00 2001 From: Dima Krasner Date: Fri, 17 Feb 2017 12:32:16 +0200 Subject: [PATCH 4/5] Added a message when multhread=true --- build/meson/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/build/meson/meson.build b/build/meson/meson.build index 0f9d3117..36946133 100644 --- a/build/meson/meson.build +++ b/build/meson/meson.build @@ -25,6 +25,7 @@ else endif if get_option('multithread') + message('Enabling multi-threading support') add_global_arguments('-DZSTD_MULTITHREAD', language: 'c') libzstd_deps = [dependency('threads')] else From 107c9a4e421f28fd80d4b6b3e3751c651dc2ef7c Mon Sep 17 00:00:00 2001 From: Dima Krasner Date: Sat, 18 Feb 2017 23:30:57 +0200 Subject: [PATCH 5/5] Moved to contrib --- README.md | 2 +- build/README.md | 1 - contrib/meson/README | 3 +++ {build => contrib}/meson/meson.build | 0 {build => contrib}/meson/meson_options.txt | 0 5 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 contrib/meson/README rename {build => contrib}/meson/meson.build (100%) rename {build => contrib}/meson/meson_options.txt (100%) diff --git a/README.md b/README.md index 7782972d..229571b3 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ to create `zstd` binary, and `libzstd` dynamic and static libraries. #### Meson -A Meson project is provided within `build/meson`. +A Meson project is provided within `contrib/meson`. #### Visual (Windows) diff --git a/build/README.md b/build/README.md index ca88e5cf..c4abe9ef 100644 --- a/build/README.md +++ b/build/README.md @@ -5,7 +5,6 @@ Projects for various integrated development environments (IDE) The following projects are included with the zstd distribution: - `cmake` - CMake project contributed by Artyom Dymchenko -- `meson` - Meson project contributed by Dima Krasner - `VS2005` - Visual Studio 2005 project - `VS2008` - Visual Studio 2008 project - `VS2010` - Visual Studio 2010 project (which also works well with Visual Studio 2012, 2013, 2015) diff --git a/contrib/meson/README b/contrib/meson/README new file mode 100644 index 00000000..0b5331e6 --- /dev/null +++ b/contrib/meson/README @@ -0,0 +1,3 @@ +This Meson project is provided with no guarantee and maintained by Dima Krasner . + +It outputs one libzstd, either shared or static, depending on default_library. diff --git a/build/meson/meson.build b/contrib/meson/meson.build similarity index 100% rename from build/meson/meson.build rename to contrib/meson/meson.build diff --git a/build/meson/meson_options.txt b/contrib/meson/meson_options.txt similarity index 100% rename from build/meson/meson_options.txt rename to contrib/meson/meson_options.txt