Commit c876e0e2 authored by Iñigo Martínez's avatar Iñigo Martínez

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
parent d5a822dd
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())
)
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
)
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')
)
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
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
)
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
{
global:
*;
local:
_.*;
};
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
)
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',