[atk/wip/meson: 2/2] Add Meson build system
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [atk/wip/meson: 2/2] Add Meson build system
- Date: Sat, 20 May 2017 16:14:38 +0000 (UTC)
commit 0c544a82d30173416917236867539aa9dfadcc6c
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sat May 20 15:36:44 2017 +0100
Add Meson build system
Meson is a meta-build system that has several advantages over Autotools:
- faster
- simpler to use and understand
- portable to various platforms
- tailored to the needs of GNOME libraries
- well maintained and supported
Various other libraries in the GNOME stack have already adopted Meson in
parallel, or exclusively, including GTK+.
atk/meson.build | 139 ++++++++++++++++++++++++++++++++++++++++
docs/meson.build | 49 ++++++++++++++
docs/xml/gtkdocentities.ent.in | 8 ++
docs/xml/meson.build | 10 +++
meson.build | 129 +++++++++++++++++++++++++++++++++++++
meson_options.txt | 4 +
po/meson.build | 3 +
tests/meson.build | 20 ++++++
8 files changed, 362 insertions(+), 0 deletions(-)
---
diff --git a/atk/meson.build b/atk/meson.build
new file mode 100644
index 0000000..8183f10
--- /dev/null
+++ b/atk/meson.build
@@ -0,0 +1,139 @@
+atk_sources = [
+ 'atkaction.c',
+ 'atkcomponent.c',
+ 'atkdocument.c',
+ 'atkeditabletext.c',
+ 'atkgobjectaccessible.c',
+ 'atkhyperlink.c',
+ 'atkhyperlinkimpl.c',
+ 'atkhypertext.c',
+ 'atkimage.c',
+ 'atknoopobject.c',
+ 'atknoopobjectfactory.c',
+ 'atkobject.c',
+ 'atkobjectfactory.c',
+ 'atkplug.c',
+ 'atkprivate.c',
+ 'atkrange.c',
+ 'atkregistry.c',
+ 'atkrelation.c',
+ 'atkrelationset.c',
+ 'atkselection.c',
+ 'atksocket.c',
+ 'atkstate.c',
+ 'atkstateset.c',
+ 'atkstreamablecontent.c',
+ 'atktable.c',
+ 'atktablecell.c',
+ 'atktext.c',
+ 'atkutil.c',
+ 'atkmisc.c',
+ 'atkvalue.c',
+ 'atkversion.c',
+ 'atkwindow.c',
+]
+
+atk_headers = [
+ 'atkaction.h',
+ 'atkcomponent.h',
+ 'atkdocument.h',
+ 'atkeditabletext.h',
+ 'atkgobjectaccessible.h',
+ 'atkhyperlink.h',
+ 'atkhyperlinkimpl.h',
+ 'atkhypertext.h',
+ 'atknoopobject.h',
+ 'atknoopobjectfactory.h',
+ 'atkobject.h',
+ 'atkobjectfactory.h',
+ 'atkplug.h',
+ 'atkimage.h',
+ 'atkrange.h',
+ 'atkregistry.h',
+ 'atkrelation.h',
+ 'atkrelationtype.h',
+ 'atkrelationset.h',
+ 'atkselection.h',
+ 'atksocket.h',
+ 'atkstate.h',
+ 'atkstateset.h',
+ 'atkstreamablecontent.h',
+ 'atktable.h',
+ 'atktablecell.h',
+ 'atktext.h',
+ 'atkutil.h',
+ 'atkmisc.h',
+ 'atkvalue.h',
+ 'atkwindow.h',
+]
+
+install_headers(atk_headers, subdir: atk_api_path)
+
+# Features header
+atk_version_conf = configuration_data()
+atk_version_conf.set('ATK_MAJOR_VERSION', atk_major_version)
+atk_version_conf.set('ATK_MINOR_VERSION', atk_minor_version)
+atk_version_conf.set('ATK_MICRO_VERSION', atk_micro_version)
+atk_version_conf.set('ATK_BINARY_AGE', atk_binary_age)
+atk_version_conf.set('ATK_INTERFACE_AGE', atk_interface_age)
+
+configure_file(input: 'atkversion.h.in',
+ output: 'atkversion.h',
+ configuration: atk_version_conf,
+ install: true,
+ install_dir: join_paths(atk_includedir, atk_api_path))
+
+# Marshallers
+atk_marshals = gnome.genmarshal('atkmarshal',
+ sources: 'atkmarshal.list',
+ prefix: 'atk_marshal')
+atk_marshal_h = atk_marshals[1]
+
+# Enumerations for GType
+atk_enums = gnome.mkenums('atk-enum-types',
+ sources: atk_headers,
+ c_template: 'atk-enum-types.c.template',
+ h_template: 'atk-enum-types.h.template',
+ install_dir: join_paths(atk_includedir, atk_api_path),
+ install_header: true)
+atk_enum_h = atk_enums[1]
+
+atk_cflags = [
+ '-DG_LOG_DOMAIN="Atk"',
+ '-DG_LOG_USE_STRUCTURED=1',
+ '-DATK_DISABLE_DEPRECATED',
+ '-DATK_COMPILATION',
+ '-DATK_LOCALEDIR="@0@"'.format(join_paths(atk_datadir, 'locale')),
+]
+
+atk_inc = include_directories('.')
+
+libatk = shared_library('atk-@0@'.format(atk_api_version),
+ sources: atk_sources + atk_enums + atk_marshals,
+ soversion: atk_soversion,
+ install: true,
+ dependencies: gobject_dep,
+ include_directories: [ root_inc, atk_inc ],
+ c_args: common_cflags + atk_cflags,
+ link_args: common_ldflags)
+
+libatk_dep = declare_dependency(link_with: libatk,
+ include_directories: atk_inc,
+ dependencies: gobject_dep,
+ sources: atk_enums)
+
+if not meson.is_cross_build()
+ gnome.generate_gir(libatk,
+ sources: atk_sources + atk_headers + [ atk_enum_h ],
+ namespace: 'Atk',
+ nsversion: atk_api_version,
+ identifier_prefix: 'Atk',
+ symbol_prefix: 'atk',
+ export_packages: 'atk',
+ includes: [ 'GObject-2.0' ],
+ install: true,
+ extra_args: [
+ '--quiet',
+ '--c-include=atk/atk.h',
+ ])
+endif
diff --git a/docs/meson.build b/docs/meson.build
new file mode 100644
index 0000000..d2dac1c
--- /dev/null
+++ b/docs/meson.build
@@ -0,0 +1,49 @@
+subdir('xml')
+
+version_xml_conf = configuration_data()
+version_xml_conf.set('ATK_VERSION', meson.project_version())
+configure_file(input: 'version.xml.in',
+ output: 'version.xml',
+ configuration: version_xml_conf)
+
+private_headers = [
+ 'atkmarshal.h',
+ 'atkintl.h',
+]
+
+content_files = [
+ 'version.xml',
+]
+
+html_images = [
+]
+
+glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix')
+glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html')
+docpath = join_paths(atk_datadir, 'gtk-doc', 'html')
+
+gnome.gtkdoc('atk',
+ main_xml: 'atk-docs.sgml',
+ src_dir: [
+ join_paths(meson.source_root(), 'atk'),
+ join_paths(meson.build_root(), 'atk'),
+ ],
+ dependencies: libatk_dep,
+ gobject_typesfile: 'atk.types',
+ scan_args: [
+ '--rebuild-types',
+ '--deprecated-guards=ATK_DISABLE_DEPRECATED',
+ '--ignore-decorators=_ATK_EXTERN',
+ '--ignore-headers=' + ' '.join(private_headers),
+ ],
+ mkdb_args: [
+ '--sgml-mode',
+ '--output-format=xml',
+ ],
+ fixxref_args: [
+ '--html-dir=@0@'.format(docpath),
+ '--extra-dir=@0@'.format(join_paths(glib_docpath, 'glib')),
+ '--extra-dir=@0@'.format(join_paths(glib_docpath, 'gobject')),
+ ],
+ html_assets: html_images,
+ install: true)
diff --git a/docs/xml/gtkdocentities.ent.in b/docs/xml/gtkdocentities.ent.in
new file mode 100644
index 0000000..f12c9ff
--- /dev/null
+++ b/docs/xml/gtkdocentities.ent.in
@@ -0,0 +1,8 @@
+<!ENTITY package "@PACKAGE@">
+<!ENTITY package_bugreport "@PACKAGE_BUGREPORT@">
+<!ENTITY package_name "@PACKAGE_NAME@">
+<!ENTITY package_string "@PACKAGE_STRING@">
+<!ENTITY package_tarname "@PACKAGE_TARNAME@">
+<!ENTITY package_url "@PACKAGE_URL@">
+<!ENTITY package_version "@PACKAGE_VERSION@">
+<!ENTITY package_api_version "@PACKAGE_API_VERSION@">
diff --git a/docs/xml/meson.build b/docs/xml/meson.build
new file mode 100644
index 0000000..91280ef
--- /dev/null
+++ b/docs/xml/meson.build
@@ -0,0 +1,10 @@
+ent_conf = configuration_data()
+ent_conf.set('PACKAGE', meson.project_name())
+ent_conf.set('PACKAGE_BUGREPORT', 'https://bugzilla.gnome.org/enter_bug.cgi?product=atk')
+ent_conf.set('PACKAGE_NAME', meson.project_name())
+ent_conf.set('PACKAGE_STRING', meson.project_name())
+ent_conf.set('PACKAGE_TARNAME', '@0@-@1@'.format(meson.project_name(), meson.project_version()))
+ent_conf.set('PACKAGE_URL', 'https://developer.gnome.org/atk/stable')
+ent_conf.set('PACKAGE_VERSION', meson.project_version())
+ent_conf.set('PACKAGE_API_VERSION', atk_api_version)
+configure_file(input: 'gtkdocentities.ent.in', output: 'gtkdocentities.ent', configuration: ent_conf)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..ecf6ca3
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,129 @@
+project('atk', 'c',
+ version: '2.24.1',
+ license: 'LGPLv2.1+',
+ default_options: [
+ 'buildtype=debugoptimized',
+ 'warning_level=1',
+ 'c_std=c99',
+ ],
+ meson_version : '>= 0.40.1')
+
+cc = meson.get_compiler('c')
+host_system = host_machine.system()
+
+version = meson.project_version().split('.')
+atk_major_version = version[0].to_int()
+atk_minor_version = version[1].to_int()
+atk_micro_version = version[2].to_int()
+
+atk_interface_age = atk_minor_version.is_odd() ? 0 : atk_micro_version
+atk_binary_age = 10000 * atk_major_version + 100 * atk_minor_version + 10 * atk_micro_version
+
+atk_api_version = '@0@.0'.format(atk_major_version)
+atk_api_path = 'atk-@0@/atk'.format(atk_api_version)
+
+atk_prefix = get_option('prefix')
+atk_libdir = join_paths(atk_prefix, get_option('libdir'))
+atk_sysconfdir = join_paths(atk_prefix, get_option('sysconfdir'))
+atk_includedir = join_paths(atk_prefix, get_option('includedir'))
+atk_datadir = join_paths(atk_prefix, get_option('datadir'))
+atk_libexecdir = join_paths(atk_prefix, get_option('libexecdir'))
+
+atk_conf = configuration_data()
+
+atk_conf.set_quoted('VERSION', meson.project_version())
+atk_conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
+
+# Maintain version scheme with libtool
+atk_soversion = '0.@0@.@1@'.format((atk_binary_age - atk_interface_age), atk_interface_age)
+
+# Compiler and linker flags
+common_cflags = []
+common_ldflags = []
+
+test_cflags = []
+
+# Symbol visibility
+if get_option('default_library') != 'static'
+ if host_system == 'windows'
+ atk_conf.set('DLL_EXPORT', true)
+ atk_conf.set('_ATK_EXTERN', '__declspec(dllexport) extern')
+ if cc.get_id() != 'msvc'
+ test_cflags += ['-fvisibility=hidden']
+ endif
+ else
+ atk_conf.set('_ATK_EXTERN', '__attribute__((visibility("default"))) extern')
+ test_cflags += ['-fvisibility=hidden']
+ endif
+endif
+
+# Check all compiler flags
+foreach cflag: test_cflags
+ if cc.has_argument(cflag)
+ common_cflags += [ cflag ]
+ endif
+endforeach
+
+# Linker flags
+if host_machine.system() == 'linux'
+ foreach ldflag: [ '-Wl,-Bsymbolic', '-Wl,-z,relro', '-Wl,-z,now', ]
+ if cc.has_argument(ldflag)
+ common_ldflags += [ ldflag ]
+ endif
+ endforeach
+endif
+
+# Maintain compatibility with autotools on macOS
+if host_machine.system() == 'darwin'
+ common_ldflags += [ '-compatibility_version=1', '-current_version=1.0', ]
+endif
+
+# Functions
+checked_funcs = [
+ 'bind_textdomain_codeset',
+]
+
+foreach f: checked_funcs
+ if cc.has_function(f)
+ atk_conf.set('HAVE_' + f.underscorify().to_upper(), 1)
+ endif
+endforeach
+
+# Dependencies
+gobject_req_version = '>= 2.31.2'
+
+gobject_dep = dependency('gobject-2.0', version: gobject_req_version)
+
+# Compat variables for pkgconfig
+pkgconf = configuration_data()
+pkgconf.set('prefix', atk_prefix)
+pkgconf.set('exec_prefix', atk_prefix)
+pkgconf.set('libdir', atk_libdir)
+pkgconf.set('includedir', atk_includedir)
+pkgconf.set('VERSION', meson.project_version())
+pkgconf.set('GLIB_PACKAGES', 'gobject-2.0')
+pkgconf.set('ATK_API_VERSION', atk_api_version)
+pkgconf.set('srcdir', '.')
+
+foreach pkg: [ 'atk.pc', 'atk-uninstalled.pc', ]
+ configure_file(input: pkg + '.in',
+ output: pkg,
+ configuration: pkgconf,
+ install: true,
+ install_dir: join_paths(atk_libdir, 'pkgconfig'))
+endforeach
+
+gnome = import('gnome')
+
+# Internal configuration header
+configure_file(output: 'config.h', configuration: atk_conf)
+
+root_inc = include_directories('.')
+
+subdir('atk')
+subdir('tests')
+subdir('po')
+
+if get_option('enable_docs')
+ subdir('docs')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..6c306f3
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,4 @@
+option('enable_docs',
+ description: 'Build API reference for ATK using GTK-Doc',
+ type: 'boolean',
+ value: false)
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..2522e9c
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,3 @@
+i18n = import('i18n')
+
+i18n.gettext('atk', preset: 'glib')
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..1fbb992
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,20 @@
+tests = [
+ 'testdocument',
+ 'testrole',
+ 'testrelation',
+ 'teststateset',
+ 'testvalue',
+]
+
+foreach t: tests
+ bin = executable(t, t + '.c',
+ dependencies: libatk_dep,
+ include_directories: root_inc,
+ c_args: common_cflags + [
+ '-DG_DISABLE_DEPRECATED',
+ ])
+ test(t, bin, env: [
+ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
+ 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+ ])
+endforeach
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]