[gitg] build: Port to meson build system



commit c876e0e255f23dea2b04e6bfc5233f4e1ce0f685
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Mon Oct 2 16:01:18 2017 +0200

    build: Port to meson build system
    
    meson is a build system focused on speed an ease of use, which
    helps speeding up the software development. This patch adds meson
    support along autotools.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788796

 contrib/ide/meson.build   |   17 +++
 contrib/xml/meson.build   |   19 +++
 data/icons/meson.build    |   20 ++++
 data/meson.build          |   59 ++++++++++
 gitg/meson.build          |  169 ++++++++++++++++++++++++++++
 libgitg-ext/meson.build   |  151 +++++++++++++++++++++++++
 libgitg.map               |    6 +
 libgitg/meson.build       |  199 +++++++++++++++++++++++++++++++++
 meson.build               |  270 +++++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt         |    4 +
 meson_post_install.py     |   33 ++++++
 plugins/diff/meson.build  |   21 ++++
 plugins/files/meson.build |   28 +++++
 plugins/meson.build       |   20 ++++
 po/meson.build            |    1 +
 tests/gitg/meson.build    |   35 ++++++
 tests/libgitg/meson.build |   30 +++++
 tests/meson.build         |   26 +++++
 tests/support/meson.build |   22 ++++
 19 files changed, 1130 insertions(+), 0 deletions(-)
---
diff --git a/contrib/ide/meson.build b/contrib/ide/meson.build
new file mode 100644
index 0000000..a606dad
--- /dev/null
+++ b/contrib/ide/meson.build
@@ -0,0 +1,17 @@
+sources = files(
+  'ide-doap.c',
+  'ide-doap-person.c'
+)
+
+libide = static_library(
+  'ide',
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: libxml_dep
+)
+
+libide_dep = declare_dependency(
+  link_with: libide,
+  include_directories: include_directories('.'),
+  dependencies: valac.find_library('ide', dirs: meson.current_source_dir())
+)
diff --git a/contrib/xml/meson.build b/contrib/xml/meson.build
new file mode 100644
index 0000000..da8d171
--- /dev/null
+++ b/contrib/xml/meson.build
@@ -0,0 +1,19 @@
+sources = files('xml-reader.c')
+
+deps = [
+  gio_dep,
+  dependency('libxml-2.0', version: '>= 2.9.0')
+]
+
+libxml = static_library(
+  'xml',
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: deps
+)
+
+libxml_dep = declare_dependency(
+  link_with: libxml,
+  include_directories: include_directories('.'),
+  dependencies: deps
+)
diff --git a/data/icons/meson.build b/data/icons/meson.build
new file mode 100644
index 0000000..bf229ee
--- /dev/null
+++ b/data/icons/meson.build
@@ -0,0 +1,20 @@
+icon_sizes = [
+  '16x16',
+  '22x22',
+  '24x24',
+  '32x32',
+  '48x48',
+  '256x256'
+]
+
+foreach icon_size: icon_sizes
+  install_data(
+    '_'.join(['hicolor', 'apps', icon_size, 'gitg.png']),
+    install_dir: join_paths(gitg_datadir, 'icons', 'hicolor', icon_size, 'apps')
+  )
+endforeach
+
+install_data(
+  '_'.join(['hicolor', 'apps', 'scalable', 'gitg-symbolic.svg']),
+  install_dir: join_paths(gitg_datadir, 'icons', 'hicolor', 'scalable', 'apps')
+)
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..4e780a0
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,59 @@
+subdir('icons')
+
+desktop_conf = configuration_data()
+desktop_conf.set('VERSION', gitg_version)
+
+desktop = 'gitg.desktop'
+
+desktop_in = configure_file(
+  input: desktop + '.in.in',
+  output: desktop + '.in',
+  configuration: desktop_conf
+)
+
+custom_target(
+  desktop,
+  input: desktop_in,
+  output: desktop,
+  command: intltool_desktop_cmd,
+  install: true,
+  install_dir: join_paths(gitg_datadir, 'applications')
+)
+
+schema_conf = configuration_data()
+schema_conf.set('GETTEXT_PACKAGE', gitg_gettext)
+
+schema = 'org.gnome.gitg.gschema.xml'
+
+schema_in = configure_file(
+  input: schema + '.in.in',
+  output: schema + '.in',
+  configuration: schema_conf
+)
+
+custom_target(
+  schema,
+  input: schema_in,
+  output: schema,
+  command: [intltool_merge, '-x', '-u', '--no-translations', '@INPUT@', '@OUTPUT@'],
+  install: true,
+  install_dir: join_paths(gitg_datadir, 'glib-2.0', 'schemas')
+)
+
+install_data(
+  'gitg.appdata.xml',
+  install_dir: join_paths(gitg_datadir, 'metainfo')
+)
+
+install_data(
+  'gitg.1',
+  install_dir: join_paths(gitg_mandir, 'man1')
+)
+
+enable_glade_catalog = get_option('enable-glade-catalog')
+if enable_glade_catalog
+  install_data(
+    'gitg-glade.xml',
+    install_dir: join_paths(gitg_datadir, 'glade', 'catalogs')
+  )
+endif
diff --git a/gitg/meson.build b/gitg/meson.build
new file mode 100644
index 0000000..421076f
--- /dev/null
+++ b/gitg/meson.build
@@ -0,0 +1,169 @@
+gitg_sources = files(
+  'gitg-action-support.vala',
+  'gitg-commit-action-cherry-pick.vala',
+  'gitg-ref-action-checkout.vala',
+  'gitg-ref-action-merge.vala'
+)
+
+sources = gitg_sources + files(
+  'commit/gitg-commit-dialog.vala',
+  'commit/gitg-commit-paned.vala',
+  'commit/gitg-commit-sidebar.vala',
+  'commit/gitg-commit-submodule-diff-view.vala',
+  'commit/gitg-commit-submodule-history-view.vala',
+  'commit/gitg-commit-submodule-info.vala',
+  'commit/gitg-commit.vala',
+  'history/gitg-history-action-interface.vala',
+  'history/gitg-history-command-line.vala',
+  'history/gitg-history-paned.vala',
+  'history/gitg-history-refs-list.vala',
+  'history/gitg-history.vala',
+  'preferences/gitg-preferences-commit.vala',
+  'preferences/gitg-preferences-dialog.vala',
+  'preferences/gitg-preferences-history.vala',
+  'preferences/gitg-preferences-interface.vala',
+  'gitg-animated-paned.vala',
+  'gitg-application.vala',
+  'gitg-author-details-dialog.vala',
+  'gitg-builder.vala',
+  'gitg-clone-dialog.vala',
+  'gitg-commit-action-create-branch.vala',
+  'gitg-commit-action-create-patch.vala',
+  'gitg-commit-action-create-tag.vala',
+  'gitg-convert.vala',
+  'gitg-create-branch-dialog.vala',
+  'gitg-create-tag-dialog.vala',
+  'gitg-dash-view.vala',
+  'gitg-dirs.vala',
+  'gitg-notifications.vala',
+  'gitg-plugins-engine.vala',
+  'gitg-popup-menu.vala',
+  'gitg-recursive-monitor.vala',
+  'gitg-recursive-scanner.vala',
+  'gitg-ref-action-copy-name.vala',
+  'gitg-ref-action-delete.vala',
+  'gitg-ref-action-fetch.vala',
+  'gitg-ref-action-rename.vala',
+  'gitg-remote-manager.vala',
+  'gitg-remote-notification.vala',
+  'gitg-simple-notification.vala',
+  'gitg-ui-elements.vala',
+  'gitg-window.vala',
+  'gitg.vala'
+)
+
+deps = [
+  config_dep,
+  gee_dep,
+  gio_dep,
+  gitg_platform_support_dep,
+  glib_dep,
+  gtk_dep,
+  gtksourceview_dep,
+  libgit2_glib_dep,
+  libgitg_dep,
+  libgitg_ext_dep,
+  libpeas_dep,
+  m_dep,
+  dependency('gobject-introspection-1.0', version: '>= 0.10.1'),
+  dependency('gtkspell3-3.0')
+]
+
+cflags = warn_flags + [
+  '-DDATADIR="@0@"'.format(gitg_datadir),
+  '-DGITG_DATADIR="@0@"'.format(gitg_pkgdatadir),
+  '-DGITG_LOCALEDIR="@0@"'.format(gitg_localedir)
+]
+
+resources_conf = configuration_data()
+resources_conf.set('PLATFORM_NAME', platform_name)
+
+resources = 'gitg-resources.xml'
+
+resources_in = configure_file(
+  input: join_paths('resources', resources + '.in'),
+  output: resources,
+  configuration: resources_conf
+)
+
+resource_data = files(
+  'resources/ui//gitg-author-details-dialog.ui',
+  'resources/ui//gitg-clone-dialog.ui',
+  'resources/ui//gitg-commit-dialog.ui',
+  'resources/ui//gitg-commit-paned.ui',
+  'resources/ui//gitg-commit-submodule-diff-view.ui',
+  'resources/ui//gitg-commit-submodule-history-view.ui',
+  'resources/ui//gitg-commit-submodule-info.ui',
+  'resources/ui//gitg-create-branch-dialog.ui',
+  'resources/ui//gitg-create-tag-dialog.ui',
+  'resources/ui//gitg-dash-view.ui',
+  'resources/ui//gitg-history-paned.ui',
+  'resources/ui//gitg-history-ref-header.ui',
+  'resources/ui//gitg-history-ref-row.ui',
+  'resources/ui//gitg-menus.ui',
+  'resources/ui//gitg-preferences-commit.ui',
+  'resources/ui//gitg-preferences-history.ui',
+  'resources/ui//gitg-preferences-interface.ui',
+  'resources/ui//gitg-preferences.ui',
+  'resources/ui//gitg-remote-notification.ui',
+  'resources/ui//gitg-shortcuts.ui',
+  'resources/ui//gitg-simple-notification.ui',
+  'resources/ui//gitg-window.ui',
+  'resources/ui//style.css',
+  'resources/ui//style-@0@.css'.format(platform_name)
+)
+
+sources += gnome.compile_resources(
+  'gitg-resources',
+  resources_in,
+  source_dir: 'resources',
+  dependencies: resource_data,
+  export: true
+)
+
+vala_flags = '--gresourcesdir=' + join_paths(meson.current_source_dir(), 'resources')
+
+if gtk_shortcuts_window
+  vala_args += '--define GTK_SHORTCUTS_WINDOW'
+endif
+
+executable(
+  gitg_name,
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: deps,
+  c_args: cflags,
+  vala_args: vala_flags,
+  install: true,
+  install_dir: gitg_bindir
+)
+
+ldflags = []
+
+if have_version_script
+  ldflags += '-Wl,--version-script,' + symbol_map
+endif
+
+# FIXME: to be tested on win32
+if platform_name == 'win32'
+  win = import('windows')
+
+  sources += win.compile_resources(
+    'gitg.rc',
+    args: ['-O', 'coff']
+  )
+
+  ldflags += '-mwindows'
+endif
+
+gitg = shared_library(
+  gitg_name,
+  name_prefix: '',
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: deps,
+  c_args: cflags,
+  vala_args: vala_flags,
+  link_args: ldflags,
+  link_depends: symbol_map
+)
diff --git a/libgitg-ext/meson.build b/libgitg-ext/meson.build
new file mode 100644
index 0000000..a29d3ce
--- /dev/null
+++ b/libgitg-ext/meson.build
@@ -0,0 +1,151 @@
+name = gitg_name + '-ext'
+api_name = '@0@-@1@'.format(name, gitg_api_version)
+
+lib_name = 'lib' + name
+lib_api_name = 'lib' + api_name
+
+gir_ns = 'GitgExt'
+gir_api_name = '@0@-@1@'.format(gir_ns, gitg_gir_version)
+gir_name = gir_api_name + '.gir'
+gir_typelib = gir_api_name + '.typelib'
+
+sources = files(
+  'gitg-ext-action.vala',
+  'gitg-ext-activity.vala',
+  'gitg-ext-application.vala',
+  'gitg-ext-assembly-info.vala',
+  'gitg-ext-command-line.vala',
+  'gitg-ext-command-lines.vala',
+  'gitg-ext-commit-action.vala',
+  'gitg-ext-history-panel.vala',
+  'gitg-ext-history.vala',
+  'gitg-ext-message-bus.vala',
+  'gitg-ext-message-id.vala',
+  'gitg-ext-message.vala',
+  'gitg-ext-notification.vala',
+  'gitg-ext-notifications.vala',
+  'gitg-ext-preferences.vala',
+  'gitg-ext-ref-action-interface.vala',
+  'gitg-ext-ref-action.vala',
+  'gitg-ext-remote-lookup.vala',
+  'gitg-ext-searchable.vala',
+  'gitg-ext-selectable.vala',
+  'gitg-ext-ui-element.vala',
+  'gitg-ext-ui.vala',
+  'gitg-ext-user-query.vala'
+)
+
+deps = [
+  gee_dep,
+  gtk_dep,
+  libgit2_glib_dep,
+  libgitg_dep
+]
+
+cflags = warn_flags + [
+  '-DDATADIR="@0@"'.format(gitg_datadir),
+  '-DLIBDIR="@0@"'.format(gitg_libdir)
+]
+
+ldflags = []
+
+if have_version_script
+  ldflags += '-Wl,--version-script,' + symbol_map
+endif
+
+libgitg_ext = shared_library(
+  api_name,
+  sources: sources,
+  version: libversion,
+  soversion: soversion,
+  include_directories: top_inc,
+  dependencies: deps,
+  c_args: cflags,
+  vala_header: lib_name + '.h',
+  vala_vapi: lib_api_name + '.vapi',
+  vala_gir: gir_name,
+  link_args: ldflags,
+  link_depends: symbol_map,
+  install: true,
+  install_dir: [
+    gitg_libdir,
+    join_paths(gitg_includedir, lib_api_name, lib_name),
+    true,
+    true
+  ]
+)
+
+libgitg_ext_dep = declare_dependency(
+  link_with: libgitg_ext,
+  include_directories: include_directories('.')
+)
+
+pkg.generate(
+  libraries: libgitg_ext,
+  version: gitg_version,
+  name: lib_name,
+  description: gitg_name + ' extensions library',
+  filebase: lib_api_name,
+  subdirs: lib_api_name,
+  requires: [
+    'gio-2.0',
+    'glib-2.0',
+    'gmodule-2.0',
+    'gobject-2.0',
+    'gtk+-3.0',
+    'gthread-2.0',
+    'libgit2-glib-1.0',
+    'libgitg-1.0',
+    gio_system_pkg
+  ],
+  variables: 'exec_prefix=' + gitg_prefix,
+  install_dir: join_paths(gitg_libdir, 'pkgconfig')
+)
+
+# FIXME: does not work due to missing proper valadoc support
+if enable_docs
+  vala_pkgs = [
+    '--pkg', 'ggit-1.0',
+    '--pkg', 'gio-2.0',
+    '--pkg', 'gtk+-3.0',
+    '--pkg', 'libsoup-2.4',
+    '--pkg', 'gee-0.8'
+  ]
+
+  valaproc_cmd = [
+    valadoc,
+    '--directory', join_paths(meson.source_root(), 'docs'),
+    '--package-name', 'gitgext',
+    vala_pkgs,
+    '--basedir', meson.source_root(),
+    '--vapidir', join_paths(meson.build_root(), 'gitg'),
+    sources
+  ]
+
+  run_target(
+    'libgitg-ext-docs',
+    command: valaproc_cmd
+  )
+endif
+
+custom_target(
+  gir_typelib,
+  output: gir_typelib,
+  command: [g_ir_compiler, '--shared-library', libgitg_ext.full_path(), '--includedir', libgitg_dir, 
'--output', '@OUTPUT@', join_paths(meson.current_build_dir(), gir_name)],
+  depends: [
+    libgitg,
+    libgitg_ext
+  ],
+  install: true,
+  install_dir: gitg_girepositorydir
+)
+
+enable_python = get_option('enable-python')
+if enable_python
+  python = import('python3')
+
+  install_data(
+    'GitgExt.py',
+    install_dir: join_paths(python.sysconfig_path('purelib'), 'gi', 'overrides')
+  )
+endif
diff --git a/libgitg.map b/libgitg.map
new file mode 100644
index 0000000..4a61852
--- /dev/null
+++ b/libgitg.map
@@ -0,0 +1,6 @@
+{
+global:
+  *;
+local:
+  _.*;
+};
diff --git a/libgitg/meson.build b/libgitg/meson.build
new file mode 100644
index 0000000..bdabb3f
--- /dev/null
+++ b/libgitg/meson.build
@@ -0,0 +1,199 @@
+name = gitg_name
+api_name = '@0@-@1@'.format(name, gitg_api_version)
+
+lib_name = 'lib' + name
+lib_api_name = 'lib' + api_name
+
+gir_ns = 'Gitg'
+gir_api_name = '@0@-@1@'.format(gir_ns, gitg_gir_version)
+gir_name = gir_api_name + '.gir'
+gir_typelib = gir_api_name + '.typelib'
+
+sources = files(
+  'gitg-assembly-info.vala',
+  'gitg-async.vala',
+  'gitg-authentication-dialog.vala',
+  'gitg-avatar-cache.vala',
+  'gitg-branch-base.vala',
+  'gitg-branch.vala',
+  'gitg-cell-renderer-lanes.vala',
+  'gitg-color.vala',
+  'gitg-commit-list-view.vala',
+  'gitg-commit-model.vala',
+  'gitg-commit.vala',
+  'gitg-credentials-manager.vala',
+  'gitg-date.vala',
+  'gitg-diff-image-composite.vala',
+  'gitg-diff-image-difference.vala',
+  'gitg-diff-image-overlay.vala',
+  'gitg-diff-image-side-by-side.vala',
+  'gitg-diff-image-slider.vala',
+  'gitg-diff-image-surface-cache.vala',
+  'gitg-diff-selectable.vala',
+  'gitg-diff-stat.vala',
+  'gitg-diff-view-commit-details.vala',
+  'gitg-diff-view-file-info.vala',
+  'gitg-diff-view-file-renderer-binary.vala',
+  'gitg-diff-view-file-renderer-image.vala',
+  'gitg-diff-view-file-renderer-text.vala',
+  'gitg-diff-view-file-renderer.vala',
+  'gitg-diff-view-file-selectable.vala',
+  'gitg-diff-view-file.vala',
+  'gitg-diff-view-lines-renderer.vala',
+  'gitg-diff-view-options.vala',
+  'gitg-diff-view.vala',
+  'gitg-hook.vala',
+  'gitg-init.vala',
+  'gitg-label-renderer.vala',
+  'gitg-lanes.vala',
+  'gitg-lane.vala',
+  'gitg-progress-bin.vala',
+  'gitg-ref-base.vala',
+  'gitg-ref.vala',
+  'gitg-remote.vala',
+  'gitg-repository-list-box.vala',
+  'gitg-repository.vala',
+  'gitg-resource.vala',
+  'gitg-sidebar.vala',
+  'gitg-stage-status-enumerator.vala',
+  'gitg-stage.vala',
+  'gitg-utils.vala',
+  'gitg-when-mapped.vala'
+)
+
+resource_data = files(
+  'resources/ui/gitg-authentication-dialog.ui',
+  'resources/ui/gitg-diff-view-commit-details.ui',
+  'resources/ui/gitg-diff-view-file-renderer-binary.ui',
+  'resources/ui/gitg-diff-view-file-renderer-image.ui',
+  'resources/ui/gitg-diff-view-file-renderer-text.ui',
+  'resources/ui/gitg-diff-view-file.ui',
+  'resources/ui/gitg-diff-view-options-spacing.ui',
+  'resources/ui/gitg-diff-view-options.ui',
+  'resources/ui/gitg-diff-view.ui',
+  'resources/ui/gitg-repository-list-box-row.ui',
+  'resources/ui/gitg-sidebar.ui',
+  'resources/ui/libgitg-style.css'
+)
+
+sources += gnome.compile_resources(
+  'libgitg-resources',
+  'resources/resources.xml',
+  source_dir: 'resources',
+  dependencies: resource_data
+)
+
+deps = [
+  gee_dep,
+  gitg_platform_support_dep,
+  glib_dep,
+  gtk_dep,
+  gtksourceview_dep,
+  libgit2_glib_dep,
+  libide_dep,
+  libsoup_dep,
+  m_dep,
+  dependency('gsettings-desktop-schemas'),
+  dependency('libsecret-1')
+]
+
+cflags = warn_flags + [
+  '-DDATADIR="@0@"'.format(gitg_datadir),
+  '-DLIBDIR="@0@"'.format(gitg_libdir),
+  '-DGETTEXT_PACKAGE="@0@"'.format(gitg_gettext)
+]
+
+ldflags = []
+
+if have_version_script
+  ldflags += '-Wl,--version-script,' + symbol_map
+endif
+
+test_ldflags = []
+if gdk_targets.contains('quartz')
+  sources += files('gitg-platform-support-osx.c')
+  gio_system_pkg = 'gio-unix-2.0'
+  deps += [
+    dependency(gio_system_pkg),
+    find_library('objc')
+  ]
+  cflags += '-xobjective-c'
+
+  test_ldflags += [
+    '-framework Foundation',
+    '-framework AppKit'
+  ]
+elif gdk_targets.contains('win32')
+  sources += files('gitg-platform-support-win32.c')
+  gio_system_pkg = 'gio-windows-2.0'
+  deps += dependency(gio_system_pkg)
+else
+  sources += files('gitg-platform-support.c')
+  gio_system_pkg = 'gio-unix-2.0'
+  deps += dependency(gio_system_pkg)
+endif
+
+foreach test_ldflag: test_ldflags
+  if cc.has_argument(test_ldflag)
+    ldflags += test_ldflag
+  endif
+endforeach
+
+libgitg = shared_library(
+  api_name,
+  sources: sources,
+  version: libversion,
+  soversion: soversion,
+  include_directories: top_inc,
+  dependencies: deps,
+  c_args: cflags,
+  vala_header: lib_name + '.h',
+  vala_vapi: lib_api_name + '.vapi',
+  vala_gir: gir_name,
+  link_args: ldflags,
+  link_depends: symbol_map,
+  install: true,
+  install_dir: [
+    gitg_libdir,
+    join_paths(gitg_includedir, lib_api_name, lib_name),
+    true,
+    true
+  ]
+)
+
+libgitg_dep = declare_dependency(
+  link_with: libgitg,
+  include_directories: include_directories('.')
+)
+
+pkg.generate(
+  libraries: libgitg,
+  version: gitg_version,
+  name: gitg_name,
+  description: gitg_name + ' library',
+  filebase: lib_api_name,
+  subdirs: lib_api_name,
+  requires: [
+    'gio-2.0',
+    'glib-2.0',
+    'gmodule-2.0',
+    'gobject-2.0',
+    'gthread-2.0',
+    'gtk+-3.0',
+    'libgit2-glib-1.0',
+    gio_system_pkg
+  ],
+  variables: 'exec_prefix=' + gitg_prefix,
+  install_dir: join_paths(gitg_libdir, 'pkgconfig')
+)
+
+libgitg_dir = meson.current_build_dir()
+
+custom_target(
+  gir_typelib,
+  output: gir_typelib,
+  command: [g_ir_compiler, '--shared-library', libgitg.full_path(), '--output', '@OUTPUT@', 
join_paths(libgitg_dir, gir_name)],
+  depends: libgitg,
+  install: true,
+  install_dir: gitg_girepositorydir
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..c58968c
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,270 @@
+project(
+  'gitg', ['c', 'vala'],
+  version: '3.26.0',
+  license: 'GPL2',
+  default_options: [
+    'b_lundef=true',
+    'buildtype=debugoptimized',
+    'warning_level=1'
+  ],
+  meson_version: '>= 0.43.0'
+)
+
+gitg_name = meson.project_name()
+
+gitg_version = meson.project_version()
+version_array = gitg_version.split('.')
+gitg_major_version = version_array[0].to_int()
+gitg_minor_version = version_array[1].to_int()
+gitg_micro_version = version_array[2].to_int()
+
+gitg_api_version = '1.0'
+gitg_gir_version = '1.0'
+
+gitg_gettext = gitg_name
+
+gitg_prefix = get_option('prefix')
+gitg_bindir = join_paths(gitg_prefix, get_option('bindir'))
+gitg_datadir = join_paths(gitg_prefix, get_option('datadir'))
+gitg_includedir = join_paths(gitg_prefix, get_option('includedir'))
+gitg_libdir = join_paths(gitg_prefix, get_option('libdir'))
+gitg_localedir = join_paths(gitg_prefix, get_option('localedir'))
+gitg_mandir = join_paths(gitg_prefix, get_option('mandir'))
+
+gitg_pkgdatadir = join_paths(gitg_datadir, gitg_name)
+gitg_pkglibdir = join_paths(gitg_libdir, gitg_name)
+
+gitg_girepositorydir = join_paths(gitg_libdir, 'girepository-' + gitg_gir_version)
+
+soversion = 0
+current = 0
+revision = 0
+libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
+
+gitg_debug = get_option('buildtype').contains('debug')
+
+cc = meson.get_compiler('c')
+valac = meson.get_compiler('vala')
+
+config_h = configuration_data()
+
+# defines
+set_defines = [
+  # package
+  ['PACKAGE', gitg_name],
+  ['PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=' + gitg_name],
+  ['PACKAGE_NAME', gitg_name],
+  ['PACKAGE_STRING', '@0@ @1@'.format(gitg_name, gitg_version)],
+  ['PACKAGE_TARNAME', gitg_name],
+  ['PACKAGE_URL', 'https://wiki.gnome.org/Apps/Gitg'],
+  ['PACKAGE_VERSION', gitg_version],
+  ['VERSION', gitg_version],
+  # i18n
+  ['GETTEXT_PACKAGE', gitg_gettext],
+  # gitg
+  ['GITG_DATADIR', gitg_pkgdatadir],
+  ['GITG_LIBDIR', gitg_pkglibdir],
+  ['GITG_LOCALEDIR', gitg_localedir]
+]
+
+foreach define: set_defines
+  config_h.set_quoted(define[0], define[1])
+endforeach
+
+# version values
+config_h.set('GITG_MAJOR_VERSION', gitg_major_version)
+config_h.set('GITG_MINOR_VERSION', gitg_minor_version)
+config_h.set('GITG_MICRO_VERSION', gitg_micro_version)
+
+# debug options
+config_h.set('ENABLE_DEBUG', gitg_debug,
+             description: 'Define if debugging is enabled')
+
+# headers
+check_headers = [
+  ['HAVE_DLFCN_H', 'dlfcn.h'],
+  ['HAVE_INTTYPES_H', 'inttypes.h'],
+  ['HAVE_MEMORY_H', 'memory.h'],
+  ['HAVE_STDINT_H', 'stdint.h'],
+  ['HAVE_STDLIB_H', 'stdlib.h'],
+  ['HAVE_STRINGS_H', 'strings.h'],
+  ['HAVE_STRING_H', 'string.h'],
+  ['HAVE_SYS_STAT_H', 'sys/stat.h'],
+  ['HAVE_SYS_TYPES_H', 'sys/types.h'],
+  ['HAVE_UNISTD_H', 'unistd.h']
+]
+
+foreach header: check_headers
+  config_h.set(header[0], cc.has_header(header[1]))
+endforeach
+
+# functions
+check_functions = [
+  # i18n
+  ['HAVE_DCGETTEXT', 'dcgettext'],
+  ['HAVE_GETTEXT', 'gettext'],
+  ['HAVE_ICONV', 'iconv']
+]
+
+if host_machine.system().contains('darwin')
+  check_functions += [
+    ['HAVE_CFLOCALECOPYCURRENT', 'CFLocaleCopyCurrent'],
+    ['HAVE_CFPREFERENCESCOPYAPPVALUE', 'CFPreferencesCopyAppValue']
+  ]
+endif
+
+foreach func: check_functions
+  config_h.set(func[0], cc.has_function(func[1]))
+endforeach
+
+# c compiler flags
+common_flags = ['-DHAVE_CONFIG_H']
+warn_flags = []
+
+if get_option('enable-deprecations')
+  warn_flags += [
+    '-DG_DISABLE_DEPRECATED',
+    '-DGDK_DISABLE_DEPRECATED',
+    '-DGTK_DISABLE_DEPRECATED',
+    '-DGDK_PIXBUF_DISABLE_DEPRECATED',
+    '-DGNOME_DISABLE_DEPRECATED',
+    '-DGSEAL_ENABLE'
+  ]
+endif
+
+if gitg_debug
+  test_cflags = [
+    '-w',
+    '-Werror',
+    '-Werror=format=2',
+    '-Werror=implicit-function-declaration',
+    '-Werror=init-self',
+    '-Werror=missing-include-dirs',
+    '-Werror=missing-prototypes',
+    '-Werror=pointer-arith',
+    '-Werror=return-type',
+    '-Wmissing-declarations',
+    '-Wnested-externs',
+    '-Wstrict-prototypes',
+    '-Wuninitialized'
+  ]
+
+  warn_flags += cc.get_supported_arguments(test_cflags)
+endif
+
+add_project_arguments(common_flags, language: 'c')
+
+# vala compiler flags
+vapi_dir = join_paths(meson.source_root(), 'vapi')
+
+common_flags = '--vapidir=' + vapi_dir
+
+add_project_arguments(common_flags, language: 'vala')
+
+ldflag = '-Wl,--version-script'
+have_version_script = host_machine.system().contains('linux') and cc.has_argument(ldflag)
+
+symbol_map = join_paths(meson.source_root(), 'libgitg.map')
+
+glib_req_version = '>= 2.38'
+
+gee_dep = dependency('gee-0.8')
+gio_dep = dependency('gio-2.0', version: glib_req_version)
+glib_dep = dependency('glib-2.0', version: glib_req_version)
+gtk_dep = dependency('gtk+-3.0', version: '>= 3.20.0')
+gtksourceview_dep = dependency('gtksourceview-3.0', version: '>= 3.10')
+libgit2_glib_dep = dependency('libgit2-glib-1.0', version: ['>= 0.25.0', '< 0.27.0'])
+libpeas_dep = dependency('libpeas-1.0')
+libsoup_dep = dependency('libsoup-2.4')
+
+config_dep = valac.find_library('config', dirs: vapi_dir)
+gitg_platform_support_dep = valac.find_library('gitg-platform-support', dirs: vapi_dir)
+
+# ggit threads
+ggit_threads = '''
+  #include <libgit2-glib/ggit.h>
+  int
+  main(int argc, const char *argv[])
+  {
+    ggit_init ();
+    return ((ggit_get_features () & GGIT_FEATURE_THREADS) != 0) ? 0 : 1;
+  };
+'''
+
+res = cc.run(ggit_threads, dependencies: libgit2_glib_dep)
+assert(
+  res.compiled() and (res.returncode() == 0),
+  'please recompile a threadsafe version of libgit2 (-DTHREADSAFE:BOOL=ON)'
+)
+
+# gtk required version is set to 3.20, so this will be always true
+gtk_shortcuts_window = gtk_dep.version().version_compare('3.19')
+
+m_dep = cc.find_library('m', required: false)
+have_libm = m_dep.found() and cc.has_function('sinf', dependencies: m_dep)
+config_h.set('HAVE_LIBM', have_libm)
+
+gdk_dep = dependency('gdk-3.0')
+gdk_targets = gdk_dep.get_pkgconfig_variable('targets')
+
+if gdk_targets.contains('quartz')
+  platform_name = 'osx'
+elif gdk_targets.contains('x11')
+  platform_name = 'unix'
+elif gdk_targets.contains('win32')
+  platform_name = 'win32'
+else
+  error('Unknown Gdk targets: ' + gdk_targets)
+endif
+config_h.set_quoted('PLATFORM_NAME', platform_name)
+
+g_ir_compiler = find_program('g-ir-compiler')
+
+enable_docs = get_option('enable-docs')
+if enable_docs
+  docs_dir = join_paths(meson.source_root(), 'docs')
+  valadoc = find_program('valadoc')
+endif
+
+gnome = import('gnome')
+i18n = import('i18n')
+pkg = import('pkgconfig')
+
+po_dir = join_paths(meson.source_root(), 'po')
+
+intltool_merge = find_program('intltool-merge')
+intltool_cache = join_paths(po_dir, '.intltool-merge-cache')
+intltool_desktop_cmd = [intltool_merge, '-d', '-u', '-c', intltool_cache, po_dir, '@INPUT@', '@OUTPUT@']
+intltool_xml_cmd = [intltool_merge, '-x', '-u', '-c', intltool_cache, po_dir, '@INPUT@', '@OUTPUT@']
+
+top_inc = include_directories('.')
+
+subdir('po')
+subdir('contrib/xml')
+subdir('contrib/ide')
+subdir('libgitg')
+subdir('libgitg-ext')
+subdir('plugins')
+subdir('gitg')
+subdir('data')
+subdir('tests')
+
+configure_file(
+  output: 'config.h',
+  configuration: config_h
+)
+
+meson.add_install_script(
+  'meson_post_install.py',
+  gitg_datadir,
+  (enable_python ? 'enable-python' : ''),
+  gitg_libdir
+)
+
+output = '\nConfiguration:\n\n'
+output += '        Source code location:   ' + meson.source_root() + '\n'
+output += '        Compiler:               ' + cc.get_id() + '\n'
+output += '        Glade catalog:          ' + enable_glade_catalog.to_string() + '\n'
+output += '        Debug enabled:          ' + gitg_debug.to_string() + '\n'
+output += '        Python support:         ' + enable_python.to_string() + '\n'
+message(output)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..4c60a5a
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,4 @@
+option('enable-glade-catalog', type: 'boolean', value: true, description: 'Install a glade catalog file')
+option('enable-python', type: 'boolean', value: true, description: 'Build with python support')
+option('enable-deprecations', type: 'boolean', value: false, description: 'warn about deprecated usages')
+option('enable-docs', type: 'boolean', value: false, description: 'enable generating documentation')
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100644
index 0000000..64d4c79
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+
+import glob
+import os
+import re
+import subprocess
+import sys
+
+if not os.environ.get('DESTDIR'):
+  icondir = os.path.join(sys.argv[1], 'icons', 'hicolor')
+
+  name_pattern = re.compile('hicolor_(?:apps)_(?:\d+x\d+|scalable)_(.*)')
+  search_pattern = '/**/hicolor_*'
+
+  [os.rename(file, os.path.join(os.path.dirname(file), name_pattern.search(file).group(1)))
+   for file in glob.glob(icondir + search_pattern, recursive=True)]
+
+  print('Update icon cache...')
+  subprocess.call(['gtk-update-icon-cache', '-f', '-t', '-q', icondir])
+
+  icondir = os.path.join(sys.argv[1], 'gitg', 'icons', 'hicolor')
+  subprocess.call(['gtk-update-icon-cache', '-f', '-t', '-q', icondir])
+
+  schemadir = os.path.join(sys.argv[1], 'glib-2.0', 'schemas')
+  print('Compiling gsettings schemas...')
+  subprocess.call(['glib-compile-schemas', schemadir])
+
+  if sys.argv[2] == 'enable-python':
+    print('Byte-compiling python modules...')
+    subprocess.call(['python', '-m', 'compileall', '-f', '-q', sys.argv[3]])
+
+    print('Byte-compiling python modules (optimized versions) ...')
+    subprocess.call(['python', '-O', '-m', 'compileall', '-f', '-q', sys.argv[3]])
diff --git a/plugins/diff/meson.build b/plugins/diff/meson.build
new file mode 100644
index 0000000..efc0d5d
--- /dev/null
+++ b/plugins/diff/meson.build
@@ -0,0 +1,21 @@
+install_data(
+  'icons/diff-symbolic.svg',
+  install_dir: join_paths(gitg_pkgdatadir, 'icons', 'hicolor', 'scalable', 'actions')
+)
+
+install_data(
+  'diff.plugin',
+  install_dir: plugin_dir
+)
+
+sources = files('gitg-diff.vala')
+
+libdiff = shared_module(
+  'diff',
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: plugin_deps,
+  c_args: plugin_cflags,
+  install: true,
+  install_dir: plugin_dir
+)
diff --git a/plugins/files/meson.build b/plugins/files/meson.build
new file mode 100644
index 0000000..74e34cc
--- /dev/null
+++ b/plugins/files/meson.build
@@ -0,0 +1,28 @@
+install_data(
+  'files.plugin',
+  install_dir: plugin_dir
+)
+
+sources = files(
+  'gitg-files.vala',
+  'gitg-files-tree-store.vala'
+)
+
+resource_data = files('resources/view-files.ui')
+
+sources += gnome.compile_resources(
+  'gitg-files-resources',
+  'resources/resources.xml',
+  source_dir: 'resources',
+  dependencies: resource_data
+)
+
+libfiles = shared_module(
+  'files',
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: plugin_deps,
+  c_args: plugin_cflags,
+  install: true,
+  install_dir: plugin_dir
+)
diff --git a/plugins/meson.build b/plugins/meson.build
new file mode 100644
index 0000000..165006e
--- /dev/null
+++ b/plugins/meson.build
@@ -0,0 +1,20 @@
+plugin_cflags = warn_flags + [
+  '-DDATADIR="@0@"'.format(gitg_datadir),
+  '-DLIBDIR="@0@"'.format(gitg_libdir)
+]
+
+plugin_deps = [
+  config_dep,
+  gee_dep,
+  libgit2_glib_dep,
+  gtk_dep,
+  gtksourceview_dep,
+  libgitg_dep,
+  libgitg_ext_dep,
+  libpeas_dep
+]
+
+plugin_dir = join_paths(gitg_pkglibdir, 'plugins')
+
+subdir('diff')
+subdir('files')
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..0b7cf8d
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1 @@
+i18n.gettext(gitg_gettext, preset: 'glib')
diff --git a/tests/gitg/meson.build b/tests/gitg/meson.build
new file mode 100644
index 0000000..abc85ad
--- /dev/null
+++ b/tests/gitg/meson.build
@@ -0,0 +1,35 @@
+sources = gitg_sources + support_sources + files(
+  'application-mock.vala',
+  'main.vala',
+  'notifications-mock.vala',
+  'ref-action-interface-mock.vala',
+  'simple-notification-mock.vala',
+  'test-checkout-ref.vala',
+  'test-cherry-pick-commit.vala',
+  'test-merge-ref.vala'
+)
+
+deps = [
+  config_dep,
+  gee_dep,
+  gitg_assert_dep,
+  gtk_dep,
+  libgit2_glib_dep,
+  libgitg_dep,
+  libgitg_ext_dep
+]
+
+vala_flags = '--disable-warnings'
+
+test_unit = 'tests-gitg'
+
+exe = executable(
+  test_unit,
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: deps,
+  c_args: warn_flags,
+  vala_args: vala_flags
+)
+
+test(test_unit, exe)
diff --git a/tests/libgitg/meson.build b/tests/libgitg/meson.build
new file mode 100644
index 0000000..e489dce
--- /dev/null
+++ b/tests/libgitg/meson.build
@@ -0,0 +1,30 @@
+sources = support_sources + files(
+  'main.vala',
+  'test-commit.vala',
+  'test-date.vala',
+  'test-encoding.vala',
+  'test-stage.vala'
+)
+
+deps = [
+  gee_dep,
+  gitg_assert_dep,
+  gtk_dep,
+  libgit2_glib_dep,
+  libgitg_dep
+]
+
+vala_flags = '--disable-warnings'
+
+test_unit = 'tests-libgitg'
+
+exe = executable(
+  test_unit,
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: deps,
+  c_args: warn_flags,
+  vala_args: vala_flags
+)
+
+test(test_unit, exe)
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..a8b9335
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,26 @@
+subdir('support')
+subdir('libgitg')
+subdir('gitg')
+
+deps = [
+  gee_dep,
+  gtk_dep,
+  libgit2_glib_dep,
+  libgitg_dep
+]
+
+test_names = [
+  'diff-view',
+  'repository-list-box',
+  'progress-bin'
+]
+
+foreach test_name: test_names
+  executable(
+    'tests-' + test_name,
+    sources: test_name + '.vala',
+    include_directories: top_inc,
+    dependencies: deps,
+    c_args: warn_flags
+  )
+endforeach
diff --git a/tests/support/meson.build b/tests/support/meson.build
new file mode 100644
index 0000000..dd10bed
--- /dev/null
+++ b/tests/support/meson.build
@@ -0,0 +1,22 @@
+copygen = generator(
+  find_program('cp'),
+  arguments: ['@INPUT@', '@OUTPUT@'],
+  output: 'support-@PLAINNAME@'
+)
+
+sources = [
+  'main.vala',
+  'repository.vala',
+  'test.vala'
+]
+
+support_sources = []
+
+foreach source: sources
+  support_sources += copygen.process(source)
+endforeach
+
+gitg_assert_dep = declare_dependency(
+  include_directories: include_directories('.'),
+  dependencies: valac.find_library('gitg-assert', dirs: meson.current_source_dir())
+)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]