]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
meson: Change build options' name
authorLzu Tao <taolzu@gmail.com>
Fri, 30 Nov 2018 14:05:03 +0000 (21:05 +0700)
committerLzu Tao <taolzu@gmail.com>
Sat, 1 Dec 2018 16:18:59 +0000 (23:18 +0700)
build/meson/lib/meson.build
build/meson/meson.build
build/meson/meson_options.txt
build/meson/programs/meson.build
build/meson/tests/meson.build

index 5bfdbb074412aa377f6e0fd8ae915fb5139d9e1b..c39a6553092d0f71304bcba72a54f58f8e5b0f1c 100644 (file)
@@ -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',
index f181fdc32df22a983f38db437b3778de9f0a57f8..c36c9425a1a34b8b9cdf5705fbab7edf46fe90e0 100644 (file)
@@ -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
index d4bac3c4863fb082fcd4abd6e2899243395347a2..349d915c7c495e1fa9aad27e3c0f0660b748e1f0 100644 (file)
@@ -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,
+option('debug_level', type: 'integer', min: 0, max: 9, value: 1,
+  description: 'Enable run-time debug. See lib/common/debug.h')
+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('build_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,
+option('build_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
-  description: 'Enable run-time debug. See lib/common/debug.h')
-option('enable-multithread', type: 'boolean', value: true,
+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('enable-static-runtime', type: 'boolean', value: false,
-  description: 'Link to static run-time libraries on MSVC')
-option('enable-zlib', type: 'boolean', value: false,
+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.')
index 8102eda159dfff4b479658c1c7f83999d611a42d..f538aa556b74fa3a2ff269be52558aca180c1b21 100644 (file)
@@ -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
index 4e127dec3c0ff35c26f7333e7b83bdd8193c6fe7..c8772e7617c0e20d1c3ba93e26819ae0888b242b 100644 (file)
@@ -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