From daf01d9e3fa89506b6da2aba5175803fa42f6af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Tue, 23 Oct 2018 07:33:08 +0200 Subject: [PATCH 01/15] meson: Do not use an array for default options An array is used for setting default options in project function. However, the fact that only one option is set makes the use of the array unnecessary. The build type is set now as a single option. --- meson.build | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/meson.build b/meson.build index bdcc0b3..e21f99a 100644 --- a/meson.build +++ b/meson.build @@ -1,8 +1,6 @@ project('libgit2-glib', 'c', version: '0.27.7', - default_options: [ - 'buildtype=debugoptimized' - ], + default_options: 'buildtype=debugoptimized', license: 'LGPL2+', meson_version: '>= 0.48.0') -- GitLab From d56e5dfc74988f3b6c5ce1344ffda665de1d6cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Wed, 24 Oct 2018 22:50:49 +0200 Subject: [PATCH 02/15] meson: Remove unnecessary auxiliary variable The variable containing the list of compiler arguments to be checked can be removed without any harm to readibility. The variable has been removed by appending directly to the list of common compiler arguments, those that are supported. --- meson.build | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index e21f99a..1a069b2 100644 --- a/meson.build +++ b/meson.build @@ -49,7 +49,7 @@ if cc.get_id() == 'msvc' # in GLib, based on _Win32_Programming_ by Rector and Newcomer common_flags = ['-FImsvc_recommended_pragmas.h'] else - test_cflags = [ + common_flags = cc.get_supported_arguments([ '-ffast-math', '-fstrict-aliasing', '-Wpointer-arith', @@ -76,9 +76,7 @@ else '-Werror=return-type', '-Werror=array-bounds', '-Werror=write-strings' - ] - - common_flags = cc.get_supported_arguments(test_cflags) + ]) endif if libgit2_glib_buildtype.contains('debug') -- GitLab From 66cca3976e3f59305071a6fd51ae652649d4f119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Mon, 12 Nov 2018 12:05:24 +0100 Subject: [PATCH 03/15] meson: Add trailing commas Add missing trailing commas that avoids getting noise when another file/parameter is added and eases reviewing changes[0]. [0] https://gitlab.gnome.org/GNOME/dconf/merge_requests/11#note_291585 --- examples/meson.build | 2 +- libgit2-glib/meson.build | 6 +++--- meson.build | 4 ++-- tests/meson.build | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/meson.build b/examples/meson.build index dfe8ada..3987ae0 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -1,6 +1,6 @@ examples = [ 'general', - 'walk' + 'walk', ] if have_termios diff --git a/libgit2-glib/meson.build b/libgit2-glib/meson.build index 62a7eba..b71e527 100644 --- a/libgit2-glib/meson.build +++ b/libgit2-glib/meson.build @@ -66,7 +66,7 @@ headers = [ 'ggit-tree.h', 'ggit-tree-builder.h', 'ggit-tree-entry.h', - 'ggit-types.h' + 'ggit-types.h', ] private_headers = [ @@ -194,7 +194,7 @@ platform_deps = [ gio_dep, glib_dep, gobject_dep, - libgit2_dep + libgit2_dep, ] if cc.get_id() == 'msvc' @@ -222,7 +222,7 @@ pkg.generate( subdirs: libgit2_glib_api_name, requires: ['libgit2 >= ' + git2_req, 'glib-2.0 >= ' + glib_req, 'gobject-2.0 >= ' + glib_req, 'gio-2.0 >= ' + glib_req], variables: 'exec_prefix=${prefix}', - extra_cflags: extra_args + extra_cflags: extra_args, ) # Internal dependency, for tests and benchmarks diff --git a/meson.build b/meson.build index 1a069b2..bc50b2b 100644 --- a/meson.build +++ b/meson.build @@ -75,7 +75,7 @@ else '-Werror=missing-braces', '-Werror=return-type', '-Werror=array-bounds', - '-Werror=write-strings' + '-Werror=write-strings', ]) endif @@ -88,7 +88,7 @@ if libgit2_glib_buildtype.contains('debug') else common_flags += [ '-DG_DISABLE_CAST_CHECKS', - '-DG_DISABLE_CHECKS' + '-DG_DISABLE_CHECKS', ] endif diff --git a/tests/meson.build b/tests/meson.build index 5c0f22a..175c7a2 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,5 +1,5 @@ unit_tests = [ - 'repository' + 'repository', ] foreach unit: unit_tests -- GitLab From e1797a26dca3e3b9085092b5b4e7e370f293fce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Tue, 23 Oct 2018 07:35:35 +0200 Subject: [PATCH 04/15] meson: Use meson build files convention meson build files has been changed to comply with the convention[0]. [0] https://github.com/mesonbuild/meson/blob/master/data/syntax-highlighting/vim/indent/meson.vim --- docs/reference/meson.build | 42 ++++++++++--------- examples/meson.build | 11 +++-- libgit2-glib/meson.build | 83 +++++++++++++++++++++++--------------- meson.build | 18 +++++---- tests/meson.build | 20 +++++---- 5 files changed, 103 insertions(+), 71 deletions(-) diff --git a/docs/reference/meson.build b/docs/reference/meson.build index 8f545e7..4a414f2 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -3,26 +3,30 @@ docs_conf.set('PACKAGE_VERSION', libgit2_glib_version) name = 'version.xml' -configure_file(input: name + '.in', - output: name, - configuration: docs_conf) +configure_file( + input: name + '.in', + output: name, + configuration: docs_conf, +) glib_prefix = glib_dep.get_pkgconfig_variable('prefix') glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html') -gnome.gtkdoc(libgit2_glib_api_name, - main_sgml: libgit2_glib_api_name + '-docs.sgml', - src_dir: join_paths(meson.source_root(), 'libgit2-glib'), - dependencies: libgit2_glib_dep, - gobject_typesfile: libgit2_glib_api_name + '.types', - scan_args: [ - '--rebuild-types', - '--ignore-headers=' + ' '.join(private_headers), - ], - fixxref_args: [ - '--extra-dir=' + join_paths(glib_docpath, 'glib'), - '--extra-dir=' + join_paths(glib_docpath, 'gobject'), - '--extra-dir=' + join_paths(glib_docpath, 'gio'), - '--html-dir=' + join_paths(libgit2_glib_prefix, gnome.gtkdoc_html_dir(libgit2_glib_api_name)), - ], - install: true) +gnome.gtkdoc( + libgit2_glib_api_name, + main_sgml: libgit2_glib_api_name + '-docs.sgml', + src_dir: join_paths(meson.source_root(), 'libgit2-glib'), + dependencies: libgit2_glib_dep, + gobject_typesfile: libgit2_glib_api_name + '.types', + scan_args: [ + '--rebuild-types', + '--ignore-headers=' + ' '.join(private_headers), + ], + fixxref_args: [ + '--extra-dir=' + join_paths(glib_docpath, 'glib'), + '--extra-dir=' + join_paths(glib_docpath, 'gobject'), + '--extra-dir=' + join_paths(glib_docpath, 'gio'), + '--html-dir=' + join_paths(libgit2_glib_prefix, gnome.gtkdoc_html_dir(libgit2_glib_api_name)), + ], + install: true, +) diff --git a/examples/meson.build b/examples/meson.build index 3987ae0..e5e8d92 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -4,11 +4,14 @@ examples = [ ] if have_termios - examples += [ 'clone' ] + examples += ['clone'] endif foreach example: examples - executable(example, example + '.c', - dependencies: libgit2_glib_dep, - include_directories: libgit2_glib_inc) + executable( + example, + example + '.c', + dependencies: libgit2_glib_dep, + include_directories: libgit2_glib_inc, + ) endforeach diff --git a/libgit2-glib/meson.build b/libgit2-glib/meson.build index b71e527..f50d647 100644 --- a/libgit2-glib/meson.build +++ b/libgit2-glib/meson.build @@ -163,7 +163,7 @@ if enable_ssh #include ''' - extra_args += [ '-DGIT_SSH=1' ] + extra_args += ['-DGIT_SSH=1'] else private_headers += ssh_headers @@ -179,16 +179,22 @@ sources += configure_file( input: ggit_h + '.in', output: ggit_h, configuration: ggit_h_conf, - install_dir: libgit2_glib_pkgincludedir) + install_dir: libgit2_glib_pkgincludedir, +) -enum_types = gnome.mkenums('ggit-enum-types', - sources : headers, - h_template : 'ggit-enum-types.h.template', - c_template : 'ggit-enum-types.c.template', - install_header : true, - install_dir: libgit2_glib_pkgincludedir) +enum_types = gnome.mkenums( + 'ggit-enum-types', + sources: headers, + h_template: 'ggit-enum-types.h.template', + c_template: 'ggit-enum-types.c.template', + install_header: true, + install_dir: libgit2_glib_pkgincludedir, +) -install_headers(headers, subdir: join_paths(libgit2_glib_api_name, meson.project_name())) +install_headers( + headers, + subdir: join_paths(libgit2_glib_api_name, meson.project_name()) +) platform_deps = [ gio_dep, @@ -200,18 +206,20 @@ platform_deps = [ if cc.get_id() == 'msvc' libgit2_glib_link_args = [] else - libgit2_glib_link_args = [ '-Wl,-Bsymbolic-functions' ] + libgit2_glib_link_args = ['-Wl,-Bsymbolic-functions'] endif -libgit2_glib = shared_library('git2-glib-@0@'.format(libgit2_glib_api_version), +libgit2_glib = shared_library( + 'git2-glib-@0@'.format(libgit2_glib_api_version), include_directories: core_inc, sources: sources + enum_types + private_headers, version: libversion, soversion: soversion, install: true, dependencies: platform_deps, - c_args: extra_args + [ '-DG_LOG_DOMAIN="@0@"'.format(libgit2_glib_ns) ], - link_args: libgit2_glib_link_args) + c_args: extra_args + ['-DG_LOG_DOMAIN="@0@"'.format(libgit2_glib_ns)], + link_args: libgit2_glib_link_args, +) pkg.generate( libraries: libgit2_glib, @@ -226,32 +234,41 @@ pkg.generate( ) # Internal dependency, for tests and benchmarks -libgit2_glib_dep = declare_dependency(link_with: libgit2_glib, - include_directories: [ core_inc, libgit2_glib_inc ], - dependencies: platform_deps, - # Everything that uses libgit2-glib needs this built to compile - sources: enum_types[1]) +libgit2_glib_dep = declare_dependency( + link_with: libgit2_glib, + include_directories: [core_inc, libgit2_glib_inc], + dependencies: platform_deps, + # Everything that uses libgit2-glib needs this built to compile + sources: enum_types[1], +) if enable_python - install_data('Ggit.py', install_dir: join_paths(python.sysconfig_path('purelib'), 'gi', 'overrides')) + install_data( + 'Ggit.py', + install_dir: join_paths(python.sysconfig_path('purelib'), 'gi', 'overrides'), + ) endif if enable_gir - libgit2_glib_gir = gnome.generate_gir(libgit2_glib, - sources: headers + sources + enum_types, - namespace: libgit2_glib_ns, - nsversion: libgit2_glib_api_version, - identifier_prefix: libgit2_glib_ns, - symbol_prefix: libgit2_glib_ns.to_lower(), - export_packages: libgit2_glib_api_name, - includes: [ 'GObject-2.0', 'GLib-2.0', 'Gio-2.0' ], - header: join_paths(meson.project_name(), ggit_h), - install: true) + libgit2_glib_gir = gnome.generate_gir( + libgit2_glib, + sources: headers + sources + enum_types, + namespace: libgit2_glib_ns, + nsversion: libgit2_glib_api_version, + identifier_prefix: libgit2_glib_ns, + symbol_prefix: libgit2_glib_ns.to_lower(), + export_packages: libgit2_glib_api_name, + includes: ['GObject-2.0', 'GLib-2.0', 'Gio-2.0'], + header: join_paths(meson.project_name(), ggit_h), + install: true, + ) if enable_vapi - gnome.generate_vapi(libgit2_glib_api_name, - sources: libgit2_glib_gir[0], - packages: 'gio-2.0', - install: true) + gnome.generate_vapi( + libgit2_glib_api_name, + sources: libgit2_glib_gir[0], + packages: 'gio-2.0', + install: true, + ) endif endif diff --git a/meson.build b/meson.build index bc50b2b..13ddcdd 100644 --- a/meson.build +++ b/meson.build @@ -1,8 +1,10 @@ -project('libgit2-glib', 'c', - version: '0.27.7', - default_options: 'buildtype=debugoptimized', - license: 'LGPL2+', - meson_version: '>= 0.48.0') +project( + 'libgit2-glib', 'c', + version: '0.27.7', + default_options: 'buildtype=debugoptimized', + license: 'LGPL2+', + meson_version: '>= 0.48.0', +) libgit2_glib_version = meson.project_version() version_array = libgit2_glib_version.split('.') @@ -80,10 +82,10 @@ else endif if libgit2_glib_buildtype.contains('debug') - common_flags += [ '-DLIBGIT2_GLIB_ENABLE_DEBUG' ] + common_flags += ['-DLIBGIT2_GLIB_ENABLE_DEBUG'] if libgit2_glib_buildtype.contains('optimized') - common_flags += [ '-DG_DISABLE_CAST_CHECKS' ] + common_flags += ['-DG_DISABLE_CAST_CHECKS'] endif else common_flags += [ @@ -95,7 +97,7 @@ endif # Workaround for meson's bug # https://github.com/mesonbuild/meson/pull/1896 if get_option('b_ndebug') == true - common_flags += [ '-DG_DISABLE_ASSERT' ] + common_flags += ['-DG_DISABLE_ASSERT'] endif add_project_arguments(common_flags, language: 'c') diff --git a/tests/meson.build b/tests/meson.build index 175c7a2..f5ccd07 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,10 +1,16 @@ -unit_tests = [ - 'repository', -] +unit_tests = ['repository'] foreach unit: unit_tests - exe = executable(unit, unit + '.c', - dependencies: libgit2_glib_dep, - include_directories: libgit2_glib_inc) - test(unit, exe, args: [ '--tap', '-k' ]) + exe = executable( + unit, + unit + '.c', + dependencies: libgit2_glib_dep, + include_directories: libgit2_glib_inc, + ) + + test( + unit, + exe, + args: ['--tap', '-k'], + ) endforeach -- GitLab From c85e258c83c426252beb5f4ac223aca562470de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Mon, 12 Nov 2018 12:29:09 +0100 Subject: [PATCH 05/15] meson: Fix `b_ndebug` workaround There is a workaround present in the source root meson build file due to a bug in an older meson version[0]. The workaround is wrong and is fixed now. [0] https://github.com/mesonbuild/meson/pull/1896 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 13ddcdd..1965d14 100644 --- a/meson.build +++ b/meson.build @@ -96,7 +96,7 @@ endif # Workaround for meson's bug # https://github.com/mesonbuild/meson/pull/1896 -if get_option('b_ndebug') == true +if get_option('b_ndebug') == 'true' common_flags += ['-DG_DISABLE_ASSERT'] endif -- GitLab From 2c762bb1ab3be8e5f94116faaf0f3bf7ef4207ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Mon, 12 Nov 2018 12:34:40 +0100 Subject: [PATCH 06/15] meson: Renamed `extra_args` to `cflags` The `extra_args` variable has been renamed to the well known `cflags`, which is more widely used. Its definition has also been removed from the source root meson build file as it is only used in the `libgit2-glib` directory. --- libgit2-glib/meson.build | 12 +++++++----- meson.build | 4 +--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libgit2-glib/meson.build b/libgit2-glib/meson.build index f50d647..5810622 100644 --- a/libgit2-glib/meson.build +++ b/libgit2-glib/meson.build @@ -150,6 +150,8 @@ sources = [ 'ggit-utils.c', ] +cflags = [] + if enable_ssh headers += ssh_headers @@ -163,7 +165,7 @@ if enable_ssh #include ''' - extra_args += ['-DGIT_SSH=1'] + cflags += ['-DGIT_SSH=1'] else private_headers += ssh_headers @@ -211,13 +213,13 @@ endif libgit2_glib = shared_library( 'git2-glib-@0@'.format(libgit2_glib_api_version), - include_directories: core_inc, + include_directories: top_inc, sources: sources + enum_types + private_headers, version: libversion, soversion: soversion, install: true, dependencies: platform_deps, - c_args: extra_args + ['-DG_LOG_DOMAIN="@0@"'.format(libgit2_glib_ns)], + c_args: cflags + ['-DG_LOG_DOMAIN="@0@"'.format(libgit2_glib_ns)], link_args: libgit2_glib_link_args, ) @@ -230,13 +232,13 @@ pkg.generate( subdirs: libgit2_glib_api_name, requires: ['libgit2 >= ' + git2_req, 'glib-2.0 >= ' + glib_req, 'gobject-2.0 >= ' + glib_req, 'gio-2.0 >= ' + glib_req], variables: 'exec_prefix=${prefix}', - extra_cflags: extra_args, + extra_cflags: cflags, ) # Internal dependency, for tests and benchmarks libgit2_glib_dep = declare_dependency( link_with: libgit2_glib, - include_directories: [core_inc, libgit2_glib_inc], + include_directories: [top_inc, libgit2_glib_inc], dependencies: platform_deps, # Everything that uses libgit2-glib needs this built to compile sources: enum_types[1], diff --git a/meson.build b/meson.build index 1965d14..13b6611 100644 --- a/meson.build +++ b/meson.build @@ -105,9 +105,7 @@ add_project_arguments(common_flags, language: 'c') # Termios have_termios = cc.has_header('termios.h') -extra_args= [] - -core_inc = include_directories('.') +top_inc = include_directories('.') # Required dependencies git2_req = '0.25.0' -- GitLab From 0f4bd39784076dcf7ded7ae183cf533d69c6505c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Mon, 12 Nov 2018 12:42:52 +0100 Subject: [PATCH 07/15] meson: Move meson modules and includes meson modules and global directory include have been moved so they are available and usable early. --- meson.build | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 13b6611..fddcb9c 100644 --- a/meson.build +++ b/meson.build @@ -43,6 +43,11 @@ libgit2_glib_datadir = join_paths(libgit2_glib_prefix, get_option('datadir')) libgit2_glib_pkgincludedir = join_paths(libgit2_glib_includedir, libgit2_glib_api_name, meson.project_name()) +gnome = import('gnome') +pkg = import('pkgconfig') + +top_inc = include_directories('.') + cc = meson.get_compiler('c') # Compiler and Debugging flags @@ -105,8 +110,6 @@ add_project_arguments(common_flags, language: 'c') # Termios have_termios = cc.has_header('termios.h') -top_inc = include_directories('.') - # Required dependencies git2_req = '0.25.0' glib_req = '2.44.0' @@ -160,9 +163,6 @@ if enable_python meson.add_install_script('meson_python_compile.py', libgit2_glib_libdir) endif -gnome = import('gnome') -pkg = import('pkgconfig') - subdir('libgit2-glib') subdir('examples') subdir('tests') -- GitLab From 5e9bf6ddd96742209c546aa31dfdc9f6c7211266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Mon, 12 Nov 2018 13:29:40 +0100 Subject: [PATCH 08/15] meson: Fix DESTDIR use in Windows The use of DESTDIR in Windows produces some errors[0]. To fix this issue a different approach has been used for paths. Instead of using absolute paths, relative paths are used as meson does. One of this relative paths is used along with MESON_INSTALL_DESTDIR_PREFIX to avoid any issues. [0] https://github.com/Alexpux/MINGW-packages/pull/4560#issuecomment-431294899 --- meson.build | 7 +++---- meson_python_compile.py | 4 +++- meson_vapi_link.py | 7 ++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index fddcb9c..3b4d2f4 100644 --- a/meson.build +++ b/meson.build @@ -37,11 +37,10 @@ revision = libgit2_glib_interface_age libversion = '@0@.@1@.@2@'.format(soversion, current, revision) libgit2_glib_prefix = get_option('prefix') -libgit2_glib_libdir = join_paths(libgit2_glib_prefix, get_option('libdir')) -libgit2_glib_includedir = join_paths(libgit2_glib_prefix, get_option('includedir')) -libgit2_glib_datadir = join_paths(libgit2_glib_prefix, get_option('datadir')) +libgit2_glib_libdir = get_option('libdir') +libgit2_glib_datadir = get_option('datadir') -libgit2_glib_pkgincludedir = join_paths(libgit2_glib_includedir, libgit2_glib_api_name, meson.project_name()) +libgit2_glib_pkgincludedir = join_paths(get_option('includedir'), libgit2_glib_api_name, meson.project_name()) gnome = import('gnome') pkg = import('pkgconfig') diff --git a/meson_python_compile.py b/meson_python_compile.py index 8aff82c..1fa54ff 100644 --- a/meson_python_compile.py +++ b/meson_python_compile.py @@ -5,7 +5,9 @@ import subprocess import sys if not os.environ.get('DESTDIR'): - libdir = sys.argv[1] + prefix = os.environ['MESON_INSTALL_PREFIX'] + + libdir = os.path.join(prefix, sys.argv[1]) print('Byte-compiling python modules...') subprocess.call(['python', '-m', 'compileall', '-f', '-q', libdir]) diff --git a/meson_vapi_link.py b/meson_vapi_link.py index 435cd95..eb64fd6 100644 --- a/meson_vapi_link.py +++ b/meson_vapi_link.py @@ -4,10 +4,7 @@ import os import subprocess import sys -vapidir = os.path.join(sys.argv[1], 'vala', 'vapi') - -destdir = os.environ.get('DESTDIR', '') -dest_vapidir = os.path.normpath(destdir + os.sep + vapidir) +vapidir = os.path.join(os.environ['MESON_INSTALL_DESTDIR_PREFIX'], sys.argv[1], 'vala', 'vapi') # FIXME: meson will not track the creation of these files # https://github.com/mesonbuild/meson/blob/master/mesonbuild/scripts/uninstall.py#L39 @@ -15,7 +12,7 @@ old = 'ggit-1.0' new = 'libgit2-glib-1.0' wd = os.getcwd() -os.chdir(dest_vapidir) +os.chdir(vapidir) for ext in ['vapi', 'deps']: src = os.path.join('{}.{}'.format(new, ext)) -- GitLab From 88e7d761b2173b10ba21a5580b5226d032be88d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Mon, 12 Nov 2018 14:54:31 +0100 Subject: [PATCH 09/15] meson: Change the use of `enum_types` variable Although the `enum_types` variable stores source files from generated enum types, the name does not reflect its real meaning, storee source files. It now stores the name of the file with the enum types description that allows avoiding typos. A new variable called `enum_sources` is now used instead. --- libgit2-glib/meson.build | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libgit2-glib/meson.build b/libgit2-glib/meson.build index 5810622..4735696 100644 --- a/libgit2-glib/meson.build +++ b/libgit2-glib/meson.build @@ -184,11 +184,13 @@ sources += configure_file( install_dir: libgit2_glib_pkgincludedir, ) -enum_types = gnome.mkenums( - 'ggit-enum-types', +enum_types = 'ggit-enum-types' + +enum_sources = gnome.mkenums( + enum_types, sources: headers, - h_template: 'ggit-enum-types.h.template', - c_template: 'ggit-enum-types.c.template', + h_template: enum_types + '.h.template', + c_template: enum_types + '.c.template', install_header: true, install_dir: libgit2_glib_pkgincludedir, ) @@ -214,7 +216,7 @@ endif libgit2_glib = shared_library( 'git2-glib-@0@'.format(libgit2_glib_api_version), include_directories: top_inc, - sources: sources + enum_types + private_headers, + sources: sources + enum_sources + private_headers, version: libversion, soversion: soversion, install: true, @@ -241,7 +243,7 @@ libgit2_glib_dep = declare_dependency( include_directories: [top_inc, libgit2_glib_inc], dependencies: platform_deps, # Everything that uses libgit2-glib needs this built to compile - sources: enum_types[1], + sources: enum_sources[1], ) if enable_python @@ -254,7 +256,7 @@ endif if enable_gir libgit2_glib_gir = gnome.generate_gir( libgit2_glib, - sources: headers + sources + enum_types, + sources: headers + sources + enum_sources, namespace: libgit2_glib_ns, nsversion: libgit2_glib_api_version, identifier_prefix: libgit2_glib_ns, -- GitLab From d02b7864c52807c1fd3f020e5f4bb4e9c821acb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Mon, 12 Nov 2018 14:58:24 +0100 Subject: [PATCH 10/15] meson: Fix `shared_library` properties order Although properties can be mixed, they have been reordered using a more logical order. --- libgit2-glib/meson.build | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libgit2-glib/meson.build b/libgit2-glib/meson.build index 4735696..a3b9feb 100644 --- a/libgit2-glib/meson.build +++ b/libgit2-glib/meson.build @@ -214,15 +214,15 @@ else endif libgit2_glib = shared_library( - 'git2-glib-@0@'.format(libgit2_glib_api_version), - include_directories: top_inc, - sources: sources + enum_sources + private_headers, + 'git2-glib-' + libgit2_glib_api_version, version: libversion, soversion: soversion, - install: true, + sources: sources + enum_sources + private_headers, + include_directories: top_inc, dependencies: platform_deps, c_args: cflags + ['-DG_LOG_DOMAIN="@0@"'.format(libgit2_glib_ns)], link_args: libgit2_glib_link_args, + install: true, ) pkg.generate( -- GitLab From 1706a9efd2c829de361a25c57050ae3e3499cdd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Mon, 12 Nov 2018 15:19:47 +0100 Subject: [PATCH 11/15] meson: Use meson dependencies as pkg-config requirement Since recent meson versions, meson's dependencies can be used in the `requires` property. The older ad-hoc string has been replaced by dependencies so the string is generated automatically. --- libgit2-glib/meson.build | 2 +- meson.build | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/libgit2-glib/meson.build b/libgit2-glib/meson.build index a3b9feb..f802a51 100644 --- a/libgit2-glib/meson.build +++ b/libgit2-glib/meson.build @@ -232,7 +232,7 @@ pkg.generate( description: 'libgit2-glib, a a glib wrapper library around the libgit2 git access library.', filebase: libgit2_glib_api_name, subdirs: libgit2_glib_api_name, - requires: ['libgit2 >= ' + git2_req, 'glib-2.0 >= ' + glib_req, 'gobject-2.0 >= ' + glib_req, 'gio-2.0 >= ' + glib_req], + requires: platform_deps, variables: 'exec_prefix=${prefix}', extra_cflags: cflags, ) diff --git a/meson.build b/meson.build index 3b4d2f4..f7bb6d1 100644 --- a/meson.build +++ b/meson.build @@ -110,14 +110,13 @@ add_project_arguments(common_flags, language: 'c') have_termios = cc.has_header('termios.h') # Required dependencies -git2_req = '0.25.0' glib_req = '2.44.0' glib_dep = dependency('glib-2.0', version: '>=' + glib_req) gobject_dep = dependency('gobject-2.0', version: '>=' + glib_req) gio_dep = dependency('gio-2.0', version: '>=' + glib_req) -libgit2_dep = dependency('libgit2', version: '>=' + git2_req) +libgit2_dep = dependency('libgit2', version: '>= 0.25.0') enable_gir = get_option('introspection') if enable_gir -- GitLab From b82d0b41ed6630915df4c0e80c2e95b57319e40c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Mon, 12 Nov 2018 15:23:02 +0100 Subject: [PATCH 12/15] meson: Remove headers from source list Headers are not necessary to be listed in the source list unless if they are generated. The list of headers have been removed from the source list. --- libgit2-glib/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgit2-glib/meson.build b/libgit2-glib/meson.build index f802a51..70afd42 100644 --- a/libgit2-glib/meson.build +++ b/libgit2-glib/meson.build @@ -217,7 +217,7 @@ libgit2_glib = shared_library( 'git2-glib-' + libgit2_glib_api_version, version: libversion, soversion: soversion, - sources: sources + enum_sources + private_headers, + sources: sources + enum_sources, include_directories: top_inc, dependencies: platform_deps, c_args: cflags + ['-DG_LOG_DOMAIN="@0@"'.format(libgit2_glib_ns)], -- GitLab From 4c71fee10f4fb350349c61d15251336d6d02feb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Mon, 12 Nov 2018 15:36:21 +0100 Subject: [PATCH 13/15] meson: Fix internal `libgit2_glib_dep` dependency `libgit2_glib_dep` only exposes the list of headers used along with `libgit2_glib` shared library. These libraries are located in the `libgit2-glib` directory, so this should be the only shared directory. Tests and examples use this dependency that also includes the top source directory. However the top source directory include must be added independently. --- examples/meson.build | 2 +- libgit2-glib/meson.build | 8 +++----- tests/meson.build | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/examples/meson.build b/examples/meson.build index e5e8d92..fc1024d 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -12,6 +12,6 @@ foreach example: examples example, example + '.c', dependencies: libgit2_glib_dep, - include_directories: libgit2_glib_inc, + include_directories: top_inc, ) endforeach diff --git a/libgit2-glib/meson.build b/libgit2-glib/meson.build index 70afd42..3a9ec68 100644 --- a/libgit2-glib/meson.build +++ b/libgit2-glib/meson.build @@ -1,5 +1,3 @@ -libgit2_glib_inc = include_directories('.') - headers = [ 'ggit-annotated-commit.h', 'ggit-blame.h', @@ -239,11 +237,11 @@ pkg.generate( # Internal dependency, for tests and benchmarks libgit2_glib_dep = declare_dependency( - link_with: libgit2_glib, - include_directories: [top_inc, libgit2_glib_inc], - dependencies: platform_deps, # Everything that uses libgit2-glib needs this built to compile sources: enum_sources[1], + include_directories: include_directories('.'), + dependencies: platform_deps, + link_with: libgit2_glib, ) if enable_python diff --git a/tests/meson.build b/tests/meson.build index f5ccd07..38f3fb1 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -5,7 +5,7 @@ foreach unit: unit_tests unit, unit + '.c', dependencies: libgit2_glib_dep, - include_directories: libgit2_glib_inc, + include_directories: top_inc, ) test( -- GitLab From 59450fffbc1542bbee914b38edfe092beff62e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Mon, 12 Nov 2018 15:44:48 +0100 Subject: [PATCH 14/15] meson: Fix properties orders Properties have been reordered in both `tests` and `examples` to be consistent with the order in other built objects. --- examples/meson.build | 2 +- tests/meson.build | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/examples/meson.build b/examples/meson.build index fc1024d..5cb2cbc 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -11,7 +11,7 @@ foreach example: examples executable( example, example + '.c', - dependencies: libgit2_glib_dep, include_directories: top_inc, + dependencies: libgit2_glib_dep, ) endforeach diff --git a/tests/meson.build b/tests/meson.build index 38f3fb1..a318c90 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,16 +1,14 @@ -unit_tests = ['repository'] +unit_test = 'repository' -foreach unit: unit_tests - exe = executable( - unit, - unit + '.c', - dependencies: libgit2_glib_dep, - include_directories: top_inc, - ) +exe = executable( + unit_test, + unit_test + '.c', + include_directories: top_inc, + dependencies: libgit2_glib_dep, +) - test( - unit, - exe, - args: ['--tap', '-k'], - ) -endforeach +test( + unit_test, + exe, + args: ['--tap', '-k'], +) -- GitLab From 3b69dca01a5c27f260a523fc32134af8311149aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Mon, 12 Nov 2018 17:05:22 +0100 Subject: [PATCH 15/15] meson: Improve documentation generation GtkDoc generated documentation takes advantage of different new meson's improvements. It uses the `gtkdoc_html_dir` function to set the paths to be fixed. It also makes use of the `ignore_headers` parameter. Finally, it uses the `version.xml` file target as a content file instad of assuming the same build location. --- docs/reference/meson.build | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/reference/meson.build b/docs/reference/meson.build index 4a414f2..ea6b0af 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -1,32 +1,32 @@ +glib_prefix = glib_dep.get_pkgconfig_variable('prefix') + +fixxref_args = [ + '--extra-dir=' + join_paths(glib_prefix, gnome.gtkdoc_html_dir('glib')), + '--extra-dir=' + join_paths(glib_prefix, gnome.gtkdoc_html_dir('gobject')), + '--extra-dir=' + join_paths(glib_prefix, gnome.gtkdoc_html_dir('gio')), + '--html-dir=' + join_paths(libgit2_glib_prefix, gnome.gtkdoc_html_dir(libgit2_glib_api_name)), +] + docs_conf = configuration_data() docs_conf.set('PACKAGE_VERSION', libgit2_glib_version) name = 'version.xml' -configure_file( +content_files = configure_file( input: name + '.in', output: name, configuration: docs_conf, ) -glib_prefix = glib_dep.get_pkgconfig_variable('prefix') -glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html') - gnome.gtkdoc( libgit2_glib_api_name, main_sgml: libgit2_glib_api_name + '-docs.sgml', src_dir: join_paths(meson.source_root(), 'libgit2-glib'), dependencies: libgit2_glib_dep, + ignore_headers: private_headers, gobject_typesfile: libgit2_glib_api_name + '.types', - scan_args: [ - '--rebuild-types', - '--ignore-headers=' + ' '.join(private_headers), - ], - fixxref_args: [ - '--extra-dir=' + join_paths(glib_docpath, 'glib'), - '--extra-dir=' + join_paths(glib_docpath, 'gobject'), - '--extra-dir=' + join_paths(glib_docpath, 'gio'), - '--html-dir=' + join_paths(libgit2_glib_prefix, gnome.gtkdoc_html_dir(libgit2_glib_api_name)), - ], + scan_args: '--rebuild-types', + fixxref_args: fixxref_args, + content_files: content_files, install: true, ) -- GitLab