Commit dabb83a2 authored by Martin Blanchard's avatar Martin Blanchard Committed by Christian Hergert

Port to meson build system

The meson build system focuses on speed an ease of use,
which helps speeding up the software development.

https://bugzilla.gnome.org/show_bug.cgi?id=793916
https://gitlab.gnome.org/GNOME/libpeas/issues/26

Closes #26
parent dd795bd0
glade_catalog_xml = configuration_data()
glade_catalog_xml.set('GETTEXT_PACKAGE', package_string)
peas_glade_catalog = configure_file(
input: 'libpeas-gtk.xml.in',
output: 'libpeas-gtk.xml',
configuration: glade_catalog_xml,
install: true,
install_dir: catalogdir,
)
if xmllint_prg.found()
glade_catalog_dtd_path = join_paths(
gladeui_dep.get_pkgconfig_variable('catalogdir'),
'glade-catalog.dtd'
)
test(
'Validate Glade catalogue',
xmllint_prg,
args: [
'--dtdvalid',
glade_catalog_dtd_path,
peas_glade_catalog,
'--noout',
]
)
endif
icon_sizes = [
'16x16',
'22x22',
'32x32',
]
foreach size: icon_sizes
install_data(
join_paths(size, 'libpeas-plugin.png'),
install_dir: join_paths(
iconsdir,
'hicolor',
size,
'actions'
)
)
endforeach
install_data(
join_paths('scalable', 'libpeas-plugin.svg'),
install_dir: join_paths(
iconsdir,
'hicolor',
'scalable',
'actions'
)
)
if install_glade_catalog == true
subdir('glade')
endif
subdir('icons')
if build_gtk_doc == true
subdir('reference')
endif
glib_prefix = glib_dep.get_pkgconfig_variable('prefix')
glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html')
gtk_prefix = gtk_dep.get_pkgconfig_variable('prefix')
gtk_docpath = join_paths(gtk_prefix, 'share', 'gtk-doc', 'html')
libpeas_reference_ignored_h = [
'peas-debug.h',
'peas-dirs.h',
'peas-engine-priv.h',
'peas-i18n.h',
'peas-introspection.h',
'peas-marshal.h',
'peas-plugin-info-priv.h',
'peas-plugin-loader.h',
'peas-plugin-loader-c.h',
'peas-utils.h',
]
libpeas_reference_html_images = [
]
libpeas_reference_srcdirs = [
libpeas_srcdir,
]
if build_gtk_widgetry == true
libpeas_reference_ignored_h += [
'peas-gtk-disable-plugins-dialog.h',
'peas-gtk-plugin-manager-store.h',
]
libpeas_reference_html_images += [
join_paths('images', 'peas-gtk-plugin-manager.png'),
]
libpeas_reference_srcdirs += [
libpeas_gtk_srcdir,
]
endif
version_xml = configuration_data()
version_xml.set('PEAS_VERSION', version)
configure_file(
input: 'version.xml.in',
output: 'version.xml',
configuration: version_xml,
)
libpeas_reference_deps = [
libpeas_dep,
]
libpeas_reference_scan_args = [
'--rebuild-types',
'--deprecated-guards="PEAS_DISABLE_DEPRECATED"',
'--ignore-headers=' + ' '.join(libpeas_reference_ignored_h),
]
libpeas_reference_fixxref_args = [
'--extra-dir=@0@'.format(join_paths(glib_docpath, 'glib')),
'--extra-dir=@0@'.format(join_paths(glib_docpath, 'gobject')),
'--extra-dir=@0@'.format(join_paths(glib_docpath, 'gmodule')),
'--extra-dir=@0@'.format(join_paths(glib_docpath, 'gio')),
]
libpeas_reference_mkdb_args = [
'--sgml-mode',
'--output-format=xml',
]
if build_gtk_widgetry == true
libpeas_reference_deps += [
libpeas_gtk_dep,
]
libpeas_reference_fixxref_args += [
'--extra-dir=@0@'.format(join_paths(gtk_docpath, 'gtk')),
]
endif
gnome.gtkdoc(
package_name,
main_sgml: 'libpeas-docs.sgml',
gobject_typesfile: 'libpeas.types',
src_dir: libpeas_reference_srcdirs,
html_assets: libpeas_reference_html_images,
dependencies: libpeas_reference_deps,
scan_args: libpeas_reference_scan_args,
fixxref_args: libpeas_reference_fixxref_args,
mkdb_args: libpeas_reference_mkdb_args,
install: true,
install_dir: join_paths(
gtkdocdir,
'html',
package_name,
)
)
libpeas_gtk_srcdir = include_directories('.')
libpeas_gtk_public_h = files(
'peas-gtk-autocleanups.h',
'peas-gtk-configurable.h',
'peas-gtk-plugin-manager.h',
'peas-gtk-plugin-manager-view.h',
'peas-gtk.h',
)
libpeas_gtk_c = files(
'peas-gtk-configurable.c',
'peas-gtk-disable-plugins-dialog.c',
'peas-gtk-plugin-manager.c',
'peas-gtk-plugin-manager-store.c',
'peas-gtk-plugin-manager-view.c',
)
libpeas_gtk_deps = [
glib_dep,
gobject_dep,
introspection_dep,
gtk_dep,
libpeas_dep,
]
libpeas_gtk_c_args = [
'-DHAVE_CONFIG_H',
'-DG_LOG_DOMAIN="libpeas-gtk"',
]
libpeas_gtk_link_args = [
]
install_headers(
libpeas_gtk_public_h,
install_dir: join_paths(
pkgincludedir,
package_gtk_name,
)
)
libpeas_gtk_sha = library(
package_gtk_string.strip('lib'),
libpeas_gtk_c,
version: lib_version,
include_directories: rootdir,
dependencies: libpeas_gtk_deps,
c_args: libpeas_gtk_c_args,
link_args: libpeas_gtk_link_args,
install: true,
install_dir: libdir,
)
libpeas_gtk_dep_sources = []
if generate_gir == true
libpeas_gtk_gir_includes = [
'GObject-2.0',
'Gtk-3.0',
libpeas_gir.get(0)
]
libpeas_gtk_gir = gnome.generate_gir(
libpeas_gtk_sha,
sources: libpeas_gtk_c + libpeas_gtk_public_h,
nsversion: api_version,
namespace: 'PeasGtk',
symbol_prefix: 'peas_gtk',
identifier_prefix: 'PeasGtk',
header: 'libpeas-gtk/peas-gtk.h',
export_packages: [package_gtk_string],
includes: libpeas_gtk_gir_includes,
link_with: [libpeas_sha, libpeas_gtk_sha],
install: true,
install_dir_gir: girdir,
install_dir_typelib: typelibdir,
extra_args: [
'--warn-all',
],
)
libpeas_gtk_dep_sources += [
libpeas_gtk_gir,
]
endif
libpeas_gtk_dep = declare_dependency(
link_with: libpeas_gtk_sha,
dependencies: libpeas_gtk_deps,
include_directories: rootdir,
sources: libpeas_gtk_dep_sources,
)
libpeas_gtk_pc = pkg.generate(
libpeas_gtk_sha,
name: package_gtk_string,
description: 'GObject plugins library widgetery',
subdirs: package_gtk_string,
install_dir: pkgconfigdir,
)
libpeas_srcdir = include_directories('.')
libpeas_public_h = files(
'peas-activatable.h',
'peas-autocleanups.h',
'peas-engine.h',
'peas-extension.h',
'peas-extension-base.h',
'peas-extension-set.h',
'peas-object-module.h',
'peas-plugin-info.h',
'peas.h',
)
libpeas_sources = files(
'peas-activatable.c',
'peas-debug.c',
'peas-dirs.c',
'peas-engine.c',
'peas-extension.c',
'peas-extension-base.c',
'peas-extension-set.c',
'peas-i18n.c',
'peas-introspection.c',
'peas-object-module.c',
'peas-plugin-info.c',
'peas-plugin-loader.c',
'peas-plugin-loader-c.c',
'peas-utils.c',
)
libpeas_deps = [
glib_dep,
gobject_dep,
gmodule_dep,
gio_dep,
introspection_dep,
]
libpeas_c_args = [
'-DHAVE_CONFIG_H',
'-DG_LOG_DOMAIN="libpeas"',
'-DDATADIR="@0@"'.format(datadir),
'-DLIBDIR="@0@"'.format(libdir),
]
libpeas_link_args = [
]
libpeas_marshal = gnome.genmarshal(
'peas-marshal',
sources: 'peas-marshal.list',
prefix: 'peas_cclosure_marshal',
install_header: false,
)
libpeas_marshals_h = libpeas_marshal.get(1)
libpeas_sources += [
libpeas_marshal,
]
install_headers(
libpeas_public_h,
install_dir: join_paths(
pkgincludedir,
package_name,
),
)
libpeas_sha = library(
package_string.strip('lib'),
libpeas_sources,
version: lib_version,
include_directories: rootdir,
dependencies: libpeas_deps,
c_args: libpeas_c_args,
link_args: libpeas_link_args,
install: true,
install_dir: libdir,
)
libpeas_dep_sources = [
libpeas_marshals_h,
]
if generate_gir == true
libpeas_gir_includes = [
'GObject-2.0',
'GModule-2.0',
'Gio-2.0',
'GIRepository-2.0'
]
libpeas_gir = gnome.generate_gir(
libpeas_sha,
sources: libpeas_sources + libpeas_public_h,
nsversion: api_version,
namespace: 'Peas',
symbol_prefix: 'peas',
identifier_prefix: 'Peas',
header: 'libpeas/peas.h',
export_packages: [package_string],
includes: libpeas_gir_includes,
link_with: libpeas_sha,
install: true,
install_dir_gir: girdir,
install_dir_typelib: typelibdir,
extra_args: [
'--warn-all',
],
)
libpeas_dep_sources += [
libpeas_gir,
]
endif
libpeas_dep = declare_dependency(
link_with: libpeas_sha,
include_directories: rootdir,
dependencies: libpeas_deps,
sources: libpeas_dep_sources,
)
libpeas_pc = pkg.generate(
libpeas_sha,
name: package_string,
description: 'GObject plugins library',
subdirs: package_string,
install_dir: pkgconfigdir,
)
lua51_loader_name = 'lua51loader'
lua51_lgi_version = lua51_lgi_dep.version()
lua51_lgi_version_arr = lua51_lgi_version.split('.')
lua51_lgi_version_major = lua51_lgi_version_arr[0].to_int()
lua51_lgi_version_minor = lua51_lgi_version_arr[1].to_int()
lua51_lgi_version_micro = lua51_lgi_version_arr[2].to_int()
lua51_loader_c = files(
'peas-lua-internal.c',
'peas-lua-utils.c',
'peas-plugin-loader-lua.c',
)
subdir('resources') # Declares 'lua51_loader_res'
lua51_loader_deps = [
libpeas_dep,
lua51_dep,
lua51_lgi_dep,
]
lua51_loader_c_args = [
'-DHAVE_CONFIG_H',
'-DLGI_MAJOR_VERSION=@0@'.format(lua51_lgi_version_major),
'-DLGI_MINOR_VERSION=@0@'.format(lua51_lgi_version_minor),
'-DLGI_MICRO_VERSION=@0@'.format(lua51_lgi_version_micro),
]
lua51_loader_sha = shared_library(
lua51_loader_name,
lua51_loader_c + lua51_loader_res,
include_directories: rootdir,
dependencies: lua51_loader_deps,
c_args: lua51_loader_c_args,
install: true,
install_dir: join_paths(
pkglibdir,
'loaders',
)
)
lua51_loader_res = gnome.compile_resources(
'peas-lua-resources',
'peas-lua.gresource.xml',
export: true,
)
if build_lua51_loader == true
subdir('lua5.1')
endif
if build_python3_loader == true
subdir('python')
endif
if build_python3_loader == true
subdir('python3')
endif
python2_loader_name = 'python2loader'
pygobject_version = pygobject_dep.version()
pygobject_version_arr = pygobject_version.split('.')
pygobject_version_major = pygobject_version_arr[0].to_int()
pygobject_version_minor = pygobject_version_arr[1].to_int()
pygobject_version_micro = pygobject_version_arr[2].to_int()
python2_loader_c = files(
'peas-plugin-loader-python.c',
'peas-python-internal.c',
)
python2_loader_res = gnome.compile_resources(
'peas-python-resources',
'peas-python.gresource.xml',
export: true,
)
python2_loader_deps = [
libpeas_dep,
python2_dep,
pygobject_dep,
]
python2_loader_c_args = [
'-DHAVE_CONFIG_H',
'-DPEAS_LOCALEDIR="@0@"'.format(localedir),
'-DPYGOBJECT_MAJOR_VERSION=@0@'.format(pygobject_version_major),
'-DPYGOBJECT_MINOR_VERSION=@0@'.format(pygobject_version_minor),
'-DPYGOBJECT_MICRO_VERSION=@0@'.format(pygobject_version_micro),
]
python2_loader_sha = shared_library(
python2_loader_name,
python2_loader_c + python2_loader_res,
include_directories: rootdir,
dependencies: python2_loader_deps,
c_args: python2_loader_c_args,
install: true,
install_dir: join_paths(
pkglibdir,
'loaders',
)
)
python3_loader_name = 'python3loader'
pygobject_version = pygobject_dep.version()
pygobject_version_arr = pygobject_version.split('.')
pygobject_version_major = pygobject_version_arr[0].to_int()
pygobject_version_minor = pygobject_version_arr[1].to_int()
pygobject_version_micro = pygobject_version_arr[2].to_int()
python3_loader_c = files(
'../python/peas-plugin-loader-python.c',
'../python/peas-python-internal.c',
)
python3_loader_res = gnome.compile_resources(
'peas-python2-resources',
'peas-python3.gresource.xml',
export: true,
)
python3_loader_deps = [
libpeas_dep,
python3_dep,
pygobject_dep,
]
python3_loader_c_args = [
'-DHAVE_CONFIG_H',
'-DPEAS_LOCALEDIR="@0@"'.format(localedir),
'-DPYGOBJECT_MAJOR_VERSION=@0@'.format(pygobject_version_major),
'-DPYGOBJECT_MINOR_VERSION=@0@'.format(pygobject_version_minor),
'-DPYGOBJECT_MICRO_VERSION=@0@'.format(pygobject_version_micro),
]
python3_loader_sha = shared_library(
python3_loader_name,
python3_loader_c + python3_loader_res,
include_directories: rootdir,
dependencies: python3_loader_deps,
c_args: python3_loader_c_args,
install: true,
install_dir: join_paths(
pkglibdir,
'loaders',
)
)
project(
'libpeas', 'c',
version: '1.22.0',
license: 'LGPLv2.1+',
meson_version: '>= 0.49.0',
default_options: [
'buildtype=debugoptimized',
]
)
gnome = import('gnome')
i18n = import('i18n')
pkg = import('pkgconfig')
# Versioning
version = meson.project_version()
version_arr = version.split('.')
version_major = version_arr[0].to_int()
version_minor = version_arr[1].to_int()
version_micro = version_arr[2].to_int()
api_version = '@0@.0'.format(version_major)
if version_minor.is_odd()
interface_age = 0
else
interface_age = version_micro
endif
# Compatibility with libtool versioning:
# current = minor * 100 + micro - interface
# revision = interface
lib_version_soversion = version_major
lib_version_current = version_minor * 100 + version_micro - interface_age
lib_version_revision = interface_age
lib_version = '@0@.@1@.@2@'.format(
lib_version_soversion,
lib_version_current,
lib_version_revision
)
package_name = meson.project_name()
package_string = '@0@-@1@'.format(package_name, api_version)
package_long_string = '@0@-@1@'.format(package_name, version)
package_gtk_name = '@0@-gtk'.format(meson.project_name())
package_gtk_string = '@0@-@1@'.format(package_gtk_name, api_version)
# Paths
rootdir = include_directories('.')
srcdir = meson.current_source_dir()
builddir = meson.current_build_dir()
prefix = get_option('prefix')
includedir = join_paths(prefix, get_option('includedir'))
libdir = join_paths(prefix, get_option('libdir'))
datadir = join_paths(prefix, get_option('datadir'))
localedir = join_paths(prefix, get_option('localedir'))
pkgincludedir = join_paths(includedir, package_string)
pkglibdir = join_paths(libdir, package_string)
pkgdatadir = join_paths(datadir, package_string)
girdir = join_paths(datadir, 'gir-1.0')
gtkdocdir = join_paths(datadir, 'gtk-doc')
iconsdir = join_paths(datadir, 'icons')
pkgconfigdir = join_paths(libdir, 'pkgconfig')
typelibdir = join_paths(libdir, 'girepository-1.0')
# Configurations
config_h = configuration_data()
config_h.set_quoted('PACKAGE', package_name)
config_h.set_quoted('PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=libpeas')
config_h.set_quoted('PACKAGE_NAME', package_name)
config_h.set_quoted('PACKAGE_STRING', package_long_string)
config_h.set_quoted('PACKAGE_URL', 'https://wiki.gnome.org/Projects/Libpeas')
config_h.set_quoted('PACKAGE_URL', 'https://wiki.gnome.org/Projects/Libpeas')
config_h.set_quoted('PACKAGE_VERSION', version)
config_h.set_quoted('VERSION', version)
config_h.set_quoted('GETTEXT_PACKAGE', package_string)
# Dependencies
cc = meson.get_compiler('c')
glib_req = '>= 2.38.0'
introspection_req = '>= 1.39.0'
gtk_req = '>= 3.0.0'
gtk_doc_req = '>= 1.11'
python2_req = '>= 2.5.2'
python3_req = '>= 3.2.0'
pygobject_req = '>= 3.2.0'
lua_req = '>= 5.1.0'
lua_lgi_req = '>= 0.9.0'
luajit_req = '>= 2.0'
glib_dep = dependency('glib-2.0', version: glib_req)
gobject_dep = dependency('gobject-2.0', version: glib_req)
gmodule_dep = dependency('gmodule-2.0', version: glib_req)
gio_dep = dependency('gio-2.0', version: glib_req)
introspection_dep = dependency('gobject-introspection-1.0', version: introspection_req)
gtk_dep = dependency('gtk+-3.0', version: gtk_req, required: false)
gtk_doc_dep = dependency('gtk-doc', version: gtk_doc_req, required: false)
gladeui_dep = dependency('gladeui-2.0', required: false)
python2_dep = dependency('python2', version: python2_req, required: false)
python3_dep = dependency('python3', version: python3_req, required: false)
pygobject_dep = dependency('pygobject-3.0', version: pygobject_req, required: false)
lua51_dep = dependency('lua5.1', version: lua_req, required: false)
lua51_lgi_dep = dependency('lua5.1-lgi', version: lua_lgi_req, required: false)
luajit_dep = dependency('luajit', version: luajit_req, required: false)
luajit_prg = find_program('luajit', required: false)
xmllint_prg = find_program('xmllint', required: false)
if build_machine.system() == 'darwin'
config_h.set_quoted('OS_OSX', 1)
endif
configure_file(
output: 'config.h',
configuration: config_h
)
# Options
build_gtk_doc = get_option('gtk_doc')
if build_gtk_doc and not gtk_doc_dep.found()
build_gtk_doc = false
endif
install_glade_catalog = get_option('glade_catalog')
if install_glade_catalog and not gladeui_dep.found()
install_glade_catalog = false
elif install_glade_catalog == true
catalogdir = join_paths(datadir, 'glade', 'catalogs')
# FIXME: In gladeui-2.0.pc, catalogdir should be relative to datadir:
# https://gitlab.gnome.org/GNOME/glade/issues/353
# catalogdir = gladeui_dep.get_pkgconfig_variable(
# 'catalogdir',
# define_variable: [
# 'datadir', datadir,
# ]
# )
endif
build_gtk_widgetry = get_option('widgetry')
if build_gtk_widgetry and not gtk_dep.found()
build_gtk_widgetry = false
endif
build_demos = get_option('widgetry')
if build_demos and not build_gtk_widgetry
build_demos = false
endif
generate_gir = get_option('introspection')
if generate_gir and not introspection_dep.found()
generate_gir = false
endif
build_lua51_loader = get_option('lua51')
lua51_found = lua51_dep.found() and lua51_lgi_dep.found()
if build_lua51_loader and not lua51_found
build_lua51_loader = false
endif
build_python2_loader = get_option('python2')
python2_found = python2_dep.found() and pygobject_dep.found()
if build_python2_loader and not python2_found
build_python2_loader = false
endif
build_python3_loader = get_option('python2')
python3_found = python3_dep.found() and pygobject_dep.found()
if build_python3_loader and not python3_found
build_python3_loader = false
endif
subdir('libpeas')
if build_gtk_widgetry == true
subdir('libpeas-gtk')
endif
subdir('docs')
subdir('data')
subdir('po')
subdir('loaders')
if build_demos == true
subdir('peas-demo')
endif
subdir('tests')
summary = [
'',
'------',
'libpeas @0@ (@1@)'.format(version, api_version),
'',
' Demos: @0@'.format(build_demos),
' Documentation: @0@'.format(build_gtk_doc),
' Glade catalog: @0@'.format(install_glade_catalog),
' GTK+ widgetry: @0@'.format(build_gtk_widgetry),
' Introspection: @0@'.format(generate_gir),
' Lua 5.1 support: @0@'.format(build_lua51_loader),
' Python 2 support: @0@'.format(build_python2_loader),
' Python 3 support: @0@'.format(build_python3_loader),
'',
'Directories:',
' prefix: @0@'.format(prefix),
' includedir: @0@'.format(includedir),
' libdir: @0@'.format(libdir),
' datadir: @0@'.format(datadir),
'------',
]
message('\n'.join(summary))
option('lua51',
type: 'boolean', value: true,
description: 'Enable Lua 5.1 support (requires lua-lgi)')