-
Notifications
You must be signed in to change notification settings - Fork 45
Meson build #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
whs
wants to merge
25
commits into
tlwg:master
Choose a base branch
from
whs:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Meson build #22
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
9863b66
WIP: Add meson build scripts
whs 1fff582
meson: Add linker info
whs c407212
meson: Test and docs
whs 5fdd61b
Add objects files to ignore
whs 3fe3efc
Add pkgconfig build
whs debcd30
Build with include_directories to root
whs 11d5a1d
Add include_directory for tests
whs 2b8e6c8
Space instead of tabs
whs 745dfb2
Test for no-undefined
whs 00df122
Use libdatrie_dep to build test
whs 711089a
Rename pkgconfig file
whs b60d706
Add support for Windows build
whs 80fdeb7
Version stamp for tarball
whs 7edf5c0
Run autogen on dist
whs 8279dec
Add meson files to automake dist
whs 5d8a61a
Docs meson building
whs 242cc75
Detect iconv by compiler.find_library
whs 96b12ea
Remove vs_module_defs
whs a3a5155
Fix versioning and tarballing
whs c0fe2a9
Fix building on windows clang
whs 481ed33
Apply suggestions from code review
whs b0e671d
Fix missing quote
whs daa9c6d
Add override_dependency, override_find_program
whs 558d8ba
Fix deprecated option
whs 3985d6f
Reformat with meson fmt
whs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .gitignore export-ignore | ||
| .gitattributes export-ignore | ||
| nsis/ export-ignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {global:hello; local:*;}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| ldflags = [] | ||
| link_depends = ['libdatrie.map'] | ||
|
|
||
| if ld_has_version_script | ||
| ldflags += [ | ||
| '-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'], | ||
| # This use ASCII as some PS version do not have UTF8NoBOM | ||
| 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', | ||
| ) | ||
| ldflags += [ '/def:@0@'.format(link_def.full_path()) ] | ||
| link_depends += [link_def] | ||
| endif | ||
|
|
||
| datrie_src = files( | ||
| '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 : link_depends, | ||
| version : libversion, | ||
| soversion : soversion, | ||
| include_directories : configuration_inc, | ||
| ) | ||
| libdatrie_dep = declare_dependency( | ||
| include_directories : configuration_inc, | ||
| link_with : datrie | ||
| ) | ||
|
|
||
| install_headers( | ||
| 'alpha-map.h', | ||
| 'trie.h', | ||
| 'triedefs.h', | ||
| 'typedefs.h', | ||
| 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, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| EXTRA_DIST = meson.build | ||
|
|
||
| if ENABLE_DOXYGEN_DOC | ||
|
|
||
| all-local: doxygen.stamp | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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.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'), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| EXTRA_DIST = trietool.1 | ||
| EXTRA_DIST = trietool.1 meson.build | ||
|
|
||
| man_MANS = trietool.1 | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +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'))) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| 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') | ||
| 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)) | ||
| 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 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 <langinfo.h> | ||
| 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 | ||
| 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.global_source_root() / 'build-aux' / 'test.map') | ||
whs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| # Generate config.h | ||
| configure_file(output : 'config.h', configuration: conf_data) | ||
| configuration_inc = include_directories('.') | ||
|
|
||
| # Build! | ||
| subdir('datrie') | ||
| subdir('tests') | ||
| subdir('tools') | ||
| subdir('man') | ||
| subdir('doc') | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| 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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| 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', | ||
| dependencies : libdatrie_dep, | ||
| ) | ||
| test(item, exe) | ||
| endforeach |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| AM_CPPFLAGS = -I$(top_srcdir) | ||
|
|
||
| EXTRA_DIST = meson.build | ||
|
|
||
| bin_PROGRAMS = trietool | ||
|
|
||
| trietool_SOURCES = trietool.c | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| if not have_locale_charset and not have_langinfo_codeset | ||
| subdir_done() | ||
| endif | ||
|
|
||
| trietool = executable( | ||
| 'trietool', | ||
| 'trietool.c', | ||
| dependencies : deps, | ||
| link_with : datrie, | ||
| install : true, | ||
| 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'))) | ||
whs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.