From a317afc2895ba1a581447f11f5fa724073f8511b Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 15:04:28 +0700 Subject: [PATCH 01/13] Add meson build --- data/meson.build | 51 +++++++++++++++++++++++++++++++++ include/meson.build | 22 +++++++++++++++ man/meson.build | 5 ++++ meson.build | 43 ++++++++++++++++++++++++++++ meson_options.txt | 3 ++ src/meson.build | 69 +++++++++++++++++++++++++++++++++++++++++++++ tests/meson.build | 41 +++++++++++++++++++++++++++ 7 files changed, 234 insertions(+) create mode 100644 data/meson.build create mode 100644 include/meson.build create mode 100644 man/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 src/meson.build create mode 100644 tests/meson.build diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 0000000..21abe9d --- /dev/null +++ b/data/meson.build @@ -0,0 +1,51 @@ +dict_dir = get_option('datadir') / 'libthai' + +if get_option('dict') + sort = find_program('sort') + cp = find_program('cp') + trietool = find_program('trietool', dirs : datrie.get_variable('bindir')) + + dictionary = custom_target( + 'tdict', + command : [sort, '-u', '-o', '@OUTPUT@', '@INPUT@'], + env : { + 'LC_ALL': 'C', + }, + input : [ + 'tdict-common.txt', + 'tdict-collection.txt', + 'tdict-currency.txt', + 'tdict-district.txt', + 'tdict-city.txt', + 'tdict-country.txt', + 'tdict-geo.txt', + 'tdict-history.txt', + 'tdict-ict.txt', + 'tdict-lang-ethnic.txt', + 'tdict-proper.txt', + 'tdict-science.txt', + 'tdict-slang.txt', + 'tdict-spell.txt', + 'tdict-std.txt', + 'tdict-std-compound.txt' + ], + output : ['tdict.txt'], + ) + # trietool look for thbrk.abm in the directory of thbrk.tri + # so we need to copy thbrk.abm into the build directory + alphamap = custom_target( + 'alphabet_map', + command : [cp, '@INPUT@', '@OUTPUT@'], + input : ['thbrk.abm'], + output : ['thbrk.abm'], + ) + tri = custom_target( + 'tri', + command : [trietool, 'data/thbrk', 'add-list', '-e', 'utf-8', '@INPUT0@'], + input : [dictionary], + depends : [alphamap], + output : ['thbrk.tri'], + install : true, + install_dir: dict_dir, + ) +endif diff --git a/include/meson.build b/include/meson.build new file mode 100644 index 0000000..3baab26 --- /dev/null +++ b/include/meson.build @@ -0,0 +1,22 @@ +install_headers( + 'thai/thailib.h', + 'thai/thctype.h', + 'thai/thstr.h', + 'thai/thcoll.h', + 'thai/thcell.h', + 'thai/thinp.h', + 'thai/thrend.h', + 'thai/thbrk.h', + 'thai/thwchar.h', + 'thai/thwctype.h', + 'thai/thwcoll.h', + 'thai/thwinp.h', + 'thai/thwrend.h', + 'thai/thwstr.h', + 'thai/thwbrk.h', + 'thai/tis.h', + 'thai/wtt.h', + subdir : 'thai', +) + +include_dir = include_directories('.') diff --git a/man/meson.build b/man/meson.build new file mode 100644 index 0000000..223abd1 --- /dev/null +++ b/man/meson.build @@ -0,0 +1,5 @@ +install_man( + 'man3/libthai.3', + 'man3/thctype.3', + 'man3/wtt.3', +) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..e05e4ed --- /dev/null +++ b/meson.build @@ -0,0 +1,43 @@ +project( + 'libthai', 'c', meson_version : '>=1.0.0', + version: run_command(files('build-aux/git-version-gen'), check : true).stdout().strip() +) + +# --enable-ansi: Removed. C compiler with Meson should be quite mature now +# --enable-debug: Replaced with Meson --buildtype=debug + +sh = find_program('sh') +compiler = meson.get_compiler('c') +datrie = dependency('datrie-0.2') +deps = [ + datrie, +] + +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 = 3 +LT_REVISION = 1 +LT_AGE = 3 + +soversion = LT_CURRENT - LT_AGE +libversion = '@0@.@1@.@2@'.format(soversion, LT_AGE, LT_REVISION) + +# 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') +) + +if get_option('buildtype') in ['debug', 'debugoptimized'] + add_project_arguments('-DNDEBUG', language : ['c']) +endif + +# TODO: Doxygen + +subdir('data') +subdir('include') +subdir('src') +subdir('man') +subdir('tests') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..e22ae68 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,3 @@ +option('docs', type : 'feature', value : 'auto', description : 'Generate documents with Doxygen') +option('docsdir', type : 'string', value : 'share/doc/datrie', description : 'Where to install the Doxygen-generated HTML doc') +option('dict', type : 'boolean', value : true, description : 'Enable dictionary data generation (require libdatrie)') diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..2745c4c --- /dev/null +++ b/src/meson.build @@ -0,0 +1,69 @@ +ldflags = [] +link_depends = ['libthai.map'] + +if ld_has_version_script + ldflags += [ + '-Wl,--version-script,@0@'.format(meson.current_source_dir() / 'libthai.map') + ] +else + ldflags += [ + '-export-symbols @0@'.format(meson.current_source_dir() / 'libthai.map') + ] +endif + +thai = library( + 'thai', + [ + 'thctype/thctype.c', + 'thctype/wtt.c', + + 'thstr/thstr.c', + + 'thcell/thcell.c', + + 'thinp/thinp.c', + + 'thrend/thrend.c', + + 'thcoll/cweight.c', + 'thcoll/cweight.h', + 'thcoll/thcoll.c', + + 'thbrk/thbrk.c', + 'thbrk/thbrk-priv.h', + 'thbrk/thbrk-utils.h', + 'thbrk/brk-ctype.c', + 'thbrk/brk-ctype.h', + 'thbrk/brk-common.c', + 'thbrk/brk-common.h', + 'thbrk/brk-maximal.c', + 'thbrk/brk-maximal.h', + + 'thwchar/thwchar.c', + + 'thwctype/thwctype.c', + + 'thwstr/thwstr.c', + + 'thwbrk/thwbrk.c', + ], + + install : true, + link_args : ldflags, + link_depends : link_depends, + c_args: ['-DDICT_DIR="@0@"'.format(dict_dir)], + dependencies : [datrie], + version : libversion, + soversion : soversion, + include_directories : include_dir, +) + +pkg = import('pkgconfig') +pkg.generate( + thai, + filebase : 'libthai', + name : 'libthai', + description : 'Thai support library', + version : version, + requires_private: datrie, +) diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000..39c4252 --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,41 @@ +fs = import('fs') + +tests = [ + 'thctype', 'thcell', 'thinp', 'thrend', + 'thstr', 'thwchar', +] + +foreach item : tests + exe = executable( + 'test_' + item, + 'test_@0@.c'.format(item), + link_with : thai, + ) + test(item, exe) +endforeach + +# thcoll +thsort = executable('thsort', 'thsort.c', link_with : thai) +test( + 'thcoll', + find_program('test-thcoll.sh'), + depends : [thsort], + env : { + 'srcdir' : meson.current_source_dir(), + 'top_builddir' : meson.project_build_root(), + }, +) + +if get_option('dict') + foreach item : ['thbrk', 'thwbrk'] + exe = executable('test_' + item, 'test_@0@.c'.format(item), link_with : thai) + test( + item, + exe, + depends : [tri], + env : { + 'LIBTHAI_DICTDIR' : fs.parent(tri.full_path()), + }, + ) + endforeach +endif From 6c5cba3615b7ad73cf74bc25ac357b8fb7a9cd85 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 15:29:58 +0700 Subject: [PATCH 02/13] Use libdatrie wrap --- data/meson.build | 2 +- meson.build | 3 --- src/meson.build | 6 +++++- subprojects/libdatrie.wrap | 8 ++++++++ 4 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 subprojects/libdatrie.wrap diff --git a/data/meson.build b/data/meson.build index 21abe9d..581c640 100644 --- a/data/meson.build +++ b/data/meson.build @@ -3,7 +3,7 @@ dict_dir = get_option('datadir') / 'libthai' if get_option('dict') sort = find_program('sort') cp = find_program('cp') - trietool = find_program('trietool', dirs : datrie.get_variable('bindir')) + trietool = find_program('trietool') dictionary = custom_target( 'tdict', diff --git a/meson.build b/meson.build index e05e4ed..2eb3b01 100644 --- a/meson.build +++ b/meson.build @@ -9,9 +9,6 @@ project( sh = find_program('sh') compiler = meson.get_compiler('c') datrie = dependency('datrie-0.2') -deps = [ - datrie, -] 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)) diff --git a/src/meson.build b/src/meson.build index 2745c4c..0ad06d5 100644 --- a/src/meson.build +++ b/src/meson.build @@ -57,6 +57,10 @@ thai = library( soversion : soversion, include_directories : include_dir, ) +libthai_dep = declare_dependency( + include_directories : include_dir, + link_with : thai, +) pkg = import('pkgconfig') pkg.generate( @@ -65,5 +69,5 @@ pkg.generate( name : 'libthai', description : 'Thai support library', version : version, - requires_private: datrie, + requires_private: ['datrie-0.2'], ) diff --git a/subprojects/libdatrie.wrap b/subprojects/libdatrie.wrap new file mode 100644 index 0000000..c5c9b04 --- /dev/null +++ b/subprojects/libdatrie.wrap @@ -0,0 +1,8 @@ +[wrap-git] +url = https://github.com/tlwg/libdatrie.git +revision = daa9c6d33ef95931a0796294f005f249af97cc05 +depth = 1 + +[provide] +dependency_names = datrie-0.2 +program_names = trietool From 15c144b50991b300f0b73368c0dc9915b85c4310 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 15:30:36 +0700 Subject: [PATCH 03/13] Remove debug comments --- meson.build | 3 --- 1 file changed, 3 deletions(-) diff --git a/meson.build b/meson.build index 2eb3b01..3bf1612 100644 --- a/meson.build +++ b/meson.build @@ -3,9 +3,6 @@ project( version: run_command(files('build-aux/git-version-gen'), check : true).stdout().strip() ) -# --enable-ansi: Removed. C compiler with Meson should be quite mature now -# --enable-debug: Replaced with Meson --buildtype=debug - sh = find_program('sh') compiler = meson.get_compiler('c') datrie = dependency('datrie-0.2') From c4e8022e56e29ef006d4ad9b098c803ab11f501d Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 15:41:11 +0700 Subject: [PATCH 04/13] Refactor data --- data/meson.build | 98 ++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/data/meson.build b/data/meson.build index 581c640..53606c0 100644 --- a/data/meson.build +++ b/data/meson.build @@ -1,51 +1,53 @@ dict_dir = get_option('datadir') / 'libthai' -if get_option('dict') - sort = find_program('sort') - cp = find_program('cp') - trietool = find_program('trietool') +if not get_option('dict') + subdir_done() +endif - dictionary = custom_target( - 'tdict', - command : [sort, '-u', '-o', '@OUTPUT@', '@INPUT@'], - env : { - 'LC_ALL': 'C', - }, - input : [ - 'tdict-common.txt', - 'tdict-collection.txt', - 'tdict-currency.txt', - 'tdict-district.txt', - 'tdict-city.txt', - 'tdict-country.txt', - 'tdict-geo.txt', - 'tdict-history.txt', - 'tdict-ict.txt', - 'tdict-lang-ethnic.txt', - 'tdict-proper.txt', - 'tdict-science.txt', - 'tdict-slang.txt', - 'tdict-spell.txt', - 'tdict-std.txt', - 'tdict-std-compound.txt' - ], - output : ['tdict.txt'], - ) - # trietool look for thbrk.abm in the directory of thbrk.tri - # so we need to copy thbrk.abm into the build directory - alphamap = custom_target( - 'alphabet_map', - command : [cp, '@INPUT@', '@OUTPUT@'], - input : ['thbrk.abm'], - output : ['thbrk.abm'], - ) - tri = custom_target( - 'tri', - command : [trietool, 'data/thbrk', 'add-list', '-e', 'utf-8', '@INPUT0@'], - input : [dictionary], - depends : [alphamap], - output : ['thbrk.tri'], - install : true, - install_dir: dict_dir, - ) -endif +sort = find_program('sort') +cp = find_program('cp') +trietool = find_program('trietool') + +dictionary = custom_target( + 'tdict', + command : [sort, '-u', '-o', '@OUTPUT@', '@INPUT@'], + env : { + 'LC_ALL': 'C', + }, + input : [ + 'tdict-common.txt', + 'tdict-collection.txt', + 'tdict-currency.txt', + 'tdict-district.txt', + 'tdict-city.txt', + 'tdict-country.txt', + 'tdict-geo.txt', + 'tdict-history.txt', + 'tdict-ict.txt', + 'tdict-lang-ethnic.txt', + 'tdict-proper.txt', + 'tdict-science.txt', + 'tdict-slang.txt', + 'tdict-spell.txt', + 'tdict-std.txt', + 'tdict-std-compound.txt' + ], + output : ['tdict.txt'], +) +# trietool look for thbrk.abm in the directory of thbrk.tri +# so we need to copy thbrk.abm into the build directory +alphamap = custom_target( + 'alphabet_map', + command : [cp, '@INPUT@', '@OUTPUT@'], + input : ['thbrk.abm'], + output : ['thbrk.abm'], +) +tri = custom_target( + 'tri', + command : [trietool, 'data/thbrk', 'add-list', '-e', 'utf-8', '@INPUT0@'], + input : [dictionary], + depends : [alphamap], + output : ['thbrk.tri'], + install : true, + install_dir: dict_dir, +) From 411d37cbcebe47174322fdeb5330dd1e518746da Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 16:08:13 +0700 Subject: [PATCH 05/13] Doxygen build --- doc/meson.build | 30 +++++++++++++++++++++ include/meson.build | 7 +++-- meson.build | 1 + meson_options.txt | 2 +- src/meson.build | 54 ++++++++++++++++++++------------------ subprojects/libdatrie.wrap | 2 +- 6 files changed, 66 insertions(+), 30 deletions(-) create mode 100644 doc/meson.build diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 0000000..886a666 --- /dev/null +++ b/doc/meson.build @@ -0,0 +1,30 @@ +if get_option('docs').disabled() + subdir_done() +endif + +doxygen = find_program('doxygen', required : get_option('docs'), version : '>=1.9.1') +if not doxygen.found() + subdir_done() +endif + +doxyfile_data = configuration_data() +doxyfile_data.set('VERSION', version) +doxyfile_data.set('PACKAGE', meson.project_name()) +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, +) + +custom_target( + 'docs', + input : doxyfile, + output : 'html', + command : [doxygen, doxyfile], + depend_files : thai_src + headers_src, + install : true, + install_dir: get_option('docsdir'), +) diff --git a/include/meson.build b/include/meson.build index 3baab26..fbe8ce0 100644 --- a/include/meson.build +++ b/include/meson.build @@ -1,4 +1,4 @@ -install_headers( +headers_src = files( 'thai/thailib.h', 'thai/thctype.h', 'thai/thstr.h', @@ -15,7 +15,10 @@ install_headers( 'thai/thwstr.h', 'thai/thwbrk.h', 'thai/tis.h', - 'thai/wtt.h', + 'thai/wtt.h' +) +install_headers( + headers_src, subdir : 'thai', ) diff --git a/meson.build b/meson.build index 3bf1612..38e928d 100644 --- a/meson.build +++ b/meson.build @@ -34,4 +34,5 @@ subdir('data') subdir('include') subdir('src') subdir('man') +subdir('doc') subdir('tests') diff --git a/meson_options.txt b/meson_options.txt index e22ae68..8a213fc 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,3 @@ option('docs', type : 'feature', value : 'auto', description : 'Generate documents with Doxygen') -option('docsdir', type : 'string', value : 'share/doc/datrie', description : 'Where to install the Doxygen-generated HTML doc') +option('docsdir', type : 'string', value : 'share/doc/libthai', description : 'Where to install the Doxygen-generated HTML doc') option('dict', type : 'boolean', value : true, description : 'Enable dictionary data generation (require libdatrie)') diff --git a/src/meson.build b/src/meson.build index 0ad06d5..3dad7f9 100644 --- a/src/meson.build +++ b/src/meson.build @@ -11,42 +11,44 @@ else ] endif -thai = library( - 'thai', - [ - 'thctype/thctype.c', - 'thctype/wtt.c', +thai_src = files( + 'thctype/thctype.c', + 'thctype/wtt.c', + + 'thstr/thstr.c', - 'thstr/thstr.c', + 'thcell/thcell.c', - 'thcell/thcell.c', + 'thinp/thinp.c', - 'thinp/thinp.c', + 'thrend/thrend.c', - 'thrend/thrend.c', + 'thcoll/cweight.c', + 'thcoll/cweight.h', + 'thcoll/thcoll.c', - 'thcoll/cweight.c', - 'thcoll/cweight.h', - 'thcoll/thcoll.c', + 'thbrk/thbrk.c', + 'thbrk/thbrk-priv.h', + 'thbrk/thbrk-utils.h', + 'thbrk/brk-ctype.c', + 'thbrk/brk-ctype.h', + 'thbrk/brk-common.c', + 'thbrk/brk-common.h', + 'thbrk/brk-maximal.c', + 'thbrk/brk-maximal.h', - 'thbrk/thbrk.c', - 'thbrk/thbrk-priv.h', - 'thbrk/thbrk-utils.h', - 'thbrk/brk-ctype.c', - 'thbrk/brk-ctype.h', - 'thbrk/brk-common.c', - 'thbrk/brk-common.h', - 'thbrk/brk-maximal.c', - 'thbrk/brk-maximal.h', + 'thwchar/thwchar.c', - 'thwchar/thwchar.c', + 'thwctype/thwctype.c', - 'thwctype/thwctype.c', + 'thwstr/thwstr.c', - 'thwstr/thwstr.c', + 'thwbrk/thwbrk.c', +) - 'thwbrk/thwbrk.c', - ], +thai = library( + 'thai', + thai_src, install : true, link_args : ldflags, diff --git a/subprojects/libdatrie.wrap b/subprojects/libdatrie.wrap index c5c9b04..04f3b50 100644 --- a/subprojects/libdatrie.wrap +++ b/subprojects/libdatrie.wrap @@ -1,6 +1,6 @@ [wrap-git] url = https://github.com/tlwg/libdatrie.git -revision = daa9c6d33ef95931a0796294f005f249af97cc05 +revision = 558d8ba9aec8298a3883a0b4ec505f5af04e0b1f depth = 1 [provide] From 46410bd0250b3712f5c119e2f211126e0b4a6d7d Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 16:11:24 +0700 Subject: [PATCH 06/13] Reformat project --- build-aux/test.map | 1 + data/meson.build | 72 +++++++++++++++-------------- doc/meson.build | 22 +++++---- include/meson.build | 39 ++++++++-------- man/meson.build | 6 +-- meson.build | 26 ++++++++--- src/meson.build | 107 ++++++++++++++++++++------------------------ tests/meson.build | 53 ++++++++++------------ 8 files changed, 160 insertions(+), 166 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 0000000..9b1f1be --- /dev/null +++ b/build-aux/test.map @@ -0,0 +1 @@ +{global:hello; local:*;}; diff --git a/data/meson.build b/data/meson.build index 53606c0..574b9a0 100644 --- a/data/meson.build +++ b/data/meson.build @@ -1,53 +1,51 @@ dict_dir = get_option('datadir') / 'libthai' if not get_option('dict') - subdir_done() -endif + subdir_done() +endif sort = find_program('sort') cp = find_program('cp') trietool = find_program('trietool') dictionary = custom_target( - 'tdict', - command : [sort, '-u', '-o', '@OUTPUT@', '@INPUT@'], - env : { - 'LC_ALL': 'C', - }, - input : [ - 'tdict-common.txt', - 'tdict-collection.txt', - 'tdict-currency.txt', - 'tdict-district.txt', - 'tdict-city.txt', - 'tdict-country.txt', - 'tdict-geo.txt', - 'tdict-history.txt', - 'tdict-ict.txt', - 'tdict-lang-ethnic.txt', - 'tdict-proper.txt', - 'tdict-science.txt', - 'tdict-slang.txt', - 'tdict-spell.txt', - 'tdict-std.txt', - 'tdict-std-compound.txt' - ], - output : ['tdict.txt'], + 'tdict', + command: [sort, '-u', '-o', '@OUTPUT@', '@INPUT@'], + env: {'LC_ALL': 'C'}, + input: [ + 'tdict-common.txt', + 'tdict-collection.txt', + 'tdict-currency.txt', + 'tdict-district.txt', + 'tdict-city.txt', + 'tdict-country.txt', + 'tdict-geo.txt', + 'tdict-history.txt', + 'tdict-ict.txt', + 'tdict-lang-ethnic.txt', + 'tdict-proper.txt', + 'tdict-science.txt', + 'tdict-slang.txt', + 'tdict-spell.txt', + 'tdict-std.txt', + 'tdict-std-compound.txt', + ], + output: ['tdict.txt'], ) # trietool look for thbrk.abm in the directory of thbrk.tri # so we need to copy thbrk.abm into the build directory alphamap = custom_target( - 'alphabet_map', - command : [cp, '@INPUT@', '@OUTPUT@'], - input : ['thbrk.abm'], - output : ['thbrk.abm'], + 'alphabet_map', + command: [cp, '@INPUT@', '@OUTPUT@'], + input: ['thbrk.abm'], + output: ['thbrk.abm'], ) tri = custom_target( - 'tri', - command : [trietool, 'data/thbrk', 'add-list', '-e', 'utf-8', '@INPUT0@'], - input : [dictionary], - depends : [alphamap], - output : ['thbrk.tri'], - install : true, - install_dir: dict_dir, + 'tri', + command: [trietool, 'data/thbrk', 'add-list', '-e', 'utf-8', '@INPUT0@'], + input: [dictionary], + depends: [alphamap], + output: ['thbrk.tri'], + install: true, + install_dir: dict_dir, ) diff --git a/doc/meson.build b/doc/meson.build index 886a666..2db43eb 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 : thai_src + headers_src, - install : true, + input: doxyfile, + output: 'html', + command: [doxygen, doxyfile], + depend_files: thai_src + headers_src, + install: true, install_dir: get_option('docsdir'), ) diff --git a/include/meson.build b/include/meson.build index fbe8ce0..d45dd34 100644 --- a/include/meson.build +++ b/include/meson.build @@ -1,25 +1,22 @@ headers_src = files( - 'thai/thailib.h', - 'thai/thctype.h', - 'thai/thstr.h', - 'thai/thcoll.h', - 'thai/thcell.h', - 'thai/thinp.h', - 'thai/thrend.h', - 'thai/thbrk.h', - 'thai/thwchar.h', - 'thai/thwctype.h', - 'thai/thwcoll.h', - 'thai/thwinp.h', - 'thai/thwrend.h', - 'thai/thwstr.h', - 'thai/thwbrk.h', - 'thai/tis.h', - 'thai/wtt.h' -) -install_headers( - headers_src, - subdir : 'thai', + 'thai/thailib.h', + 'thai/thbrk.h', + 'thai/thcell.h', + 'thai/thcoll.h', + 'thai/thctype.h', + 'thai/thinp.h', + 'thai/thrend.h', + 'thai/thstr.h', + 'thai/thwbrk.h', + 'thai/thwchar.h', + 'thai/thwcoll.h', + 'thai/thwctype.h', + 'thai/thwinp.h', + 'thai/thwrend.h', + 'thai/thwstr.h', + 'thai/tis.h', + 'thai/wtt.h', ) +install_headers(headers_src, subdir: 'thai') include_dir = include_directories('.') diff --git a/man/meson.build b/man/meson.build index 223abd1..c157889 100644 --- a/man/meson.build +++ b/man/meson.build @@ -1,5 +1 @@ -install_man( - 'man3/libthai.3', - 'man3/thctype.3', - 'man3/wtt.3', -) +install_man('man3/libthai.3', 'man3/thctype.3', 'man3/wtt.3') diff --git a/meson.build b/meson.build index 38e928d..0b5d568 100644 --- a/meson.build +++ b/meson.build @@ -1,16 +1,26 @@ project( - 'libthai', 'c', meson_version : '>=1.0.0', - version: run_command(files('build-aux/git-version-gen'), check : true).stdout().strip() + 'libthai', + 'c', + meson_version: '>=1.0.0', + version: run_command(files('build-aux/git-version-gen'), check: true).stdout().strip(), ) sh = find_program('sh') compiler = meson.get_compiler('c') datrie = dependency('datrie-0.2') -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 = 3 LT_REVISION = 1 @@ -21,11 +31,13 @@ libversion = '@0@.@1@.@2@'.format(soversion, LT_AGE, LT_REVISION) # 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.global_source_root() / 'build-aux' / 'test.map', + ), ) if get_option('buildtype') in ['debug', 'debugoptimized'] - add_project_arguments('-DNDEBUG', language : ['c']) + add_project_arguments('-DNDEBUG', language: ['c']) endif # TODO: Doxygen diff --git a/src/meson.build b/src/meson.build index 3dad7f9..6c5fde2 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,75 +1,66 @@ ldflags = [] -link_depends = ['libthai.map'] +link_depends = ['libthai.map', 'libthai.def'] if ld_has_version_script - ldflags += [ - '-Wl,--version-script,@0@'.format(meson.current_source_dir() / 'libthai.map') - ] + ldflags += [ + '-Wl,--version-script,@0@'.format( + meson.current_source_dir() / 'libthai.map', + ), + ] else - ldflags += [ - '-export-symbols @0@'.format(meson.current_source_dir() / 'libthai.map') - ] + ldflags += [ + '-export-symbols @0@'.format(meson.current_source_dir() / 'libthai.def'), + ] endif thai_src = files( - 'thctype/thctype.c', - 'thctype/wtt.c', - - 'thstr/thstr.c', - - 'thcell/thcell.c', - - 'thinp/thinp.c', - - 'thrend/thrend.c', - - 'thcoll/cweight.c', - 'thcoll/cweight.h', - 'thcoll/thcoll.c', - - 'thbrk/thbrk.c', - 'thbrk/thbrk-priv.h', - 'thbrk/thbrk-utils.h', - 'thbrk/brk-ctype.c', - 'thbrk/brk-ctype.h', - 'thbrk/brk-common.c', - 'thbrk/brk-common.h', - 'thbrk/brk-maximal.c', - 'thbrk/brk-maximal.h', - - 'thwchar/thwchar.c', - - 'thwctype/thwctype.c', - - 'thwstr/thwstr.c', - - 'thwbrk/thwbrk.c', + 'thbrk/brk-common.c', + 'thbrk/brk-common.h', + 'thbrk/brk-ctype.c', + 'thbrk/brk-ctype.h', + 'thbrk/brk-maximal.c', + 'thbrk/brk-maximal.h', + 'thbrk/thbrk-priv.h', + 'thbrk/thbrk-utils.h', + 'thbrk/thbrk.c', + 'thcell/thcell.c', + 'thcoll/cweight.c', + 'thcoll/cweight.h', + 'thcoll/thcoll.c', + 'thctype/thctype.c', + 'thctype/wtt.c', + 'thinp/thinp.c', + 'thrend/thrend.c', + 'thstr/thstr.c', + 'thwbrk/thwbrk.c', + 'thwchar/thwchar.c', + 'thwctype/thwctype.c', + 'thwstr/thwstr.c', ) thai = library( - 'thai', - thai_src, - - install : true, - link_args : ldflags, - link_depends : link_depends, - c_args: ['-DDICT_DIR="@0@"'.format(dict_dir)], - dependencies : [datrie], - version : libversion, - soversion : soversion, - include_directories : include_dir, + 'thai', + thai_src, + install: true, + link_args: ldflags, + link_depends: link_depends, + c_args: ['-DDICT_DIR="@0@"'.format(dict_dir)], + dependencies: [datrie], + version: libversion, + soversion: soversion, + include_directories: include_dir, ) libthai_dep = declare_dependency( - include_directories : include_dir, - link_with : thai, + include_directories: include_dir, + link_with: thai, ) pkg = import('pkgconfig') pkg.generate( - thai, - filebase : 'libthai', - name : 'libthai', - description : 'Thai support library', - version : version, - requires_private: ['datrie-0.2'], + thai, + filebase: 'libthai', + name: 'libthai', + description: 'Thai support library', + version: version, + requires_private: ['datrie-0.2'], ) diff --git a/tests/meson.build b/tests/meson.build index 39c4252..99427b8 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,41 +1,36 @@ fs = import('fs') -tests = [ - 'thctype', 'thcell', 'thinp', 'thrend', - 'thstr', 'thwchar', -] +tests = ['thctype', 'thcell', 'thinp', 'thrend', 'thstr', 'thwchar'] foreach item : tests - exe = executable( - 'test_' + item, - 'test_@0@.c'.format(item), - link_with : thai, - ) - test(item, exe) + exe = executable('test_' + item, 'test_@0@.c'.format(item), link_with: thai) + test(item, exe) endforeach # thcoll -thsort = executable('thsort', 'thsort.c', link_with : thai) +thsort = executable('thsort', 'thsort.c', link_with: thai) test( - 'thcoll', - find_program('test-thcoll.sh'), - depends : [thsort], - env : { - 'srcdir' : meson.current_source_dir(), - 'top_builddir' : meson.project_build_root(), - }, + 'thcoll', + find_program('test-thcoll.sh'), + depends: [thsort], + env: { + 'srcdir' : meson.current_source_dir(), + 'top_builddir' : meson.project_build_root(), + }, ) if get_option('dict') - foreach item : ['thbrk', 'thwbrk'] - exe = executable('test_' + item, 'test_@0@.c'.format(item), link_with : thai) - test( - item, - exe, - depends : [tri], - env : { - 'LIBTHAI_DICTDIR' : fs.parent(tri.full_path()), - }, - ) - endforeach + foreach item : ['thbrk', 'thwbrk'] + exe = executable( + 'test_' + item, + 'test_@0@.c'.format(item), + link_with: thai, + ) + test( + item, + exe, + depends: [tri], + env: {'LIBTHAI_DICTDIR' : fs.parent(tri.full_path())}, + ) + endforeach endif From b8e3d0820160e97dba92313174aedd450f1dc60d Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 16:17:12 +0700 Subject: [PATCH 07/13] Add meson.build to autotools --- INSTALL | 23 +++++++++++++++++++++++ Makefile.am | 3 +++ data/Makefile.am | 2 +- doc/Makefile.am | 2 ++ include/Makefile.am | 1 + man/Makefile.am | 1 + src/Makefile.am | 2 +- tests/Makefile.am | 2 +- 8 files changed, 33 insertions(+), 3 deletions(-) diff --git a/INSTALL b/INSTALL index a9af056..9a80ff0 100644 --- a/INSTALL +++ b/INSTALL @@ -1,6 +1,11 @@ Basic Installation ================== +libthai can be built by Autotools or Meson + +Autotools build +--------------- + # Build requirements: # - libtool # - libdatrie development package (or https://github.com/tlwg/libdatrie) @@ -24,3 +29,21 @@ make install # In order to uninstall make uninstall +Meson build +----------- + +# Build requirements: +# - meson 1.0 or better +# - doxygen (optional, for documentation generation) +# +# Meson will use local libdatrie if installed, otherwise will automatically +# download and build libdatrie. + +# 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 diff --git a/Makefile.am b/Makefile.am index 8eba43a..8e3ead1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,6 +4,9 @@ SUBDIRS = include src data tests doc EXTRA_DIST = \ build-aux/git-version-gen \ + build-aux/test.map \ + meson.build \ + meson_options.txt \ $(NULL) MAINTAINERCLEANFILES = Makefile.in diff --git a/data/Makefile.am b/data/Makefile.am index c33bd62..54db90f 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -27,7 +27,7 @@ TDICT_SRC = \ $(srcdir)/tdict-std.txt \ $(srcdir)/tdict-std-compound.txt -EXTRA_DIST = thbrk.abm $(TDICT_SRC) +EXTRA_DIST = thbrk.abm $(TDICT_SRC) meson.build tdict.txt: $(TDICT_SRC) cat $(TDICT_SRC) | LC_ALL=C sort -u > tdict.txt diff --git a/doc/Makefile.am b/doc/Makefile.am index f191042..0ff44b2 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/include/Makefile.am b/include/Makefile.am index 7d0c75c..6701ecc 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -2,3 +2,4 @@ SUBDIRS = thai MAINTAINERCLEANFILES = Makefile.in +EXTRA_DIST = meson.build diff --git a/man/Makefile.am b/man/Makefile.am index 4c2a734..147a4db 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -2,3 +2,4 @@ SUBDIRS = man3 MAINTAINERCLEANFILES = Makefile.in +EXTRA_DIST = meson.build diff --git a/src/Makefile.am b/src/Makefile.am index cdb0d4f..c3b6e00 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,7 +3,7 @@ SUBDIRS = thctype thstr thcell thinp thrend thcoll thbrk thwchar thwctype \ MAINTAINERCLEANFILES = Makefile.in -EXTRA_DIST = libthai.map libthai.def +EXTRA_DIST = libthai.map libthai.def meson.build AM_CPPFLAGS = -I. -I$(top_srcdir)/include $(DATRIE_CFLAGS) diff --git a/tests/Makefile.am b/tests/Makefile.am index 4492507..30f404c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,7 +2,7 @@ MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/include -EXTRA_DIST = sorttest.txt sorted.txt test-thcoll.sh test-thbrk.sh test-thwbrk.sh +EXTRA_DIST = sorttest.txt sorted.txt test-thcoll.sh test-thbrk.sh test-thwbrk.sh meson.build TESTS_ENVIRONMENT = top_builddir=$(top_builddir) From 2388685234fe36e7cad4ac9c1f00208ccdcf9dc1 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 16:28:22 +0700 Subject: [PATCH 08/13] Migrate cvsignore to gitignore, set export excludes to match autotools --- .cvsignore | 25 ------------------------- .gitattributes | 4 ++++ .gitignore | 1 + build-aux/.gitignore | 8 ++++++++ data/{.cvsignore => .gitignore} | 0 doc/{.cvsignore => .gitignore} | 0 include/{.cvsignore => .gitignore} | 0 include/thai/{.cvsignore => .gitignore} | 0 man/{.cvsignore => .gitignore} | 0 man/man3/{.cvsignore => .gitignore} | 0 src/{.cvsignore => .gitignore} | 0 src/thbrk/{.cvsignore => .gitignore} | 0 src/thcell/{.cvsignore => .gitignore} | 0 src/thcoll/{.cvsignore => .gitignore} | 0 src/thctype/{.cvsignore => .gitignore} | 0 src/thinp/{.cvsignore => .gitignore} | 0 src/thrend/{.cvsignore => .gitignore} | 0 src/thstr/{.cvsignore => .gitignore} | 0 src/thwbrk/{.cvsignore => .gitignore} | 0 src/thwchar/{.cvsignore => .gitignore} | 0 src/thwctype/{.cvsignore => .gitignore} | 0 src/thwstr/{.cvsignore => .gitignore} | 0 tests/{.cvsignore => .gitignore} | 0 23 files changed, 13 insertions(+), 25 deletions(-) delete mode 100644 .cvsignore create mode 100644 .gitattributes create mode 100644 build-aux/.gitignore rename data/{.cvsignore => .gitignore} (100%) rename doc/{.cvsignore => .gitignore} (100%) rename include/{.cvsignore => .gitignore} (100%) rename include/thai/{.cvsignore => .gitignore} (100%) rename man/{.cvsignore => .gitignore} (100%) rename man/man3/{.cvsignore => .gitignore} (100%) rename src/{.cvsignore => .gitignore} (100%) rename src/thbrk/{.cvsignore => .gitignore} (100%) rename src/thcell/{.cvsignore => .gitignore} (100%) rename src/thcoll/{.cvsignore => .gitignore} (100%) rename src/thctype/{.cvsignore => .gitignore} (100%) rename src/thinp/{.cvsignore => .gitignore} (100%) rename src/thrend/{.cvsignore => .gitignore} (100%) rename src/thstr/{.cvsignore => .gitignore} (100%) rename src/thwbrk/{.cvsignore => .gitignore} (100%) rename src/thwchar/{.cvsignore => .gitignore} (100%) rename src/thwctype/{.cvsignore => .gitignore} (100%) rename src/thwstr/{.cvsignore => .gitignore} (100%) rename tests/{.cvsignore => .gitignore} (100%) diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index a2c5f15..0000000 --- a/.cvsignore +++ /dev/null @@ -1,25 +0,0 @@ -*.lo -libtool -ltmain.sh -configure -config.cache -config.guess -config.h -config.h.in -config.log -config.status -config.sub -stamp-h -stamp-h.in -Makefile -Makefile.in -aclocal.m4 -autom4te.cache -m4 -depcomp -missing -INSTALL -install-sh -mkinstalldirs -ChangeLog -libthai.pc diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8370d90 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +.gitignore export-ignore +.gitattributes export-ignore +nsis/ export-ignore +data/references/ export-ignore diff --git a/.gitignore b/.gitignore index 8c46ff5..f2bb6f9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /libtool /ltmain.sh /configure +/configure~ /config.cache /config.guess /config.h diff --git a/build-aux/.gitignore b/build-aux/.gitignore new file mode 100644 index 0000000..94fb547 --- /dev/null +++ b/build-aux/.gitignore @@ -0,0 +1,8 @@ +compile +config.guess +config.sub +depcomp +install-sh +ltmain.sh +missing +test-driver diff --git a/data/.cvsignore b/data/.gitignore similarity index 100% rename from data/.cvsignore rename to data/.gitignore diff --git a/doc/.cvsignore b/doc/.gitignore similarity index 100% rename from doc/.cvsignore rename to doc/.gitignore diff --git a/include/.cvsignore b/include/.gitignore similarity index 100% rename from include/.cvsignore rename to include/.gitignore diff --git a/include/thai/.cvsignore b/include/thai/.gitignore similarity index 100% rename from include/thai/.cvsignore rename to include/thai/.gitignore diff --git a/man/.cvsignore b/man/.gitignore similarity index 100% rename from man/.cvsignore rename to man/.gitignore diff --git a/man/man3/.cvsignore b/man/man3/.gitignore similarity index 100% rename from man/man3/.cvsignore rename to man/man3/.gitignore diff --git a/src/.cvsignore b/src/.gitignore similarity index 100% rename from src/.cvsignore rename to src/.gitignore diff --git a/src/thbrk/.cvsignore b/src/thbrk/.gitignore similarity index 100% rename from src/thbrk/.cvsignore rename to src/thbrk/.gitignore diff --git a/src/thcell/.cvsignore b/src/thcell/.gitignore similarity index 100% rename from src/thcell/.cvsignore rename to src/thcell/.gitignore diff --git a/src/thcoll/.cvsignore b/src/thcoll/.gitignore similarity index 100% rename from src/thcoll/.cvsignore rename to src/thcoll/.gitignore diff --git a/src/thctype/.cvsignore b/src/thctype/.gitignore similarity index 100% rename from src/thctype/.cvsignore rename to src/thctype/.gitignore diff --git a/src/thinp/.cvsignore b/src/thinp/.gitignore similarity index 100% rename from src/thinp/.cvsignore rename to src/thinp/.gitignore diff --git a/src/thrend/.cvsignore b/src/thrend/.gitignore similarity index 100% rename from src/thrend/.cvsignore rename to src/thrend/.gitignore diff --git a/src/thstr/.cvsignore b/src/thstr/.gitignore similarity index 100% rename from src/thstr/.cvsignore rename to src/thstr/.gitignore diff --git a/src/thwbrk/.cvsignore b/src/thwbrk/.gitignore similarity index 100% rename from src/thwbrk/.cvsignore rename to src/thwbrk/.gitignore diff --git a/src/thwchar/.cvsignore b/src/thwchar/.gitignore similarity index 100% rename from src/thwchar/.cvsignore rename to src/thwchar/.gitignore diff --git a/src/thwctype/.cvsignore b/src/thwctype/.gitignore similarity index 100% rename from src/thwctype/.cvsignore rename to src/thwctype/.gitignore diff --git a/src/thwstr/.cvsignore b/src/thwstr/.gitignore similarity index 100% rename from src/thwstr/.cvsignore rename to src/thwstr/.gitignore diff --git a/tests/.cvsignore b/tests/.gitignore similarity index 100% rename from tests/.cvsignore rename to tests/.gitignore From 19e894a7f290204af74178851d1a330f47dc9e80 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 16:33:58 +0700 Subject: [PATCH 09/13] Add wrap file to make dist --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index 8e3ead1..bb2abd3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,6 +7,7 @@ EXTRA_DIST = \ build-aux/test.map \ meson.build \ meson_options.txt \ + subprojects/libdatrie.wrap \ $(NULL) MAINTAINERCLEANFILES = Makefile.in From a739c539154bc939d97382376c9f67641b389d5f Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 17:38:37 +0700 Subject: [PATCH 10/13] Add override_dependency --- src/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/src/meson.build b/src/meson.build index 6c5fde2..b88ed41 100644 --- a/src/meson.build +++ b/src/meson.build @@ -54,6 +54,7 @@ libthai_dep = declare_dependency( include_directories: include_dir, link_with: thai, ) +meson.override_dependency('libthai', libthai_dep) pkg = import('pkgconfig') pkg.generate( From 14383ea01223dd008a60a49257177107ecbbeb1c Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 17:53:42 +0700 Subject: [PATCH 11/13] Fix windows build --- subprojects/libdatrie.wrap | 2 +- tests/meson.build | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/subprojects/libdatrie.wrap b/subprojects/libdatrie.wrap index 04f3b50..8cad4d6 100644 --- a/subprojects/libdatrie.wrap +++ b/subprojects/libdatrie.wrap @@ -1,6 +1,6 @@ [wrap-git] url = https://github.com/tlwg/libdatrie.git -revision = 558d8ba9aec8298a3883a0b4ec505f5af04e0b1f +revision = 3985d6f7b5e56bc60bb9581337bf6a3782bd71be depth = 1 [provide] diff --git a/tests/meson.build b/tests/meson.build index 99427b8..c82ffe4 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -3,12 +3,16 @@ fs = import('fs') tests = ['thctype', 'thcell', 'thinp', 'thrend', 'thstr', 'thwchar'] foreach item : tests - exe = executable('test_' + item, 'test_@0@.c'.format(item), link_with: thai) + exe = executable( + 'test_' + item, + 'test_@0@.c'.format(item), + dependencies: [libthai_dep], + ) test(item, exe) endforeach # thcoll -thsort = executable('thsort', 'thsort.c', link_with: thai) +thsort = executable('thsort', 'thsort.c', dependencies: [libthai_dep]) test( 'thcoll', find_program('test-thcoll.sh'), @@ -24,7 +28,7 @@ if get_option('dict') exe = executable( 'test_' + item, 'test_@0@.c'.format(item), - link_with: thai, + dependencies: [libthai_dep, dependency('iconv')], ) test( item, From 502777fa173ee26e67449578c53f96b199980db9 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Mon, 12 Aug 2024 18:17:11 +0700 Subject: [PATCH 12/13] Add windows build support --- src/libthai.c | 6 ++++-- src/meson.build | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/libthai.c b/src/libthai.c index 8065c1f..efd2772 100644 --- a/src/libthai.c +++ b/src/libthai.c @@ -90,8 +90,10 @@ #include "thbrk/thbrk-priv.h" -__attribute__ ((destructor)) void -_libthai_on_unload () +#if defined (__GNUC__) || defined (__clang__) +__attribute__ ((destructor)) +#endif +void _libthai_on_unload () { brk_free_shared_brk (); } diff --git a/src/meson.build b/src/meson.build index b88ed41..04dc3d7 100644 --- a/src/meson.build +++ b/src/meson.build @@ -7,6 +7,23 @@ if ld_has_version_script meson.current_source_dir() / 'libthai.map', ), ] +elif compiler.get_linker_id() in ['link', 'lld-link'] + link_def = custom_target( + 'link-def', + input: ['libthai.def'], + # This use ASCII as some PS version do not have UTF8NoBOM + command: [ + find_program('powershell'), + '-Command', + '''& { + Write-Output "EXPORTS" | Out-File -Encoding ascii -FilePath @OUTPUT0@ + Get-Content -Path @INPUT0@ | Out-File -Append -Encoding ascii -FilePath @OUTPUT0@ + }''', + ], + output: 'libthai.def', + ) + ldflags += ['/def:@0@'.format(link_def.full_path())] + link_depends += [link_def] else ldflags += [ '-export-symbols @0@'.format(meson.current_source_dir() / 'libthai.def'), @@ -36,6 +53,7 @@ thai_src = files( 'thwchar/thwchar.c', 'thwctype/thwctype.c', 'thwstr/thwstr.c', + 'libthai.c', ) thai = library( From b5484c784cb6fb9d935b3088ea89365f311b30e5 Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Thu, 15 Aug 2024 17:40:25 +0700 Subject: [PATCH 13/13] Remove todo --- meson.build | 2 -- 1 file changed, 2 deletions(-) diff --git a/meson.build b/meson.build index 0b5d568..3ca49cf 100644 --- a/meson.build +++ b/meson.build @@ -40,8 +40,6 @@ if get_option('buildtype') in ['debug', 'debugoptimized'] add_project_arguments('-DNDEBUG', language: ['c']) endif -# TODO: Doxygen - subdir('data') subdir('include') subdir('src')