[devhelp/wip/meson] build: Port to meson build system



commit 1880ee1227b8e68c806c278e7ebb369f77ac98c2
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Thu Jun 15 13:06:37 2017 +0200

    build: Port to meson build system

 data/dtd/meson.build                     |    4 +
 data/icons/meson.build                   |   20 +++
 data/meson.build                         |   72 +++++++++++
 data/org.gnome.Devhelp.service.in        |    3 +
 docs/meson.build                         |    1 +
 docs/reference/meson.build               |   40 ++++++
 docs/reference/xml/gtkdocentities.ent.in |    7 +
 docs/reference/xml/meson.build           |   17 +++
 meson.build                              |  188 +++++++++++++++++++++++++++++
 meson_options.txt                        |    2 +
 meson_post_install.py                    |   19 +++
 misc/gedit-plugin/meson.build            |   18 +++
 misc/meson.build                         |    1 +
 po/meson.build                           |    1 +
 src/devhelp.map                          |    6 +
 src/meson.build                          |  193 ++++++++++++++++++++++++++++++
 16 files changed, 592 insertions(+), 0 deletions(-)
---
diff --git a/data/dtd/meson.build b/data/dtd/meson.build
new file mode 100644
index 0000000..e27d198
--- /dev/null
+++ b/data/dtd/meson.build
@@ -0,0 +1,4 @@
+install_data(
+  'devhelp-1.dtd',
+  install_dir: join_paths(devhelp_pkgdatadir, 'dtd')
+)
diff --git a/data/icons/meson.build b/data/icons/meson.build
new file mode 100644
index 0000000..fe77412
--- /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(
+    icon_size + '/devhelp.png',
+    install_dir: join_paths(devhelp_datadir, 'icons', 'hicolor', icon_size, 'apps')
+  )
+endforeach
+
+install_data(
+  'symbolic/devhelp-symbolic.svg',
+  install_dir: join_paths(devhelp_datadir, 'icons', 'hicolor', 'symbolic', 'apps')
+)
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..03fb6d9
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,72 @@
+info_name = 'org.gnome.Devhelp.metainfo.xml'
+
+i18n.merge_file(
+  info_name,
+  input: 'org.gnome.Devhelp.appdata.xml.in',
+  output: info_name,
+  po_dir: po_dir,
+  install: true,
+  install_dir: join_paths(devhelp_datadir, 'metainfo')
+)
+
+desktop = 'org.gnome.Devhelp.desktop'
+
+desktop_conf = configuration_data()
+desktop_conf.set('VERSION', devhelp_version)
+
+desktop_in = configure_file(
+  input: desktop + '.in.in',
+  output: desktop + '.in',
+  configuration: desktop_conf
+)
+
+i18n.merge_file(
+  desktop,
+  type: 'desktop',
+  input: desktop_in,
+  output: desktop,
+  po_dir: po_dir,
+  install: true,
+  install_dir: join_paths(devhelp_datadir, 'applications')
+)
+
+service_conf = configuration_data()
+service_conf.set('bindir', devhelp_bindir)
+
+service = 'org.gnome.Devhelp.service'
+
+configure_file(
+  input: service + '.in',
+  output: service,
+  install: true,
+  install_dir: join_paths(devhelp_datadir, 'dbus-1', 'services'),
+  configuration: service_conf
+)
+
+assistant_files = files(
+  'assistant.js',
+  'assistant.css'
+)
+
+install_data(
+  assistant_files,
+  install_dir: join_paths(devhelp_pkgdatadir, 'assistant')
+)
+
+install_data(
+  'org.gnome.devhelp.gschema.xml',
+  install_dir: join_paths(devhelp_datadir, 'glib-2.0', 'schemas')
+)
+
+install_data(
+  'devhelp.convert',
+  install_dir: join_paths(devhelp_datadir, 'GConf', 'gsettings')
+)
+
+install_data(
+  'devhelp.1',
+  install_dir: join_paths(devhelp_mandir, 'man1')
+)
+
+subdir('dtd')
+subdir('icons')
diff --git a/data/org.gnome.Devhelp.service.in b/data/org.gnome.Devhelp.service.in
new file mode 100644
index 0000000..3555cfd
--- /dev/null
+++ b/data/org.gnome.Devhelp.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.Devhelp
+Exec=@bindir@/devhelp --gapplication-service
diff --git a/docs/meson.build b/docs/meson.build
new file mode 100644
index 0000000..ead14c4
--- /dev/null
+++ b/docs/meson.build
@@ -0,0 +1 @@
+subdir('reference')
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
new file mode 100644
index 0000000..fa7260b
--- /dev/null
+++ b/docs/reference/meson.build
@@ -0,0 +1,40 @@
+subdir('xml')
+
+private_headers = [
+  'dh-app.h',
+  'dh-assistant.h',
+  'dh-enum-types-app.h',
+  'dh-error.h',
+  'dh-language.h',
+  'dh-parser.h',
+  'dh-preferences.h',
+  'dh-settings.h',
+  'dh-util.h',
+  'dh-window.h'
+]
+
+webkit_prefix = webkit2gtk_dep.get_pkgconfig_variable('prefix')
+webkit_doc_path = join_paths(webkit_prefix, 'share', 'gtk-doc', 'html')
+
+doc_path = join_paths(devhelp_datadir, 'gtk-doc', 'html', libdevhelp_name)
+
+gnome.gtkdoc(
+  devhelp_name,
+  main_xml: devhelp_name + '-docs.xml',
+  src_dir: src_inc,
+  dependencies: libdevhelp_dep,
+  scan_args: [
+    '--rebuild-types',
+    '--ignore-headers=' + ' '.join(private_headers)
+  ],
+  mkdb_args: [
+    '--xml-mode',
+    '--output-format=xml'
+  ],
+  gobject_typesfile: devhelp_name + '.types',
+  fixxref_args: [
+    '--extra-dir=' + join_paths(webkit_doc_path, 'webkit2gtk-4.0')
+  ],
+  install: true,
+  install_dir: doc_path
+)
diff --git a/docs/reference/xml/gtkdocentities.ent.in b/docs/reference/xml/gtkdocentities.ent.in
new file mode 100644
index 0000000..fd86c16
--- /dev/null
+++ b/docs/reference/xml/gtkdocentities.ent.in
@@ -0,0 +1,7 @@
+<!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@">
diff --git a/docs/reference/xml/meson.build b/docs/reference/xml/meson.build
new file mode 100644
index 0000000..a383dd5
--- /dev/null
+++ b/docs/reference/xml/meson.build
@@ -0,0 +1,17 @@
+ent_conf = configuration_data()
+
+ent_conf.set('PACKAGE', package)
+ent_conf.set('PACKAGE_BUGREPORT', package_bugreport)
+ent_conf.set('PACKAGE_NAME', package_name)
+ent_conf.set('PACKAGE_STRING', package_string)
+ent_conf.set('PACKAGE_TARNAME', package_tarname)
+ent_conf.set('PACKAGE_URL', package_url)
+ent_conf.set('PACKAGE_VERSION', package_version)
+
+ent = 'gtkdocentities.ent'
+
+configure_file(
+  input: ent + '.in',
+  output: ent,
+  configuration: ent_conf
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..1c51924
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,188 @@
+project(
+  'Devhelp', 'c',
+  version: '3.25.2',
+  license: 'GPL2',
+  default_options: [
+    'buildtype=debugoptimized',
+    'c_std=gnu99',
+    'warning_level=1'
+  ],
+  meson_version: '>= 0.41.0'
+)
+
+devhelp_name = meson.project_name().to_lower()
+
+devhelp_version = meson.project_version()
+version_array = devhelp_version.split('.')
+devhelp_major_version = version_array[0].to_int()
+devhelp_minor_version = version_array[1].to_int()
+devhelp_micro_version = version_array[2].to_int()
+
+devhelp_api_version = '@0@.0'.format(devhelp_major_version)
+devhelp_api_name = '@0@-@1@'.format(devhelp_name, devhelp_api_version)
+
+devhelp_gir_version = '1.0'
+
+devhelp_prefix = get_option('prefix')
+devhelp_bindir = join_paths(devhelp_prefix, get_option('bindir'))
+devhelp_datadir = join_paths(devhelp_prefix, get_option('datadir'))
+devhelp_includedir = join_paths(devhelp_prefix, get_option('includedir'))
+devhelp_libdir = join_paths(devhelp_prefix, get_option('libdir'))
+devhelp_localedir = join_paths(devhelp_prefix, get_option('localedir'))
+devhelp_mandir = join_paths(devhelp_prefix, get_option('mandir'))
+
+devhelp_pkgdatadir = join_paths(devhelp_datadir, devhelp_name)
+devhelp_pkgincludedir = join_paths(devhelp_includedir, devhelp_api_name)
+
+# LT Version numbers, remember to change them just *before* a release.
+#   (Interfaces removed:    CURRENT++, AGE=0, REVISION=0)
+#   (Interfaces added:      CURRENT++, AGE++, REVISION=0)
+#   (No interfaces changed:                   REVISION++)
+libdevhelp_current = 3
+libdevhelp_revision = 0
+libdevhelp_age = 0
+libdevhelp_version = '@0@.@1@.@2@'.format(libdevhelp_current, libdevhelp_revision, libdevhelp_age)
+
+libdevhelp_name = '@0@-@1@'.format(devhelp_name, libdevhelp_current)
+
+# package
+package = devhelp_name
+package_bugreport = 'http://bugzilla.gnome.org/enter_bug.cgi?product=devhelp'
+package_name = meson.project_name()
+package_string = '@0@ @1@'.format(meson.project_name(), devhelp_version)
+package_tarname = devhelp_name
+package_url = 'https://wiki.gnome.org/Apps/Devhelp'
+package_version = devhelp_version
+
+cc = meson.get_compiler('c')
+
+config_h = configuration_data()
+
+config_h.set_quoted('GETTEXT_PACKAGE', devhelp_name)
+
+# package
+config_h.set_quoted('PACKAGE_BUGREPORT', package_bugreport)
+config_h.set_quoted('PACKAGE_NAME', package_name)
+config_h.set_quoted('PACKAGE_STRING', package_string)
+config_h.set_quoted('PACKAGE_TARNAME', package_tarname)
+config_h.set_quoted('PACKAGE_URL', package_url)
+config_h.set_quoted('PACKAGE_VERSION', package_version)
+
+# headers
+config_h.set('HAVE_DLFCN_H', cc.has_header('dlfcn.h'))
+config_h.set('HAVE_INTTYPES_H', cc.has_header('inttypes.h'))
+config_h.set('HAVE_MEMORY_H', cc.has_header('memory.h'))
+config_h.set('HAVE_STDINT_H', cc.has_header('stdint.h'))
+config_h.set('HAVE_STDLIB_H', cc.has_header('stdlib.h'))
+config_h.set('HAVE_STRINGS_H', cc.has_header('strings.h'))
+config_h.set('HAVE_STRING_H', cc.has_header('string.h'))
+config_h.set('HAVE_SYS_STAT_H', cc.has_header('sys/stat.h'))
+config_h.set('HAVE_SYS_TYPES_H', cc.has_header('sys/types.h'))
+config_h.set('HAVE_UNISTD_H', cc.has_header('unistd.h'))
+
+# functions
+if host_machine.system().contains('darwin')
+  config_h.set('HAVE_CFLOCALECOPYCURRENT', cc.has_function('CFLocaleCopyCurrent'))
+  config_h.set('HAVE_CFPREFERENCESCOPYAPPVALUE', cc.has_function('CFPreferencesCopyAppValue'))
+endif
+
+config_h.set('HAVE_DCGETTEXT', cc.has_function('dcgettext'))
+config_h.set('HAVE_GETTEXT', cc.has_function('gettext'))
+config_h.set('HAVE_ICONV', cc.has_function('iconv'))
+
+# compiler flags
+common_flags = [
+  '-DHAVE_CONFIG_H',
+  '-DLOCALEDIR="@0@"'.format(devhelp_localedir),
+  '-DDATADIR="@0@"'.format(devhelp_datadir),
+  '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name()),
+  '-DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES'
+]
+
+buildtype = get_option('buildtype')
+if buildtype == 'debug' or buildtype == 'debugoptimized'
+  test_cflags = [
+    '-fno-strict-aliasing',
+    '-Wcast-align',
+    '-Wdeclaration-after-statement',
+    '-Wformat-nonliteral',
+    '-Wformat=2',
+    '-Winit-self',
+    '-Winline',
+    '-Wmissing-declarations',
+    '-Wmissing-format-attribute',
+    '-Wmissing-include-dirs',
+    '-Wmissing-noreturn',
+    '-Wmissing-prototypes',
+    '-Wnested-externs',
+    '-Wno-error=missing-field-initializers',
+    '-Wno-error=unused-parameter',
+    '-Wno-missing-field-initializers',
+    '-Wno-unused-parameter',
+    '-Wold-style-definition',
+    '-Wpacked',
+    '-Wpointer-arith',
+    '-Wredundant-decls',
+    '-Wshadow',
+    '-Wstrict-prototypes',
+    '-Wswitch-enum',
+    '-Wundef',
+    '-Wunused-but-set-variable',
+    '-Wwrite-strings'
+  ]
+
+  foreach cflag: test_cflags
+    if cc.has_argument(cflag)
+      common_flags += [cflag]
+    endif
+  endforeach
+
+  add_project_arguments(common_flags, language: 'c')
+endif
+
+gio_req_version = '>= 2.38'
+gtk_req_version = '>= 3.22'
+webkit2gtk_req_version = '>= 2.6'
+
+webkit2gtk_dep = dependency('webkit2gtk-4.0', version: webkit2gtk_req_version)
+
+devhelp_deps = [
+  dependency('gio-2.0', version: gio_req_version),
+  dependency('gtk+-3.0', version: gtk_req_version),
+  webkit2gtk_dep,
+  dependency('gsettings-desktop-schemas'),
+  cc.find_library('m', required: true)
+]
+
+configure_file(
+  output: 'config.h',
+  configuration: config_h
+)
+
+gnome = import('gnome')
+i18n = import('i18n')
+pkg = import('pkgconfig')
+
+po_dir = join_paths(meson.source_root(), 'po')
+
+top_inc = include_directories('.')
+
+subdir('po')
+subdir('src')
+subdir('data')
+subdir('misc')
+
+if get_option('enable-gtk-doc')
+  subdir('docs')
+endif
+
+meson.add_install_script('meson_post_install.py')
+
+# Print a summary of the configuration
+message('Configuration:')
+message(meson.project_name() +  ' version ' + devhelp_version)
+message('Source code location:  ' + meson.source_root())
+message('Prefix:                ' + devhelp_prefix)
+message('Compiler:              ' + cc.get_id())
+message('API documentation:     ' + (get_option('enable-gtk-doc') ? 'yes' : 'no'))
+message('GObject introspection: ' + (get_option('enable-introspection') ? 'yes' : 'no'))
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..253fb68
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,2 @@
+option('enable-gtk-doc', type: 'boolean', value: false, description: 'use gtk-doc to build documentation')
+option('enable-introspection', type: 'boolean', value: true, description: 'Enable GObject Introspection 
(depends on GObject)')
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100644
index 0000000..a8202d5
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+
+install_prefix = os.environ['MESON_INSTALL_PREFIX']
+icondir = os.path.join(install_prefix, 'share', 'icons', 'hicolor')
+schemadir = os.path.join(install_prefix, 'share', 'glib-2.0', 'schemas')
+
+if not os.environ.get('DESTDIR'):
+  print('Update icon cache...')
+  subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir])
+
+  print('Compiling gsettings schemas...')
+  subprocess.call(['glib-compile-schemas', schemadir])
+
+  print('Byte-compiling python modules...')
+  subprocess.call(['pycompile', install_prefix])
+  subprocess.call(['python', '-O', '-m', 'compileall', '-f', '-q', install_prefix])
diff --git a/misc/gedit-plugin/meson.build b/misc/gedit-plugin/meson.build
new file mode 100644
index 0000000..65f6a78
--- /dev/null
+++ b/misc/gedit-plugin/meson.build
@@ -0,0 +1,18 @@
+plugin_dir = join_paths(devhelp_libdir, 'gedit', 'plugins')
+
+install_data(
+  devhelp_name + '.py',
+  install_dir: plugin_dir
+)
+
+plugin_data = devhelp_name + '.plugin'
+
+i18n.merge_file(
+  plugin_data,
+  type: 'desktop',
+  input: plugin_data + '.desktop.in',
+  output: plugin_data,
+  po_dir: po_dir,
+  install: true,
+  install_dir: plugin_dir
+)
diff --git a/misc/meson.build b/misc/meson.build
new file mode 100644
index 0000000..76f47a0
--- /dev/null
+++ b/misc/meson.build
@@ -0,0 +1 @@
+subdir('gedit-plugin')
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..3ca995d
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1 @@
+i18n.gettext(devhelp_name, preset: 'glib')
diff --git a/src/devhelp.map b/src/devhelp.map
new file mode 100644
index 0000000..d5f7037
--- /dev/null
+++ b/src/devhelp.map
@@ -0,0 +1,6 @@
+LIBDEVHELP_3 {
+global:
+  dh_*;
+local:
+       *;
+};
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..c67cf39
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,193 @@
+src_inc = include_directories('.')
+
+libdevhelp_headers = files(
+  'devhelp.h',
+  'dh-assistant-view.h',
+  'dh-book.h',
+  'dh-book-manager.h',
+  'dh-book-tree.h',
+  'dh-init.h',
+  'dh-keyword-model.h',
+  'dh-link.h',
+  'dh-sidebar.h'
+)
+
+install_headers(
+  libdevhelp_headers,
+  install_dir: join_paths(devhelp_pkgincludedir, devhelp_name)
+)
+
+libdevhelp_sources = files(
+  'dh-assistant-view.c',
+  'dh-book.c',
+  'dh-book-manager.c',
+  'dh-book-tree.c',
+  'dh-init.c',
+  'dh-keyword-model.c',
+  'dh-link.c',
+  'dh-sidebar.c'
+)
+
+enum = 'dh-enum-types'
+
+libdevhelp_sources += gnome.mkenums(
+  enum,
+  sources: libdevhelp_headers,
+  c_template: enum + '.c.template',
+  h_template: enum + '.h.template',
+  install_header: true,
+  install_dir: join_paths(devhelp_pkgincludedir, devhelp_name)
+)
+
+libdevhelp_private_headers = files(
+  'dh-error.h',
+  'dh-language.h',
+  'dh-parser.h',
+  'dh-preferences.h',
+  'dh-settings.h',
+  'dh-util.h'
+)
+
+libdevhelp_private_sources = files(
+  'dh-error.c',
+  'dh-language.c',
+  'dh-parser.c',
+  'dh-preferences.c',
+  'dh-util.c',
+  'dh-settings.c'
+)
+
+resource_files = files(
+  'devhelp-menu.ui',
+  'dh-assistant.ui',
+  'dh-preferences.ui',
+  'dh-window.ui',
+  'help-overlay.ui'
+)
+
+libdevhelp_private_sources += gnome.compile_resources(
+  'dh-resources',
+  'dh.gresource.xml',
+  source_dir: '.',
+  c_name: 'dh',
+  dependencies: resource_files,
+  export: true
+)
+
+symbol_map = 'devhelp.map'
+
+ldflags = [
+  '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), symbol_map)
+]
+
+libdevhelp_ldflags = []
+
+if host_machine.system().contains('linux')
+  foreach ldflag: ldflags
+    if cc.has_argument(ldflag)
+      libdevhelp_ldflags += ldflag
+    endif
+  endforeach
+endif
+
+libdevhelp = library(
+  libdevhelp_name,
+  sources: libdevhelp_sources + libdevhelp_private_sources,
+  version: libdevhelp_version,
+  soversion: libdevhelp_current,
+  include_directories: top_inc,
+  dependencies: devhelp_deps,
+  link_args: libdevhelp_ldflags,
+  link_depends: symbol_map,
+  install: true,
+  install_dir: devhelp_libdir
+)
+
+libdevhelp_dep = declare_dependency(
+  link_with: libdevhelp,
+  include_directories: src_inc,
+  dependencies: devhelp_deps
+)
+
+pkg.generate(
+  libraries: libdevhelp,
+  version: devhelp_version,
+  name: devhelp_name,
+  description: devhelp_name,
+  filebase: 'lib' + devhelp_api_name,
+  subdirs: devhelp_pkgincludedir,
+  requires: [
+    'gio-2.0 ' + gio_req_version,
+    'gtk+-3.0 ' + gtk_req_version,
+    'webkit2gtk-4.0 ' + webkit2gtk_req_version
+  ],
+  requires_private: [
+    'gsettings-desktop-schemas'
+  ],
+  variables: [
+    'exec_prefix=${prefix}'
+  ],
+  install_dir: join_paths(devhelp_libdir, 'pkgconfig')
+)
+
+devhelp_headers = files(
+  'dh-app.h',
+  'dh-assistant.h',
+  'dh-window.h'
+)
+
+devhelp_sources = files(
+  'dh-app.c',
+  'dh-assistant.c',
+  'dh-main.c',
+  'dh-window.c'
+)
+
+enum = 'dh-enum-types-app'
+
+devhelp_sources += gnome.mkenums(
+  enum,
+  sources: devhelp_headers,
+  c_template: enum + '.c.template',
+  h_template: enum + '.h.template'
+)
+
+executable(
+  devhelp_name,
+  devhelp_sources,
+  include_directories: top_inc,
+  dependencies: libdevhelp_dep,
+  install: true,
+  install_dir: devhelp_bindir
+)
+
+if get_option('enable-introspection') and get_option('default_library') == 'shared'
+  gir_incs = [
+    'Gtk-3.0',
+    'WebKit2-4.0'
+  ]
+
+  gir_extra_args = [
+    '--warn-all',
+    '--c-include="devhelp/devhelp.h"'
+  ]
+
+  gir_dir = join_paths(devhelp_datadir, 'gir-' + devhelp_gir_version)
+  typelib_dir = join_paths(devhelp_libdir, 'girepository-' + devhelp_gir_version)
+
+  gnome.generate_gir(
+    libdevhelp,
+    sources: libdevhelp_sources + libdevhelp_headers,
+    namespace: meson.project_name(),
+    nsversion: devhelp_api_version,
+    symbol_prefix: 'dh',
+    identifier_prefix: 'Dh',
+    export_packages: 'lib' + devhelp_api_name,
+    includes: gir_incs,
+    include_directories: top_inc,
+    install: true,
+    install_dir_gir: gir_dir,
+    install_dir_typelib: typelib_dir,
+    extra_args: gir_extra_args
+  )
+endif


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