From 9863b660449ba5440bcd52d71b1ede106c5412d7 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Thu, 2 Sep 2021 00:03:00 +0700 Subject: [PATCH 01/25] WIP: Add meson build scripts --- .gitignore | 25 +++++++++++++++++++++ datrie/meson.build | 47 ++++++++++++++++++++++++++++++++++++++ meson.build | 56 ++++++++++++++++++++++++++++++++++++++++++++++ meson_options.txt | 1 + tools/meson.build | 9 ++++++++ 5 files changed, 138 insertions(+) create mode 100644 .gitignore create mode 100644 datrie/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 tools/meson.build diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..7ad8a15a --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +Makefile.in +aclocal.m4 +autom4te.cache +m4 +depcomp +config.h.in +configure +config.h +config.log +config.status +config.guess +config.sub +INSTALL +install-sh +missing +libtool +ltmain.sh +Makefile +stamp-h1 +.deps +build-aux/compile +build-aux/test-driver +*~ +datrie-*.pc +doc/Doxyfile diff --git a/datrie/meson.build b/datrie/meson.build new file mode 100644 index 00000000..42df35ca --- /dev/null +++ b/datrie/meson.build @@ -0,0 +1,47 @@ +datrie = library( + 'datrie', + + 'typedefs.h', + 'triedefs.h', + 'trie-private.h', + 'dstring.h', + 'dstring-private.h', + 'dstring.c', + 'trie-string.h', + 'trie-string.c', + 'fileutils.h', + 'fileutils.c', + 'darray.h', + 'darray.c', + 'tail.h', + 'tail.c', + 'trie.h', + 'trie.c', + 'alpha-map.h', + 'alpha-map-private.h', + 'alpha-map.c', + + dependencies : deps, + install : true, +) + +install_headers( + 'typedefs.h', + 'triedefs.h', + 'alpha-map.h', + 'trie.h', + subdir : 'datrie', +) +# TODO: gen pkgconfig + +# if LD_HAS_VERSION_SCRIPT +# EXPORTS_FLAGS = -Wl,-version-script -Wl,$(srcdir)/libdatrie.map +# EXPORTS_DEPS = libdatrie.map +# else +# EXPORTS_FLAGS = -export-symbols $(srcdir)/libdatrie.def +# EXPORTS_DEPS = libdatrie.def +# endif + +# libdatrie_la_LDFLAGS = -no-undefined \ +# -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ +# $(EXPORTS_FLAGS) diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..8573d5ed --- /dev/null +++ b/meson.build @@ -0,0 +1,56 @@ +project('datrie', 'c', version : '0.2.13') # TODO: How to get this?? +conf_data = configuration_data() + +conf_data.set_quoted('VERSION', meson.project_version()) + +# TODO: Doxygen + +# LT_CURRENT=5 +# LT_REVISION=0 +# LT_AGE=4 + +compiler = meson.get_compiler('c') + +deps = [] + +compiler_has_iconv = compiler.has_function('iconv_open') +iconv_pkgconfig = get_option('iconv_pkgconfig') +if iconv_pkgconfig.auto() + if not compiler_has_iconv + deps += dependency('iconv') + endif +elif iconv_pkgconfig.enabled() + deps += dependency('iconv') +elif iconv_pkgconfig.disabled() + if not compiler_has_iconv + error('No usable iconv() implementation found') + endif +endif + +have_locale_charset = compiler.has_function('locale_charset', dependencies : deps) +if have_locale_charset + conf_data.set('HAVE_LOCALE_CHARSET', 1) +endif + +have_langinfo_codeset = compiler.compiles(''' +#include +void func() { char *codeset = nl_langinfo (CODESET); } +''', name : 'nl_langinfo (CODESET)') +if have_langinfo_codeset + conf_data.set('HAVE_LANGINFO_CODESET', 1) +endif + +if not have_locale_charset and not have_langinfo_codeset + error('No locale_charset() nor nl_langinfo(CODESET) found.\nPlease consider installing GNU libiconv') +endif + +# LD_HAS_VERSION_SCRIPT? whether linker supports -version-script + +configure_file(output : 'config.h', configuration: conf_data) +configuration_inc = include_directories('.') + +# Subdir: man doc tests +subdir('datrie') +subdir('tools') + +# FIXME: Dist diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..ba8647f0 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('iconv_pkgconfig', type : 'feature', value : 'auto', description : 'Search for iconv with pkg-config or equivalent') diff --git a/tools/meson.build b/tools/meson.build new file mode 100644 index 00000000..e6c4e1de --- /dev/null +++ b/tools/meson.build @@ -0,0 +1,9 @@ +trietool = executable( + 'trietool', + 'trietool.c', + dependencies : deps, + link_with : datrie, + install : true, + include_directories : configuration_inc, +) +# install trietool-0.2 symlink From 1fff582b11bb9e2942fe0d44c6873e30ba6b5b33 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Thu, 2 Sep 2021 08:57:23 +0700 Subject: [PATCH 02/25] meson: Add linker info --- build-aux/test.map | 1 + datrie/meson.build | 25 ++++++++++++------------- meson.build | 19 +++++++++++-------- tools/meson.build | 4 +++- 4 files changed, 27 insertions(+), 22 deletions(-) create mode 100644 build-aux/test.map diff --git a/build-aux/test.map b/build-aux/test.map new file mode 100644 index 00000000..9b1f1bee --- /dev/null +++ b/build-aux/test.map @@ -0,0 +1 @@ +{global:hello; local:*;}; diff --git a/datrie/meson.build b/datrie/meson.build index 42df35ca..53b6c61b 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -1,3 +1,12 @@ +ldflags = [ + '-Wl,-no-undefined', +] +if ld_has_version_script + ldflags += [ + '-Wl,--version-script,@0@/libdatrie.map'.format(meson.current_source_dir()) + ] +endif + datrie = library( 'datrie', @@ -23,6 +32,9 @@ datrie = library( dependencies : deps, install : true, + link_args : ldflags, + link_depends : ['libdatrie.map', 'libdatrie.def'], + version : meson.project_version(), ) install_headers( @@ -32,16 +44,3 @@ install_headers( 'trie.h', subdir : 'datrie', ) -# TODO: gen pkgconfig - -# if LD_HAS_VERSION_SCRIPT -# EXPORTS_FLAGS = -Wl,-version-script -Wl,$(srcdir)/libdatrie.map -# EXPORTS_DEPS = libdatrie.map -# else -# EXPORTS_FLAGS = -export-symbols $(srcdir)/libdatrie.def -# EXPORTS_DEPS = libdatrie.def -# endif - -# libdatrie_la_LDFLAGS = -no-undefined \ -# -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -# $(EXPORTS_FLAGS) diff --git a/meson.build b/meson.build index 8573d5ed..d54eeeca 100644 --- a/meson.build +++ b/meson.build @@ -1,13 +1,15 @@ -project('datrie', 'c', version : '0.2.13') # TODO: How to get this?? -conf_data = configuration_data() +project('datrie', 'c', version: '1.4.0') -conf_data.set_quoted('VERSION', meson.project_version()) +sh = find_program('sh') -# TODO: Doxygen +version = run_command(files('build-aux/git-version-gen'), check : true) +# FIXME: Make thid work +meson.add_dist_script(sh, '-c', 'echo "@0@" > $MESON_DIST_ROOT/VERSION'.format(version)) -# LT_CURRENT=5 -# LT_REVISION=0 -# LT_AGE=4 +conf_data = configuration_data() +conf_data.set_quoted('VERSION', version.stdout()) + +# TODO: Doxygen compiler = meson.get_compiler('c') @@ -44,7 +46,8 @@ if not have_locale_charset and not have_langinfo_codeset error('No locale_charset() nor nl_langinfo(CODESET) found.\nPlease consider installing GNU libiconv') endif -# LD_HAS_VERSION_SCRIPT? whether linker supports -version-script +ld_has_version_script = compiler.has_link_argument('-Wl,-version-script,@0@/build-aux/test.map'.format(meson.global_source_root())) +# TODO: gen pkgconfig configure_file(output : 'config.h', configuration: conf_data) configuration_inc = include_directories('.') diff --git a/tools/meson.build b/tools/meson.build index e6c4e1de..f18966c3 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -6,4 +6,6 @@ trietool = executable( install : true, include_directories : configuration_inc, ) -# install trietool-0.2 symlink + +meson.add_install_script(sh, '-c', 'rm "$MESON_INSTALL_DESTDIR_PREFIX/bin/trietool-0.2" || true') +meson.add_install_script(sh, '-c', 'ln -s "$MESON_INSTALL_DESTDIR_PREFIX/bin/trietool" "$MESON_INSTALL_DESTDIR_PREFIX/bin/trietool-0.2"') From c4072128443226ab3b18c354dd666b920fb8f2c9 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Thu, 2 Sep 2021 23:56:28 +0700 Subject: [PATCH 03/25] meson: Test and docs --- configure.ac | 2 +- datrie/meson.build | 10 ++++++---- doc/meson.build | 42 ++++++++++++++++++++++++++++++++++++++++++ man/meson.build | 4 ++++ meson.build | 15 ++++++++------- meson_options.txt | 2 ++ tests/meson.build | 10 ++++++++++ tools/meson.build | 4 ++-- 8 files changed, 75 insertions(+), 14 deletions(-) create mode 100644 doc/meson.build create mode 100644 man/meson.build create mode 100644 tests/meson.build diff --git a/configure.ac b/configure.ac index 0b3b897f..0b191201 100644 --- a/configure.ac +++ b/configure.ac @@ -126,7 +126,7 @@ fi dnl where to install the doxygen-generated HTML doc AC_ARG_WITH(html-docdir, [AS_HELP_STRING([--with-html-docdir=DIR], - [where to install the doxyten-generated HTML doc [PREFIX/share/doc/datrie/html]])], + [where to install the doxygen-generated HTML doc [PREFIX/share/doc/datrie/html]])], [htmldocdir="$withval"], [htmldocdir=\$\{prefix\}/share/doc/datrie/html]) AC_SUBST(htmldocdir) diff --git a/datrie/meson.build b/datrie/meson.build index 53b6c61b..b8dcfb26 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -3,13 +3,11 @@ ldflags = [ ] if ld_has_version_script ldflags += [ - '-Wl,--version-script,@0@/libdatrie.map'.format(meson.current_source_dir()) + '-Wl,--version-script,@0@'.format(meson.current_source_dir() / 'libdatrie.map') ] endif -datrie = library( - 'datrie', - +datrie_src = files( 'typedefs.h', 'triedefs.h', 'trie-private.h', @@ -29,6 +27,10 @@ datrie = library( 'alpha-map.h', 'alpha-map-private.h', 'alpha-map.c', +) + +datrie = library( + 'datrie', datrie_src, dependencies : deps, install : true, diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 00000000..c7214325 --- /dev/null +++ b/doc/meson.build @@ -0,0 +1,42 @@ +if get_option('docs').disabled() + subdir_done() +endif + +required_doxygen_version = '>=1.9.1' + +doxygen = find_program('doxygen', required : get_option('docs')) +if not doxygen.found() + subdir_done() +endif +doxygen_version = run_command(doxygen, '--version') +if not doxygen_version.stdout().version_compare(required_doxygen_version) + message = 'Doxygen version @0@ is under requirements @1@'.format(doxygen_version, required_doxygen_version) + if get_option('docs').enabled() + error(message) + else + warning(message) + subdir_done() + endif +endif + +doxyfile_data = configuration_data() +doxyfile_data.set('VERSION', version.stdout()) +doxyfile_data.set('PACKAGE', meson.project_name()) +doxyfile_data.set('top_builddir', meson.build_root()) +doxyfile_data.set('top_srcdir', meson.source_root()) + +doxyfile = configure_file( + input : 'Doxyfile.in', + output : 'Doxyfile', + configuration : doxyfile_data, +) + +custom_target( + 'docs', + input : doxyfile, + output : 'html', + command : [doxygen, doxyfile], + depend_files : datrie_src, + install : true, + install_dir: get_option('docsdir'), +) diff --git a/man/meson.build b/man/meson.build new file mode 100644 index 00000000..3b8abf94 --- /dev/null +++ b/man/meson.build @@ -0,0 +1,4 @@ +install_man('trietool.1') + +mandir_abs = '$DESTDIR' + get_option('prefix') / get_option('mandir') +meson.add_install_script(sh, '-c', 'cd @0@ && ln -s trietool.1 trietool-0.2.1 || true'.format(mandir_abs / 'man1')) diff --git a/meson.build b/meson.build index d54eeeca..b8ab47bf 100644 --- a/meson.build +++ b/meson.build @@ -1,16 +1,13 @@ -project('datrie', 'c', version: '1.4.0') +project('libdatrie', 'c', version: '1.4.0', meson_version : '>=0.49.0') sh = find_program('sh') version = run_command(files('build-aux/git-version-gen'), check : true) -# FIXME: Make thid work -meson.add_dist_script(sh, '-c', 'echo "@0@" > $MESON_DIST_ROOT/VERSION'.format(version)) +# meson.add_dist_script(sh, '-c', 'echo "@0@" > $MESON_DIST_ROOT/VERSION'.format(version)) conf_data = configuration_data() conf_data.set_quoted('VERSION', version.stdout()) -# TODO: Doxygen - compiler = meson.get_compiler('c') deps = [] @@ -46,14 +43,18 @@ if not have_locale_charset and not have_langinfo_codeset error('No locale_charset() nor nl_langinfo(CODESET) found.\nPlease consider installing GNU libiconv') endif -ld_has_version_script = compiler.has_link_argument('-Wl,-version-script,@0@/build-aux/test.map'.format(meson.global_source_root())) +ld_has_version_script = compiler.has_link_argument( + '-Wl,-version-script,@0@'.format(meson.source_root() / 'build-aux' / 'test.map') +) # TODO: gen pkgconfig configure_file(output : 'config.h', configuration: conf_data) configuration_inc = include_directories('.') -# Subdir: man doc tests subdir('datrie') +subdir('tests') subdir('tools') +subdir('man') +subdir('doc') # FIXME: Dist diff --git a/meson_options.txt b/meson_options.txt index ba8647f0..35df1c82 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1,3 @@ option('iconv_pkgconfig', type : 'feature', value : 'auto', description : 'Search for iconv with pkg-config or equivalent') +option('docs', type : 'feature', value : 'auto', description : 'Build docs') +option('docsdir', type : 'string', value : 'share/doc/datrie', description : 'Where to install the doxygen-generated HTML doc') diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 00000000..bc7b23cd --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,10 @@ +tests = [ + 'walk', 'iterator', 'store-retrieve', 'file', + 'serialization', 'nonalpha', 'null_trie', + 'term_state', 'byte_alpha', 'byte_list', +] + +foreach item : tests + exe = executable('test_' + item, 'test_@0@.c'.format(item), 'utils.c', link_with : datrie) + test(item, exe) +endforeach diff --git a/tools/meson.build b/tools/meson.build index f18966c3..37c54c85 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -7,5 +7,5 @@ trietool = executable( include_directories : configuration_inc, ) -meson.add_install_script(sh, '-c', 'rm "$MESON_INSTALL_DESTDIR_PREFIX/bin/trietool-0.2" || true') -meson.add_install_script(sh, '-c', 'ln -s "$MESON_INSTALL_DESTDIR_PREFIX/bin/trietool" "$MESON_INSTALL_DESTDIR_PREFIX/bin/trietool-0.2"') +bindir_abs = '$DESTDIR' + get_option('prefix') + '/' + get_option('bindir') +meson.add_install_script(sh, '-c', 'cd @0@ && ln -s trietool trietool-0.2 || true'.format(bindir_abs)) From 5fdd61beca7381f6a6ebf0813e0f153d2e6e703d Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Fri, 3 Sep 2021 00:05:27 +0700 Subject: [PATCH 04/25] Add objects files to ignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 7ad8a15a..6b6b03d7 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ build-aux/test-driver *~ datrie-*.pc doc/Doxyfile +*.o + From 3fe3efcafc8e4c853d14d9f4eaa4d7b60fd22283 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Sat, 4 Sep 2021 22:42:49 +0700 Subject: [PATCH 05/25] Add pkgconfig build --- datrie/meson.build | 8 ++++++++ meson.build | 13 ++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/datrie/meson.build b/datrie/meson.build index b8dcfb26..70f41346 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -46,3 +46,11 @@ install_headers( 'trie.h', subdir : 'datrie', ) + +pkg = import('pkgconfig') +pkg.generate( + datrie, + description : 'Double-array trie library', + url : 'https://github.com/tlwg/libdatrie', + version : version.stdout(), +) diff --git a/meson.build b/meson.build index b8ab47bf..9d662146 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,8 @@ project('libdatrie', 'c', version: '1.4.0', meson_version : '>=0.49.0') sh = find_program('sh') +compiler = meson.get_compiler('c') +deps = [] version = run_command(files('build-aux/git-version-gen'), check : true) # meson.add_dist_script(sh, '-c', 'echo "@0@" > $MESON_DIST_ROOT/VERSION'.format(version)) @@ -8,10 +10,7 @@ version = run_command(files('build-aux/git-version-gen'), check : true) conf_data = configuration_data() conf_data.set_quoted('VERSION', version.stdout()) -compiler = meson.get_compiler('c') - -deps = [] - +# Detect for iconv compiler_has_iconv = compiler.has_function('iconv_open') iconv_pkgconfig = get_option('iconv_pkgconfig') if iconv_pkgconfig.auto() @@ -26,11 +25,13 @@ elif iconv_pkgconfig.disabled() endif endif +# Detect for locale_charset have_locale_charset = compiler.has_function('locale_charset', dependencies : deps) if have_locale_charset conf_data.set('HAVE_LOCALE_CHARSET', 1) endif +# Detect for nl_langinfo(CODESET) have_langinfo_codeset = compiler.compiles(''' #include void func() { char *codeset = nl_langinfo (CODESET); } @@ -43,14 +44,16 @@ if not have_locale_charset and not have_langinfo_codeset error('No locale_charset() nor nl_langinfo(CODESET) found.\nPlease consider installing GNU libiconv') endif +# Detect for version-script support ld_has_version_script = compiler.has_link_argument( '-Wl,-version-script,@0@'.format(meson.source_root() / 'build-aux' / 'test.map') ) -# TODO: gen pkgconfig +# Generate config.h configure_file(output : 'config.h', configuration: conf_data) configuration_inc = include_directories('.') +# Build! subdir('datrie') subdir('tests') subdir('tools') From debcd3091696c4c8b8ee04912c55eff80eea9410 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Sat, 4 Sep 2021 22:54:41 +0700 Subject: [PATCH 06/25] Build with include_directories to root --- datrie/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/datrie/meson.build b/datrie/meson.build index 70f41346..93b3a6b5 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -37,6 +37,7 @@ datrie = library( link_args : ldflags, link_depends : ['libdatrie.map', 'libdatrie.def'], version : meson.project_version(), + include_directories : configuration_inc, ) install_headers( From 11d5a1da9ec5aa038b3bad6f00899d983e4d88c5 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Sat, 4 Sep 2021 23:00:26 +0700 Subject: [PATCH 07/25] Add include_directory for tests --- tests/meson.build | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/meson.build b/tests/meson.build index bc7b23cd..22f29dc2 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -5,6 +5,12 @@ tests = [ ] foreach item : tests - exe = executable('test_' + item, 'test_@0@.c'.format(item), 'utils.c', link_with : datrie) + exe = executable( + 'test_' + item, + 'test_@0@.c'.format(item), + 'utils.c', + link_with : datrie, + include_directories : configuration_inc, + ) test(item, exe) endforeach From 2b8e6c8e9c2b7f3c6a1d0acf5ddb714fc06e7469 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Sat, 4 Sep 2021 23:06:08 +0700 Subject: [PATCH 08/25] Space instead of tabs --- datrie/meson.build | 80 +++++++++++++++++++++++----------------------- doc/meson.build | 38 +++++++++++----------- tests/meson.build | 22 ++++++------- tools/meson.build | 12 +++---- 4 files changed, 76 insertions(+), 76 deletions(-) diff --git a/datrie/meson.build b/datrie/meson.build index 93b3a6b5..3971e825 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -1,57 +1,57 @@ ldflags = [ - '-Wl,-no-undefined', + '-Wl,-no-undefined', ] if ld_has_version_script - ldflags += [ - '-Wl,--version-script,@0@'.format(meson.current_source_dir() / 'libdatrie.map') - ] + ldflags += [ + '-Wl,--version-script,@0@'.format(meson.current_source_dir() / 'libdatrie.map') + ] endif datrie_src = files( - 'typedefs.h', - 'triedefs.h', - 'trie-private.h', - 'dstring.h', - 'dstring-private.h', - 'dstring.c', - 'trie-string.h', - 'trie-string.c', - 'fileutils.h', - 'fileutils.c', - 'darray.h', - 'darray.c', - 'tail.h', - 'tail.c', - 'trie.h', - 'trie.c', - 'alpha-map.h', - 'alpha-map-private.h', - 'alpha-map.c', + 'alpha-map-private.h', + 'alpha-map.c', + 'alpha-map.h', + 'darray.c', + 'darray.h', + 'dstring-private.h', + 'dstring.c', + 'dstring.h', + 'fileutils.c', + 'fileutils.h', + 'tail.c', + 'tail.h', + 'trie-private.h', + 'trie-string.c', + 'trie-string.h', + 'trie.c', + 'trie.h', + 'triedefs.h', + 'typedefs.h', ) datrie = library( - 'datrie', datrie_src, - - dependencies : deps, - install : true, - link_args : ldflags, - link_depends : ['libdatrie.map', 'libdatrie.def'], - version : meson.project_version(), - include_directories : configuration_inc, + 'datrie', datrie_src, + + dependencies : deps, + install : true, + link_args : ldflags, + link_depends : ['libdatrie.map', 'libdatrie.def'], + version : meson.project_version(), + include_directories : configuration_inc, ) install_headers( - 'typedefs.h', - 'triedefs.h', - 'alpha-map.h', - 'trie.h', - subdir : 'datrie', + 'alpha-map.h', + 'trie.h', + 'triedefs.h', + 'typedefs.h', + subdir : 'datrie', ) pkg = import('pkgconfig') pkg.generate( - datrie, - description : 'Double-array trie library', - url : 'https://github.com/tlwg/libdatrie', - version : version.stdout(), + datrie, + description : 'Double-array trie library', + url : 'https://github.com/tlwg/libdatrie', + version : version.stdout(), ) diff --git a/doc/meson.build b/doc/meson.build index c7214325..161a6668 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -1,22 +1,22 @@ if get_option('docs').disabled() - subdir_done() + subdir_done() endif required_doxygen_version = '>=1.9.1' doxygen = find_program('doxygen', required : get_option('docs')) if not doxygen.found() - subdir_done() + subdir_done() endif doxygen_version = run_command(doxygen, '--version') if not doxygen_version.stdout().version_compare(required_doxygen_version) - message = 'Doxygen version @0@ is under requirements @1@'.format(doxygen_version, required_doxygen_version) - if get_option('docs').enabled() - error(message) - else - warning(message) - subdir_done() - endif + message = 'Doxygen version @0@ is under requirements @1@'.format(doxygen_version, required_doxygen_version) + if get_option('docs').enabled() + error(message) + else + warning(message) + subdir_done() + endif endif doxyfile_data = configuration_data() @@ -26,17 +26,17 @@ doxyfile_data.set('top_builddir', meson.build_root()) doxyfile_data.set('top_srcdir', meson.source_root()) doxyfile = configure_file( - input : 'Doxyfile.in', - output : 'Doxyfile', - configuration : doxyfile_data, + input : 'Doxyfile.in', + output : 'Doxyfile', + configuration : doxyfile_data, ) custom_target( - 'docs', - input : doxyfile, - output : 'html', - command : [doxygen, doxyfile], - depend_files : datrie_src, - install : true, - install_dir: get_option('docsdir'), + 'docs', + input : doxyfile, + output : 'html', + command : [doxygen, doxyfile], + depend_files : datrie_src, + install : true, + install_dir: get_option('docsdir'), ) diff --git a/tests/meson.build b/tests/meson.build index 22f29dc2..a49a8acd 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,16 +1,16 @@ tests = [ - 'walk', 'iterator', 'store-retrieve', 'file', - 'serialization', 'nonalpha', 'null_trie', - 'term_state', 'byte_alpha', 'byte_list', + 'walk', 'iterator', 'store-retrieve', 'file', + 'serialization', 'nonalpha', 'null_trie', + 'term_state', 'byte_alpha', 'byte_list', ] foreach item : tests - exe = executable( - 'test_' + item, - 'test_@0@.c'.format(item), - 'utils.c', - link_with : datrie, - include_directories : configuration_inc, - ) - test(item, exe) + exe = executable( + 'test_' + item, + 'test_@0@.c'.format(item), + 'utils.c', + link_with : datrie, + include_directories : configuration_inc, + ) + test(item, exe) endforeach diff --git a/tools/meson.build b/tools/meson.build index 37c54c85..62e2a31f 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -1,10 +1,10 @@ trietool = executable( - 'trietool', - 'trietool.c', - dependencies : deps, - link_with : datrie, - install : true, - include_directories : configuration_inc, + 'trietool', + 'trietool.c', + dependencies : deps, + link_with : datrie, + install : true, + include_directories : configuration_inc, ) bindir_abs = '$DESTDIR' + get_option('prefix') + '/' + get_option('bindir') From 745dfb25348c00e501a364865887741e714737b9 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Sat, 4 Sep 2021 23:11:10 +0700 Subject: [PATCH 09/25] Test for no-undefined --- datrie/meson.build | 2 +- meson.build | 30 +++++++++++++++++++----------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/datrie/meson.build b/datrie/meson.build index 3971e825..39f89d82 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -1,5 +1,5 @@ ldflags = [ - '-Wl,-no-undefined', + ld_no_undefined, ] if ld_has_version_script ldflags += [ diff --git a/meson.build b/meson.build index 9d662146..a2947474 100644 --- a/meson.build +++ b/meson.build @@ -14,21 +14,21 @@ conf_data.set_quoted('VERSION', version.stdout()) compiler_has_iconv = compiler.has_function('iconv_open') iconv_pkgconfig = get_option('iconv_pkgconfig') if iconv_pkgconfig.auto() - if not compiler_has_iconv - deps += dependency('iconv') - endif + if not compiler_has_iconv + deps += dependency('iconv') + endif elif iconv_pkgconfig.enabled() - deps += dependency('iconv') + deps += dependency('iconv') elif iconv_pkgconfig.disabled() - if not compiler_has_iconv - error('No usable iconv() implementation found') - endif + if not compiler_has_iconv + error('No usable iconv() implementation found') + endif endif # Detect for locale_charset have_locale_charset = compiler.has_function('locale_charset', dependencies : deps) if have_locale_charset - conf_data.set('HAVE_LOCALE_CHARSET', 1) + conf_data.set('HAVE_LOCALE_CHARSET', 1) endif # Detect for nl_langinfo(CODESET) @@ -37,18 +37,26 @@ have_langinfo_codeset = compiler.compiles(''' void func() { char *codeset = nl_langinfo (CODESET); } ''', name : 'nl_langinfo (CODESET)') if have_langinfo_codeset - conf_data.set('HAVE_LANGINFO_CODESET', 1) + conf_data.set('HAVE_LANGINFO_CODESET', 1) endif if not have_locale_charset and not have_langinfo_codeset - error('No locale_charset() nor nl_langinfo(CODESET) found.\nPlease consider installing GNU libiconv') + error('No locale_charset() nor nl_langinfo(CODESET) found.\nPlease consider installing GNU libiconv') endif # Detect for version-script support ld_has_version_script = compiler.has_link_argument( - '-Wl,-version-script,@0@'.format(meson.source_root() / 'build-aux' / 'test.map') + '-Wl,-version-script,@0@'.format(meson.source_root() / 'build-aux' / 'test.map') ) +# Detect no-undefined flag +ld_no_undefined = '' +if compiler.has_link_argument('-Wl,-no-undefined') + ld_no_undefined = '-Wl,-no-undefined' +elif compiler.has_link_argument('-Wl,-undefined,error') + ld_no_undefined = '-Wl,-undefined,error' +endif + # Generate config.h configure_file(output : 'config.h', configuration: conf_data) configuration_inc = include_directories('.') From 00df12281f27772a3c46e1ec98c73f245b3ddeb1 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Sun, 5 Sep 2021 11:38:40 +0700 Subject: [PATCH 10/25] Use libdatrie_dep to build test --- datrie/meson.build | 4 ++++ tests/meson.build | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/datrie/meson.build b/datrie/meson.build index 39f89d82..1543afb4 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -39,6 +39,10 @@ datrie = library( version : meson.project_version(), include_directories : configuration_inc, ) +libdatrie_dep = declare_dependency( + include_directories : configuration_inc, + link_with : datrie +) install_headers( 'alpha-map.h', diff --git a/tests/meson.build b/tests/meson.build index a49a8acd..6d4b7061 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -9,8 +9,7 @@ foreach item : tests 'test_' + item, 'test_@0@.c'.format(item), 'utils.c', - link_with : datrie, - include_directories : configuration_inc, + dependencies : libdatrie_dep, ) test(item, exe) endforeach From 711089ac58cafac181295f6efc829042a8081bbc Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Sun, 5 Sep 2021 11:54:17 +0700 Subject: [PATCH 11/25] Rename pkgconfig file --- datrie/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/datrie/meson.build b/datrie/meson.build index 1543afb4..fb2652a2 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -55,6 +55,7 @@ install_headers( pkg = import('pkgconfig') pkg.generate( datrie, + filebase : 'datrie-0.2', description : 'Double-array trie library', url : 'https://github.com/tlwg/libdatrie', version : version.stdout(), From b60d706612d2638ad2f20ccd263fc2daae94d0e2 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Sun, 5 Sep 2021 19:03:18 +0700 Subject: [PATCH 12/25] Add support for Windows build --- datrie/meson.build | 29 ++++++++++++++++++++++++----- doc/meson.build | 2 +- man/meson.build | 6 ++++-- meson.build | 14 +++++++++----- tools/meson.build | 10 ++++++++-- 5 files changed, 46 insertions(+), 15 deletions(-) diff --git a/datrie/meson.build b/datrie/meson.build index fb2652a2..bdffe106 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -1,12 +1,30 @@ -ldflags = [ - ld_no_undefined, -] +ldflags = [] +link_depends = ['libdatrie.map'] + +if ld_no_undefined != '' + ldflags += [ld_no_undefined] +endif + if ld_has_version_script ldflags += [ '-Wl,--version-script,@0@'.format(meson.current_source_dir() / 'libdatrie.map') ] endif +if compiler.get_id() == 'msvc' + link_def = custom_target( + 'link-def', + input : ['libdatrie.def'], + command : [find_program('powershell'), '-Command', '''& { + Write-Output "EXPORTS" > @OUTPUT0@ + Get-Content -Path @INPUT0@ >> @OUTPUT0@ + }'''], + output : 'libdatrie.def', + ) + ldflags += [ '/def:@0@'.format(link_def.full_path()) ] + link_depends += [link_def] +endif + datrie_src = files( 'alpha-map-private.h', 'alpha-map.c', @@ -35,9 +53,10 @@ datrie = library( dependencies : deps, install : true, link_args : ldflags, - link_depends : ['libdatrie.map', 'libdatrie.def'], + link_depends : link_depends, version : meson.project_version(), include_directories : configuration_inc, + vs_module_defs : 'libdatrie.def', ) libdatrie_dep = declare_dependency( include_directories : configuration_inc, @@ -58,5 +77,5 @@ pkg.generate( filebase : 'datrie-0.2', description : 'Double-array trie library', url : 'https://github.com/tlwg/libdatrie', - version : version.stdout(), + version : version, ) diff --git a/doc/meson.build b/doc/meson.build index 161a6668..b44fc3ad 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -20,7 +20,7 @@ if not doxygen_version.stdout().version_compare(required_doxygen_version) endif doxyfile_data = configuration_data() -doxyfile_data.set('VERSION', version.stdout()) +doxyfile_data.set('VERSION', version) doxyfile_data.set('PACKAGE', meson.project_name()) doxyfile_data.set('top_builddir', meson.build_root()) doxyfile_data.set('top_srcdir', meson.source_root()) diff --git a/man/meson.build b/man/meson.build index 3b8abf94..d97d5db3 100644 --- a/man/meson.build +++ b/man/meson.build @@ -1,4 +1,6 @@ install_man('trietool.1') -mandir_abs = '$DESTDIR' + get_option('prefix') / get_option('mandir') -meson.add_install_script(sh, '-c', 'cd @0@ && ln -s trietool.1 trietool-0.2.1 || true'.format(mandir_abs / 'man1')) +mandir_abs = get_option('prefix') / get_option('mandir') +if sh.found() + meson.add_install_script(sh, '-c', 'cd @0@ && ln -s trietool.1 trietool-0.2.1 || true'.format(mandir_abs / 'man1')) +endif \ No newline at end of file diff --git a/meson.build b/meson.build index a2947474..30ca66c8 100644 --- a/meson.build +++ b/meson.build @@ -1,14 +1,18 @@ project('libdatrie', 'c', version: '1.4.0', meson_version : '>=0.49.0') -sh = find_program('sh') +sh = find_program('sh', required : false) compiler = meson.get_compiler('c') deps = [] -version = run_command(files('build-aux/git-version-gen'), check : true) -# meson.add_dist_script(sh, '-c', 'echo "@0@" > $MESON_DIST_ROOT/VERSION'.format(version)) +if sh.found() + version = run_command(files('build-aux/git-version-gen'), check : true).stdout() + # meson.add_dist_script(sh, '-c', 'echo "@0@" > $MESON_DIST_ROOT/VERSION'.format(version)) +else + version = '0.0.0' +endif conf_data = configuration_data() -conf_data.set_quoted('VERSION', version.stdout()) +conf_data.set_quoted('VERSION', version) # Detect for iconv compiler_has_iconv = compiler.has_function('iconv_open') @@ -41,7 +45,7 @@ if have_langinfo_codeset endif if not have_locale_charset and not have_langinfo_codeset - error('No locale_charset() nor nl_langinfo(CODESET) found.\nPlease consider installing GNU libiconv') + warning('No locale_charset() nor nl_langinfo(CODESET) found. Please consider installing GNU libiconv') endif # Detect for version-script support diff --git a/tools/meson.build b/tools/meson.build index 62e2a31f..2a456c68 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -1,3 +1,7 @@ +if not have_locale_charset and not have_langinfo_codeset + subdir_done() +endif + trietool = executable( 'trietool', 'trietool.c', @@ -7,5 +11,7 @@ trietool = executable( include_directories : configuration_inc, ) -bindir_abs = '$DESTDIR' + get_option('prefix') + '/' + get_option('bindir') -meson.add_install_script(sh, '-c', 'cd @0@ && ln -s trietool trietool-0.2 || true'.format(bindir_abs)) +bindir_abs = get_option('prefix') + '/' + get_option('bindir') +if sh.found() + meson.add_install_script(sh, '-c', 'cd @0@ && ln -s trietool trietool-0.2 || true'.format(bindir_abs)) +endif From 80fdeb7ad66e7445efc808e796ec9fbe7e40a094 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Sun, 12 Sep 2021 11:21:10 +0700 Subject: [PATCH 13/25] Version stamp for tarball --- datrie/meson.build | 2 +- doc/meson.build | 14 +------------- man/meson.build | 4 +--- meson.build | 16 ++++++++++------ tools/meson.build | 4 +--- 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/datrie/meson.build b/datrie/meson.build index bdffe106..cb1bf871 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -15,7 +15,7 @@ if compiler.get_id() == 'msvc' link_def = custom_target( 'link-def', input : ['libdatrie.def'], - command : [find_program('powershell'), '-Command', '''& { + command : [powershell, '-Command', '''& { Write-Output "EXPORTS" > @OUTPUT0@ Get-Content -Path @INPUT0@ >> @OUTPUT0@ }'''], diff --git a/doc/meson.build b/doc/meson.build index b44fc3ad..a36a9477 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -2,22 +2,10 @@ if get_option('docs').disabled() subdir_done() endif -required_doxygen_version = '>=1.9.1' - -doxygen = find_program('doxygen', required : get_option('docs')) +doxygen = find_program('doxygen', required : get_option('docs'), version : '>=1.9.1') if not doxygen.found() subdir_done() endif -doxygen_version = run_command(doxygen, '--version') -if not doxygen_version.stdout().version_compare(required_doxygen_version) - message = 'Doxygen version @0@ is under requirements @1@'.format(doxygen_version, required_doxygen_version) - if get_option('docs').enabled() - error(message) - else - warning(message) - subdir_done() - endif -endif doxyfile_data = configuration_data() doxyfile_data.set('VERSION', version) diff --git a/man/meson.build b/man/meson.build index d97d5db3..d6f53faa 100644 --- a/man/meson.build +++ b/man/meson.build @@ -1,6 +1,4 @@ install_man('trietool.1') mandir_abs = get_option('prefix') / get_option('mandir') -if sh.found() - meson.add_install_script(sh, '-c', 'cd @0@ && ln -s trietool.1 trietool-0.2.1 || true'.format(mandir_abs / 'man1')) -endif \ No newline at end of file +meson.add_install_script(sh, '-c', 'cd @0@ && ln -s trietool.1 trietool-0.2.1 || true'.format(mandir_abs / 'man1')) diff --git a/meson.build b/meson.build index 30ca66c8..ff254835 100644 --- a/meson.build +++ b/meson.build @@ -1,15 +1,19 @@ -project('libdatrie', 'c', version: '1.4.0', meson_version : '>=0.49.0') +project('libdatrie', 'c', version: '1.4.0', meson_version : '>=0.53.0') -sh = find_program('sh', required : false) +fs = import('fs') + +sh = find_program('sh') compiler = meson.get_compiler('c') +powershell = find_program('powershell', required : compiler.get_id() == 'msvc') +cat = find_program('cat') deps = [] -if sh.found() - version = run_command(files('build-aux/git-version-gen'), check : true).stdout() - # meson.add_dist_script(sh, '-c', 'echo "@0@" > $MESON_DIST_ROOT/VERSION'.format(version)) +if fs.exists('VERSION') + version = run_command(cat, files('VERSION'), check : true).stdout().strip() else - version = '0.0.0' + version = run_command(files('build-aux/git-version-gen'), check : true).stdout().strip() endif +meson.add_dist_script(sh, '-c', 'echo "@0@" > $MESON_DIST_ROOT/VERSION'.format(version)) conf_data = configuration_data() conf_data.set_quoted('VERSION', version) diff --git a/tools/meson.build b/tools/meson.build index 2a456c68..dc0b86e4 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -12,6 +12,4 @@ trietool = executable( ) bindir_abs = get_option('prefix') + '/' + get_option('bindir') -if sh.found() - meson.add_install_script(sh, '-c', 'cd @0@ && ln -s trietool trietool-0.2 || true'.format(bindir_abs)) -endif +meson.add_install_script(sh, '-c', 'cd @0@ && ln -s trietool trietool-0.2 || true'.format(bindir_abs)) From 7edf5c0c8452a1c8dcc454b7910a0fea00a47328 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Sun, 12 Sep 2021 11:23:20 +0700 Subject: [PATCH 14/25] Run autogen on dist --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index ff254835..f5eb23a6 100644 --- a/meson.build +++ b/meson.build @@ -14,6 +14,7 @@ else version = run_command(files('build-aux/git-version-gen'), check : true).stdout().strip() endif meson.add_dist_script(sh, '-c', 'echo "@0@" > $MESON_DIST_ROOT/VERSION'.format(version)) +meson.add_dist_script(sh, '-c', 'cd $MESON_DIST_ROOT && ./autogen.sh') conf_data = configuration_data() conf_data.set_quoted('VERSION', version) From 8279decf83474c12d401c6fb45313b405f26a742 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Sun, 12 Sep 2021 11:30:37 +0700 Subject: [PATCH 15/25] Add meson files to automake dist --- Makefile.am | 3 +++ datrie/Makefile.am | 2 +- doc/Makefile.am | 2 ++ man/Makefile.am | 2 +- tests/Makefile.am | 2 ++ tools/Makefile.am | 2 ++ 6 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 11974458..3e945564 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,6 +5,9 @@ SUBDIRS = datrie tools man doc tests EXTRA_DIST = \ README.migration \ build-aux/git-version-gen \ + build-aux/test.map \ + meson.build \ + meson_options.txt \ $(NULL) pkgconfigdir = $(libdir)/pkgconfig diff --git a/datrie/Makefile.am b/datrie/Makefile.am index e46af461..504906a1 100644 --- a/datrie/Makefile.am +++ b/datrie/Makefile.am @@ -6,7 +6,7 @@ pkginclude_HEADERS = \ alpha-map.h \ trie.h -EXTRA_DIST = libdatrie.map libdatrie.def +EXTRA_DIST = libdatrie.map libdatrie.def meson.build AM_CPPFLAGS = -I$(top_srcdir) diff --git a/doc/Makefile.am b/doc/Makefile.am index d9e041b3..f11a8c58 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,3 +1,5 @@ +EXTRA_DIST = meson.build + if ENABLE_DOXYGEN_DOC all-local: doxygen.stamp diff --git a/man/Makefile.am b/man/Makefile.am index 58a53cba..e46272b0 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,4 +1,4 @@ -EXTRA_DIST = trietool.1 +EXTRA_DIST = trietool.1 meson.build man_MANS = trietool.1 diff --git a/tests/Makefile.am b/tests/Makefile.am index 41b55cb8..5ad402eb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,7 @@ AM_CPPFLAGS = -I$(top_srcdir) +EXTRA_DIST = meson.build + TESTS_ENVIRONMENT = top_builddir=$(top_builddir) TESTS = \ diff --git a/tools/Makefile.am b/tools/Makefile.am index 992530bc..69778d8b 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,5 +1,7 @@ AM_CPPFLAGS = -I$(top_srcdir) +EXTRA_DIST = meson.build + bin_PROGRAMS = trietool trietool_SOURCES = trietool.c From 5d8a61aef9c57e348d81e0a876a21d8b78a53d4a Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Sun, 12 Sep 2021 11:36:42 +0700 Subject: [PATCH 16/25] Docs meson building --- INSTALL | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/INSTALL b/INSTALL index c8938b3d..7af3b80e 100644 --- a/INSTALL +++ b/INSTALL @@ -1,6 +1,11 @@ Basic Installation ================== +libdatrie can be build by Autotools or Meson + +Autotools build +------------------ + # Build requirements: # - libtool # - iconv support (normally from glibc on GNU systems; some systems might @@ -25,3 +30,22 @@ make install # In order to uninstall make uninstall +Meson build +--------------- + +# Build requirements: +# - meson 0.53 or better +# - iconv support +# - doxygen (optional, for documentation generation) +# +# Recommended build dependencies: +# - CMake for iconv detection + +# Add -Ddocs=disabled to disable documentation generation +meson setup builddir --buildtype release --default-library both --strip --prefix=... + +cd builddir +ninja test + +# With elevated permissions if required +ninja install From 242cc7515f3979306689243dc82625db68e2aee6 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 13 Sep 2021 15:40:26 +0700 Subject: [PATCH 17/25] Detect iconv by compiler.find_library --- datrie/meson.build | 4 ---- meson.build | 26 +++++--------------------- meson_options.txt | 1 - 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/datrie/meson.build b/datrie/meson.build index cb1bf871..d3c53569 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -1,10 +1,6 @@ ldflags = [] link_depends = ['libdatrie.map'] -if ld_no_undefined != '' - ldflags += [ld_no_undefined] -endif - if ld_has_version_script ldflags += [ '-Wl,--version-script,@0@'.format(meson.current_source_dir() / 'libdatrie.map') diff --git a/meson.build b/meson.build index f5eb23a6..bc1751ea 100644 --- a/meson.build +++ b/meson.build @@ -13,25 +13,17 @@ if fs.exists('VERSION') else version = run_command(files('build-aux/git-version-gen'), check : true).stdout().strip() endif -meson.add_dist_script(sh, '-c', 'echo "@0@" > $MESON_DIST_ROOT/VERSION'.format(version)) -meson.add_dist_script(sh, '-c', 'cd $MESON_DIST_ROOT && ./autogen.sh') +meson.add_dist_script(sh, '-c', 'echo "@0@" > "$MESON_DIST_ROOT/VERSION"'.format(version)) +meson.add_dist_script(sh, '-c', 'cd "$MESON_DIST_ROOT" && ./autogen.sh') conf_data = configuration_data() conf_data.set_quoted('VERSION', version) # Detect for iconv compiler_has_iconv = compiler.has_function('iconv_open') -iconv_pkgconfig = get_option('iconv_pkgconfig') -if iconv_pkgconfig.auto() - if not compiler_has_iconv - deps += dependency('iconv') - endif -elif iconv_pkgconfig.enabled() - deps += dependency('iconv') -elif iconv_pkgconfig.disabled() - if not compiler_has_iconv - error('No usable iconv() implementation found') - endif +iconv = compiler.find_library('iconv', required : not compiler_has_iconv) +if iconv.found() + deps += iconv endif # Detect for locale_charset @@ -58,14 +50,6 @@ ld_has_version_script = compiler.has_link_argument( '-Wl,-version-script,@0@'.format(meson.source_root() / 'build-aux' / 'test.map') ) -# Detect no-undefined flag -ld_no_undefined = '' -if compiler.has_link_argument('-Wl,-no-undefined') - ld_no_undefined = '-Wl,-no-undefined' -elif compiler.has_link_argument('-Wl,-undefined,error') - ld_no_undefined = '-Wl,-undefined,error' -endif - # Generate config.h configure_file(output : 'config.h', configuration: conf_data) configuration_inc = include_directories('.') diff --git a/meson_options.txt b/meson_options.txt index 35df1c82..0dec9af5 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,2 @@ -option('iconv_pkgconfig', type : 'feature', value : 'auto', description : 'Search for iconv with pkg-config or equivalent') option('docs', type : 'feature', value : 'auto', description : 'Build docs') option('docsdir', type : 'string', value : 'share/doc/datrie', description : 'Where to install the doxygen-generated HTML doc') From 96b12eaa44abe58f07e223e4826d39b16651cf93 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Tue, 14 Sep 2021 19:06:41 +0700 Subject: [PATCH 18/25] Remove vs_module_defs --- datrie/meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/datrie/meson.build b/datrie/meson.build index d3c53569..dcb58898 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -52,7 +52,6 @@ datrie = library( link_depends : link_depends, version : meson.project_version(), include_directories : configuration_inc, - vs_module_defs : 'libdatrie.def', ) libdatrie_dep = declare_dependency( include_directories : configuration_inc, From a3a515513dec955cbfbb66855bcf1657158fbfb1 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Wed, 22 May 2024 11:37:56 +0700 Subject: [PATCH 19/25] Fix versioning and tarballing --- .cvsignore | 19 ------------------- .gitattributes | 3 +++ INSTALL | 5 +---- datrie/meson.build | 3 ++- man/meson.build | 3 +-- meson.build | 35 +++++++++++++++++------------------ tools/meson.build | 3 +-- 7 files changed, 25 insertions(+), 46 deletions(-) delete mode 100644 .cvsignore create mode 100644 .gitattributes diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index f23618fd..00000000 --- a/.cvsignore +++ /dev/null @@ -1,19 +0,0 @@ -Makefile.in -aclocal.m4 -autom4te.cache -m4 -depcomp -config.h.in -configure -config.h -config.log -config.status -config.guess -config.sub -INSTALL -install-sh -missing -libtool -ltmain.sh -Makefile -stamp-h1 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..cafe45cb --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +.gitignore export-ignore +.gitattributes export-ignore +nsis/ export-ignore diff --git a/INSTALL b/INSTALL index 7af3b80e..decb8a74 100644 --- a/INSTALL +++ b/INSTALL @@ -34,12 +34,9 @@ Meson build --------------- # Build requirements: -# - meson 0.53 or better +# - meson 1.0 or better # - iconv support # - doxygen (optional, for documentation generation) -# -# Recommended build dependencies: -# - CMake for iconv detection # Add -Ddocs=disabled to disable documentation generation meson setup builddir --buildtype release --default-library both --strip --prefix=... diff --git a/datrie/meson.build b/datrie/meson.build index dcb58898..e78a3f3b 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -50,7 +50,8 @@ datrie = library( install : true, link_args : ldflags, link_depends : link_depends, - version : meson.project_version(), + version : libversion, + soversion : soversion, include_directories : configuration_inc, ) libdatrie_dep = declare_dependency( diff --git a/man/meson.build b/man/meson.build index d6f53faa..51914949 100644 --- a/man/meson.build +++ b/man/meson.build @@ -1,4 +1,3 @@ install_man('trietool.1') -mandir_abs = get_option('prefix') / get_option('mandir') -meson.add_install_script(sh, '-c', 'cd @0@ && ln -s trietool.1 trietool-0.2.1 || true'.format(mandir_abs / 'man1')) +meson.add_install_script(sh, '-c', 'cd ${MESON_INSTALL_DESTDIR_PREFIX}/@0@/man1 && ln -s trietool.1 trietool-0.2.1 || true'.format(get_option('mandir'))) diff --git a/meson.build b/meson.build index bc1751ea..a813b7d9 100644 --- a/meson.build +++ b/meson.build @@ -1,31 +1,32 @@ -project('libdatrie', 'c', version: '1.4.0', meson_version : '>=0.53.0') +project( + 'libdatrie', 'c', meson_version : '>=1.0.0', + version: run_command(files('build-aux/git-version-gen'), check : true).stdout().strip() +) fs = import('fs') sh = find_program('sh') compiler = meson.get_compiler('c') powershell = find_program('powershell', required : compiler.get_id() == 'msvc') -cat = find_program('cat') -deps = [] +deps = [ + dependency('iconv', required: false) +] -if fs.exists('VERSION') - version = run_command(cat, files('VERSION'), check : true).stdout().strip() -else - version = run_command(files('build-aux/git-version-gen'), check : true).stdout().strip() -endif +version = run_command(files('build-aux/git-version-gen'), check : true).stdout().strip() meson.add_dist_script(sh, '-c', 'echo "@0@" > "$MESON_DIST_ROOT/VERSION"'.format(version)) meson.add_dist_script(sh, '-c', 'cd "$MESON_DIST_ROOT" && ./autogen.sh') +meson.add_dist_script(sh, '-c', 'cd "$MESON_DIST_ROOT" && rm -r autom4te.cache autogen.sh || true') + +LT_CURRENT = 5 +LT_REVISION = 0 +LT_AGE = 4 + +soversion = LT_CURRENT - LT_AGE +libversion = '@0@.@1@.@2@'.format(soversion, LT_AGE, LT_REVISION) conf_data = configuration_data() conf_data.set_quoted('VERSION', version) -# Detect for iconv -compiler_has_iconv = compiler.has_function('iconv_open') -iconv = compiler.find_library('iconv', required : not compiler_has_iconv) -if iconv.found() - deps += iconv -endif - # Detect for locale_charset have_locale_charset = compiler.has_function('locale_charset', dependencies : deps) if have_locale_charset @@ -47,7 +48,7 @@ endif # Detect for version-script support ld_has_version_script = compiler.has_link_argument( - '-Wl,-version-script,@0@'.format(meson.source_root() / 'build-aux' / 'test.map') + '-Wl,-version-script,@0@'.format(meson.global_source_root() / 'build-aux' / 'test.map') ) # Generate config.h @@ -60,5 +61,3 @@ subdir('tests') subdir('tools') subdir('man') subdir('doc') - -# FIXME: Dist diff --git a/tools/meson.build b/tools/meson.build index dc0b86e4..a50f551d 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -11,5 +11,4 @@ trietool = executable( include_directories : configuration_inc, ) -bindir_abs = get_option('prefix') + '/' + get_option('bindir') -meson.add_install_script(sh, '-c', 'cd @0@ && ln -s trietool trietool-0.2 || true'.format(bindir_abs)) +meson.add_install_script(sh, '-c', 'cd ${MESON_INSTALL_DESTDIR_PREFIX}/@0@ && ln -s trietool trietool-0.2 || true'.format(get_option('bindir'))) From c0fe2a92ba5e4b74abb8a8865e19e62defd88429 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 27 May 2024 20:34:09 +0700 Subject: [PATCH 20/25] Fix building on windows clang --- datrie/meson.build | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/datrie/meson.build b/datrie/meson.build index e78a3f3b..d26b359b 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -7,13 +7,14 @@ if ld_has_version_script ] endif -if compiler.get_id() == 'msvc' +if compiler.get_linker_id() in ['link', 'lld-link'] link_def = custom_target( 'link-def', input : ['libdatrie.def'], + # This use ASCII as some PS version do not have UTF8NoBOM command : [powershell, '-Command', '''& { - Write-Output "EXPORTS" > @OUTPUT0@ - Get-Content -Path @INPUT0@ >> @OUTPUT0@ + Write-Output "EXPORTS" | Out-File -Encoding ascii -FilePath @OUTPUT0@ + Get-Content -Path @INPUT0@ | Out-File -Append -Encoding ascii -FilePath @OUTPUT0@ }'''], output : 'libdatrie.def', ) From 481ed33b8d761da53309f67eaebda2b3b93f6854 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 27 May 2024 21:16:37 +0700 Subject: [PATCH 21/25] Apply suggestions from code review Co-authored-by: Eli Schwartz --- man/meson.build | 2 +- meson.build | 2 +- tools/meson.build | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/man/meson.build b/man/meson.build index 51914949..45d35493 100644 --- a/man/meson.build +++ b/man/meson.build @@ -1,3 +1,3 @@ install_man('trietool.1') -meson.add_install_script(sh, '-c', 'cd ${MESON_INSTALL_DESTDIR_PREFIX}/@0@/man1 && ln -s trietool.1 trietool-0.2.1 || true'.format(get_option('mandir'))) +install_symlink('trietool-0.2.1', pointing_to: 'trietool.1', install_dir: get_option('mandir') / 'man1') diff --git a/meson.build b/meson.build index a813b7d9..2930e82d 100644 --- a/meson.build +++ b/meson.build @@ -48,7 +48,7 @@ endif # Detect for version-script support ld_has_version_script = compiler.has_link_argument( - '-Wl,-version-script,@0@'.format(meson.global_source_root() / 'build-aux' / 'test.map') + '-Wl,-version-script,@0@'.format(meson.project_source_root() / 'build-aux' / 'test.map') ) # Generate config.h diff --git a/tools/meson.build b/tools/meson.build index a50f551d..5bb5256c 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -11,4 +11,4 @@ trietool = executable( include_directories : configuration_inc, ) -meson.add_install_script(sh, '-c', 'cd ${MESON_INSTALL_DESTDIR_PREFIX}/@0@ && ln -s trietool trietool-0.2 || true'.format(get_option('bindir'))) +install_symlink('trietool-0.2', pointing_to: 'trietool', install_dir: get_option('bindir)) From b0e671d497a4199091a02854569fb3124f40ce6d Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 15:13:23 +0700 Subject: [PATCH 22/25] Fix missing quote --- tools/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/meson.build b/tools/meson.build index 5bb5256c..cc739224 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -11,4 +11,4 @@ trietool = executable( include_directories : configuration_inc, ) -install_symlink('trietool-0.2', pointing_to: 'trietool', install_dir: get_option('bindir)) +install_symlink('trietool-0.2', pointing_to: 'trietool', install_dir: get_option('bindir')) From daa9c6d33ef95931a0796294f005f249af97cc05 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 15:24:20 +0700 Subject: [PATCH 23/25] Add override_dependency, override_find_program --- datrie/meson.build | 2 ++ tools/meson.build | 1 + 2 files changed, 3 insertions(+) diff --git a/datrie/meson.build b/datrie/meson.build index d26b359b..01aea607 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -59,6 +59,8 @@ libdatrie_dep = declare_dependency( include_directories : configuration_inc, link_with : datrie ) +meson.override_dependency('datrie-0.2', libdatrie_dep) +meson.override_dependency('libdatrie', libdatrie_dep) install_headers( 'alpha-map.h', diff --git a/tools/meson.build b/tools/meson.build index cc739224..9756e7e2 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -10,5 +10,6 @@ trietool = executable( install : true, include_directories : configuration_inc, ) +meson.override_find_program('trietool', trietool) install_symlink('trietool-0.2', pointing_to: 'trietool', install_dir: get_option('bindir')) From 558d8ba9aec8298a3883a0b4ec505f5af04e0b1f Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 16:05:56 +0700 Subject: [PATCH 24/25] Fix deprecated option --- doc/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/meson.build b/doc/meson.build index a36a9477..52af70ea 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -10,8 +10,8 @@ endif doxyfile_data = configuration_data() doxyfile_data.set('VERSION', version) doxyfile_data.set('PACKAGE', meson.project_name()) -doxyfile_data.set('top_builddir', meson.build_root()) -doxyfile_data.set('top_srcdir', meson.source_root()) +doxyfile_data.set('top_builddir', meson.project_build_root()) +doxyfile_data.set('top_srcdir', meson.project_source_root()) doxyfile = configure_file( input : 'Doxyfile.in', From 3985d6f7b5e56bc60bb9581337bf6a3782bd71be Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 16:11:42 +0700 Subject: [PATCH 25/25] Reformat with meson fmt --- datrie/meson.build | 50 ++++++++++++++++++++++++++-------------------- doc/meson.build | 22 +++++++++++--------- man/meson.build | 6 +++++- meson.build | 45 +++++++++++++++++++++++++++-------------- tests/meson.build | 15 ++++++++++---- tools/meson.build | 14 ++++++++----- 6 files changed, 96 insertions(+), 56 deletions(-) diff --git a/datrie/meson.build b/datrie/meson.build index 01aea607..fa111b1d 100644 --- a/datrie/meson.build +++ b/datrie/meson.build @@ -3,22 +3,28 @@ link_depends = ['libdatrie.map'] if ld_has_version_script ldflags += [ - '-Wl,--version-script,@0@'.format(meson.current_source_dir() / 'libdatrie.map') + '-Wl,--version-script,@0@'.format( + meson.current_source_dir() / 'libdatrie.map', + ), ] endif if compiler.get_linker_id() in ['link', 'lld-link'] link_def = custom_target( 'link-def', - input : ['libdatrie.def'], + input: ['libdatrie.def'], # This use ASCII as some PS version do not have UTF8NoBOM - command : [powershell, '-Command', '''& { + command: [ + powershell, + '-Command', + '''& { Write-Output "EXPORTS" | Out-File -Encoding ascii -FilePath @OUTPUT0@ Get-Content -Path @INPUT0@ | Out-File -Append -Encoding ascii -FilePath @OUTPUT0@ - }'''], - output : 'libdatrie.def', + }''', + ], + output: 'libdatrie.def', ) - ldflags += [ '/def:@0@'.format(link_def.full_path()) ] + ldflags += ['/def:@0@'.format(link_def.full_path())] link_depends += [link_def] endif @@ -45,19 +51,19 @@ datrie_src = files( ) datrie = library( - 'datrie', datrie_src, - - dependencies : deps, - install : true, - link_args : ldflags, - link_depends : link_depends, - version : libversion, - soversion : soversion, - include_directories : configuration_inc, + 'datrie', + datrie_src, + dependencies: deps, + install: true, + link_args: ldflags, + link_depends: link_depends, + version: libversion, + soversion: soversion, + include_directories: configuration_inc, ) libdatrie_dep = declare_dependency( - include_directories : configuration_inc, - link_with : datrie + include_directories: configuration_inc, + link_with: datrie, ) meson.override_dependency('datrie-0.2', libdatrie_dep) meson.override_dependency('libdatrie', libdatrie_dep) @@ -67,14 +73,14 @@ install_headers( 'trie.h', 'triedefs.h', 'typedefs.h', - subdir : 'datrie', + subdir: 'datrie', ) pkg = import('pkgconfig') pkg.generate( datrie, - filebase : 'datrie-0.2', - description : 'Double-array trie library', - url : 'https://github.com/tlwg/libdatrie', - version : version, + filebase: 'datrie-0.2', + description: 'Double-array trie library', + url: 'https://github.com/tlwg/libdatrie', + version: version, ) diff --git a/doc/meson.build b/doc/meson.build index 52af70ea..25c20f45 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -2,7 +2,11 @@ if get_option('docs').disabled() subdir_done() endif -doxygen = find_program('doxygen', required : get_option('docs'), version : '>=1.9.1') +doxygen = find_program( + 'doxygen', + required: get_option('docs'), + version: '>=1.9.1', +) if not doxygen.found() subdir_done() endif @@ -14,17 +18,17 @@ doxyfile_data.set('top_builddir', meson.project_build_root()) doxyfile_data.set('top_srcdir', meson.project_source_root()) doxyfile = configure_file( - input : 'Doxyfile.in', - output : 'Doxyfile', - configuration : doxyfile_data, + input: 'Doxyfile.in', + output: 'Doxyfile', + configuration: doxyfile_data, ) custom_target( 'docs', - input : doxyfile, - output : 'html', - command : [doxygen, doxyfile], - depend_files : datrie_src, - install : true, + input: doxyfile, + output: 'html', + command: [doxygen, doxyfile], + depend_files: datrie_src, + install: true, install_dir: get_option('docsdir'), ) diff --git a/man/meson.build b/man/meson.build index 45d35493..3844714f 100644 --- a/man/meson.build +++ b/man/meson.build @@ -1,3 +1,7 @@ install_man('trietool.1') -install_symlink('trietool-0.2.1', pointing_to: 'trietool.1', install_dir: get_option('mandir') / 'man1') +install_symlink( + 'trietool-0.2.1', + pointing_to: 'trietool.1', + install_dir: get_option('mandir') / 'man1', +) diff --git a/meson.build b/meson.build index 2930e82d..9c8dc925 100644 --- a/meson.build +++ b/meson.build @@ -1,21 +1,29 @@ project( - 'libdatrie', 'c', meson_version : '>=1.0.0', - version: run_command(files('build-aux/git-version-gen'), check : true).stdout().strip() + 'libdatrie', + 'c', + meson_version: '>=1.0.0', + version: run_command(files('build-aux/git-version-gen'), check: true).stdout().strip(), ) fs = import('fs') sh = find_program('sh') compiler = meson.get_compiler('c') -powershell = find_program('powershell', required : compiler.get_id() == 'msvc') -deps = [ - dependency('iconv', required: false) -] +powershell = find_program('powershell', required: compiler.get_id() == 'msvc') +deps = [dependency('iconv', required: false)] -version = run_command(files('build-aux/git-version-gen'), check : true).stdout().strip() -meson.add_dist_script(sh, '-c', 'echo "@0@" > "$MESON_DIST_ROOT/VERSION"'.format(version)) +version = run_command(files('build-aux/git-version-gen'), check: true).stdout().strip() +meson.add_dist_script( + sh, + '-c', + 'echo "@0@" > "$MESON_DIST_ROOT/VERSION"'.format(version), +) meson.add_dist_script(sh, '-c', 'cd "$MESON_DIST_ROOT" && ./autogen.sh') -meson.add_dist_script(sh, '-c', 'cd "$MESON_DIST_ROOT" && rm -r autom4te.cache autogen.sh || true') +meson.add_dist_script( + sh, + '-c', + 'cd "$MESON_DIST_ROOT" && rm -r autom4te.cache autogen.sh || true', +) LT_CURRENT = 5 LT_REVISION = 0 @@ -28,31 +36,38 @@ conf_data = configuration_data() conf_data.set_quoted('VERSION', version) # Detect for locale_charset -have_locale_charset = compiler.has_function('locale_charset', dependencies : deps) +have_locale_charset = compiler.has_function('locale_charset', dependencies: deps) if have_locale_charset conf_data.set('HAVE_LOCALE_CHARSET', 1) endif # Detect for nl_langinfo(CODESET) -have_langinfo_codeset = compiler.compiles(''' +have_langinfo_codeset = compiler.compiles( + ''' #include void func() { char *codeset = nl_langinfo (CODESET); } -''', name : 'nl_langinfo (CODESET)') +''', + name: 'nl_langinfo (CODESET)', +) if have_langinfo_codeset conf_data.set('HAVE_LANGINFO_CODESET', 1) endif if not have_locale_charset and not have_langinfo_codeset - warning('No locale_charset() nor nl_langinfo(CODESET) found. Please consider installing GNU libiconv') + warning( + 'No locale_charset() nor nl_langinfo(CODESET) found. Please consider installing GNU libiconv', + ) endif # Detect for version-script support ld_has_version_script = compiler.has_link_argument( - '-Wl,-version-script,@0@'.format(meson.project_source_root() / 'build-aux' / 'test.map') + '-Wl,-version-script,@0@'.format( + meson.project_source_root() / 'build-aux' / 'test.map', + ), ) # Generate config.h -configure_file(output : 'config.h', configuration: conf_data) +configure_file(output: 'config.h', configuration: conf_data) configuration_inc = include_directories('.') # Build! diff --git a/tests/meson.build b/tests/meson.build index 6d4b7061..56990f1c 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,7 +1,14 @@ tests = [ - 'walk', 'iterator', 'store-retrieve', 'file', - 'serialization', 'nonalpha', 'null_trie', - 'term_state', 'byte_alpha', 'byte_list', + 'walk', + 'iterator', + 'store-retrieve', + 'file', + 'serialization', + 'nonalpha', + 'null_trie', + 'term_state', + 'byte_alpha', + 'byte_list', ] foreach item : tests @@ -9,7 +16,7 @@ foreach item : tests 'test_' + item, 'test_@0@.c'.format(item), 'utils.c', - dependencies : libdatrie_dep, + dependencies: libdatrie_dep, ) test(item, exe) endforeach diff --git a/tools/meson.build b/tools/meson.build index 9756e7e2..7037de8a 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -5,11 +5,15 @@ endif trietool = executable( 'trietool', 'trietool.c', - dependencies : deps, - link_with : datrie, - install : true, - include_directories : configuration_inc, + dependencies: deps, + link_with: datrie, + install: true, + include_directories: configuration_inc, ) meson.override_find_program('trietool', trietool) -install_symlink('trietool-0.2', pointing_to: 'trietool', install_dir: get_option('bindir')) +install_symlink( + 'trietool-0.2', + pointing_to: 'trietool', + install_dir: get_option('bindir'), +)