[pangomm/wip/kjellahl/meson-build] Add support for building pangomm with Meson



commit 0aa566c908bbc308f1900528456be00cac6350c5
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Sun Sep 29 15:29:55 2019 +0200

    Add support for building pangomm with Meson
    
    pangomm can be built with either Autotools or Meson.
    
    See MR !4

 .gitignore                       |   3 +
 MSVC_NMake/pangomm/meson.build   |  16 +++
 Makefile.am                      |  13 +++
 docs/reference/meson.build       | 168 +++++++++++++++++++++++++++++++
 meson.build                      | 191 +++++++++++++++++++++++++++++++++++
 meson_options.txt                |   8 ++
 pango/meson.build                |  51 ++++++++++
 pango/pangomm/meson.build        | 212 +++++++++++++++++++++++++++++++++++++++
 pango/pangommconfig.h.meson      |  19 ++++
 tools/dist-cmd.py                |  12 +++
 tools/extra_defs_gen/meson.build |  27 +++++
 untracked/README                 |  36 +++++++
 12 files changed, 756 insertions(+)
---
diff --git a/.gitignore b/.gitignore
index 3c58005..7b930fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,3 +25,6 @@ stamp-h?
 /tools/extra_defs_gen/generate_extra_defs
 /MSVC_NMake/pangomm/pangomm.rc
 /MSVC_NMake/pangomm/pangommconfig.h
+untracked/build_scripts/
+untracked/docs/
+untracked/pango/
diff --git a/MSVC_NMake/pangomm/meson.build b/MSVC_NMake/pangomm/meson.build
new file mode 100644
index 0000000..1353b51
--- /dev/null
+++ b/MSVC_NMake/pangomm/meson.build
@@ -0,0 +1,16 @@
+# MSVC_NMake/pangomm
+
+# Input: pkg_conf_data, project_build_root
+# Output: -
+
+configure_file(
+  input: 'pangomm.rc.in',
+  output: '@BASENAME@',
+  configuration: pkg_conf_data,
+)
+
+# Copy the generated configuration header into the MSVC project directory.
+meson.add_postconf_script(
+  'cp', '-f', project_build_root / 'pango' / 'pangommconfig.h',
+  meson.current_build_dir()
+)
diff --git a/Makefile.am b/Makefile.am
index b81a588..f5bb023 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -48,5 +48,18 @@ dist_noinst_SCRIPTS = autogen.sh
 
 DISTCLEANFILES = MSVC_NMake/pangomm/pangommconfig.h
 
+# Distribute files needed when building mm-common with meson.
+EXTRA_DIST = \
+  meson.build \
+  meson_options.txt \
+  MSVC_NMake/pangomm/meson.build \
+  docs/reference/meson.build \
+  pango/meson.build \
+  pango/pangomm/meson.build \
+  pango/pangommconfig.h.meson \
+  tools/dist-cmd.py \
+  tools/extra_defs_gen/meson.build \
+  untracked/README
+
 # Optional: auto-generate the ChangeLog file from the git log on make dist
 include $(top_srcdir)/build/dist-changelog.am
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
new file mode 100644
index 0000000..eaa9a44
--- /dev/null
+++ b/docs/reference/meson.build
@@ -0,0 +1,168 @@
+# docs/reference
+
+# Input: built_files_root, project_source_root, pangomm_pcname, perl,
+#        hg_ccg_basenames, extra_h_files, built_file_targets, install_datadir,
+#        dist_cmd, python3
+# Output: install_docdir, install_devhelpdir
+
+tag_file_modules = [
+  'mm-common-libstdc++',
+  'sigc++-3.0',
+  'glibmm-2.64',
+  'cairomm-1.16',
+]
+doxygen_tagfiles = ''
+docinstall_flags = []
+foreach module : tag_file_modules
+  depmod = dependency(module, required: false)
+  if depmod.found()
+    doxytagfile = depmod.get_pkgconfig_variable('doxytagfile')
+    htmlrefpub = depmod.get_pkgconfig_variable('htmlrefpub', default: '')
+    htmlrefdir = depmod.get_pkgconfig_variable('htmlrefdir', default: '')
+    if htmlrefpub == ''
+      htmlrefpub = htmlrefdir
+    elif htmlrefdir == ''
+      htmlrefdir = htmlrefpub
+    endif
+    doxygen_tagfiles += ' "' + doxytagfile + '=' + htmlrefpub + '"'
+    if not htmlrefdir.endswith('/')
+      htmlrefdir += '/'
+    endif
+    docinstall_flags += ['-l', doxytagfile.split('/')[-1] + '@' + htmlrefdir]
+  endif
+endforeach
+
+book_name = pangomm_pcname
+book_title = meson.project_name() + ' Reference Manual'
+
+# Configuration data for Doxyfile.
+doc_conf_data = configuration_data()
+doc_conf_data.set('configure_input',
+  'docs/reference/Doxyfile. Generated from Doxyfile.in by meson.configure_file().')
+doc_conf_data.set('PACKAGE_NAME', meson.project_name())
+doc_conf_data.set('PACKAGE_VERSION', meson.project_version())
+doc_conf_data.set('abs_top_builddir', built_files_root)
+doc_conf_data.set('abs_top_srcdir', project_source_root)
+doc_conf_data.set('PANGOMM_MODULE_NAME', book_name)
+doc_conf_data.set('DOXYGEN_TAGFILES', doxygen_tagfiles)
+doc_conf_data.set('PERL', perl.path())
+
+configure_file(
+  input: 'Doxyfile.in',
+  output: '@BASENAME@',
+  configuration: doc_conf_data,
+)
+
+# Installation directories relative to {prefix}.
+install_docdir = install_datadir / 'doc' / book_name
+install_reference_docdir = install_docdir / 'reference'
+install_image_docdir = install_docdir / 'images'
+install_devhelpdir = install_datadir / 'devhelp' / 'books' / book_name
+
+if not build_documentation
+  # Documentation shall not be built or installed.
+  # Return to the calling meson.build file.
+  subdir_done()
+endif
+
+# Built input .h files to Doxygen.
+built_h_files = []
+foreach file : hg_ccg_basenames
+  built_h_files += built_files_root / 'pango' / 'pangomm' / file + '.h'
+endforeach
+
+# Hand-coded input .h files to Doxygen.
+src_h_files = []
+foreach file : extra_h_files
+  if file != 'wrap_init.h'
+    src_h_files += project_source_root / 'pango' / 'pangomm' / file
+  endif
+endforeach
+src_h_files += project_source_root / 'pango' / 'pangomm.h'
+
+doctool_dir = project_source_root / 'untracked' / 'docs' # MMDOCTOOLDIR
+doctool_dist_dir = 'untracked' / 'docs' # Relative to MESON_DIST_ROOT
+
+if built_file_targets.length() > 0
+  # .h files have been generated from .hg files (maintainer mode).
+  tag_file = custom_target('html_and_tag',
+    input: src_h_files,
+    output: book_name + '.tag',
+    command: [
+      python3, doc_reference, 'doxygen',
+      doctool_dir,
+      '@OUTPUT@',
+      built_h_files,
+      '@INPUT@',
+    ],
+    build_by_default: build_documentation,
+    depends: built_file_targets,
+    install: true,
+    install_dir: install_reference_docdir,
+  )
+else
+  # All .h files are stored in the source tree (not maintainer mode).
+  tag_file = custom_target('html_and_tag',
+    input: src_h_files + built_h_files,
+    output: book_name + '.tag',
+    command: [
+      python3, doc_reference, 'doxygen',
+      doctool_dir,
+      '@OUTPUT@',
+      '@INPUT@',
+    ],
+    build_by_default: build_documentation,
+    install: true,
+    install_dir: install_reference_docdir,
+  )
+endif
+
+devhelp_file = custom_target('devhelp',
+  input: tag_file,
+  output: book_name + '.devhelp2',
+  command: [
+    python3, doc_reference, 'devhelp',
+    doctool_dir,
+    '@INPUT@',
+    '@OUTPUT@',
+    book_name,
+    book_title,
+  ],
+  build_by_default: build_documentation,
+)
+
+# Install Devhelp file and html files.
+meson.add_install_script(
+  python3.path(), doc_reference, 'install_doc',
+  doctool_dir,
+  devhelp_file.full_path(),
+  install_devhelpdir,
+  install_reference_docdir / 'html',
+  docinstall_flags
+)
+
+# Install images.
+image_basefiles = [
+  'gtkmm_logo.gif',
+  'top.gif',
+]
+image_files = []
+foreach file : image_basefiles
+  image_files += '..' / 'images' / file
+endforeach
+
+install_data(image_files, install_dir: install_image_docdir)
+
+if not meson.is_subproject()
+  # Distribute built files and files copied by mm-common-prepare.
+  # (add_dist_script() is not allowed in a subproject)
+  meson.add_dist_script(
+    python3.path(), dist_cmd,
+    python3.path(), doc_reference, 'dist_doc',
+    doctool_dir,
+    doctool_dist_dir,
+    meson.current_build_dir(),
+    tag_file.full_path(),
+    devhelp_file.full_path(),
+  )
+endif
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..5389a54
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,191 @@
+# This file is part of pangomm.
+
+project('pangomm', 'cpp',
+  version: '2.43.1',
+  license: 'LGPLv2.1+',
+  default_options: [
+    'cpp_std=c++17'
+  ],
+  meson_version: '>= 0.50.0', # required for python3.path()
+)
+
+pangomm_api_version = '2.44'
+pangomm_pcname = meson.project_name() + '-' + pangomm_api_version
+
+pangomm_version_array = meson.project_version().split('.')
+pangomm_major_version = pangomm_version_array[0].to_int()
+pangomm_minor_version = pangomm_version_array[1].to_int()
+pangomm_micro_version = pangomm_version_array[2].to_int()
+
+# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
+# The relation between libtool's current:revison:age interface versioning
+# and the .so filename, .so.x.y.z, is
+# x = current - age
+# y = age
+# z = revision
+# If libtool_soversion is updated as described in libtool's documentation,
+# x.y.z will usually *not* be equal to meson.project_version().
+libtool_soversion = [1, 30, 0]
+pangomm_libversion = '@0@.@1@.@2@'.format(
+  libtool_soversion[0] - libtool_soversion[2],
+  libtool_soversion[2],
+  libtool_soversion[1])
+
+# Use these instead of meson.source_root() and meson.build_root() in subdirectories.
+# source_root() and build_root() are not useful, if this is a subproject.
+project_source_root = meson.current_source_dir()
+project_build_root = meson.current_build_dir()
+
+python3 = import('python').find_installation('python3')
+python_version = python3.language_version()
+python_version_req = '>= 3.5'
+if not python_version.version_compare(python_version_req)
+  error('Requires Python @0@, found @1@.'.format(python_version_req, python_version))
+endif
+
+# Do we build from a git repository?
+# Suppose we do if and only if a .git directory exists.
+cmd_py = '''
+import os
+import sys
+sys.exit(0 if os.path.isdir("@0@") else 1)
+'''.format(project_source_root / '.git')
+is_git_build = run_command(python3, '-c', cmd_py).returncode() == 0
+# In Unix-like system, an alternative is
+# is_git_build = run_command('test', '-d', project_source_root / '.git').returncode() == 0
+# Python code can be used in all operating sytems where Meson can run.
+
+# Options.
+maintainer_mode_opt = get_option('maintainer-mode')
+maintainer_mode = maintainer_mode_opt == 'true' or \
+                 (maintainer_mode_opt == 'if-git-build' and is_git_build)
+warning_level = get_option('warnings')
+build_deprecated_api = get_option('build-deprecated-api')
+build_documentation_opt = get_option('build-documentation')
+build_documentation = build_documentation_opt == 'true' or \
+                     (build_documentation_opt == 'if-maintainer-mode' and maintainer_mode)
+
+# Installation directories are relative to {prefix}.
+install_prefix = get_option('prefix')
+install_includedir = get_option('includedir')
+install_libdir = get_option('libdir')
+install_datadir = get_option('datadir')
+install_pkgconfigdir = install_libdir / 'pkgconfig'
+
+# Dependencies.
+glibmm_req = '>= 2.63.1'
+cairomm_req = '>= 1.15.1'
+pangocairo_req = '>= 1.41.0'
+glibmm_dep = dependency('glibmm-2.64', version: glibmm_req)
+cairomm_dep = dependency('cairomm-1.16', version: cairomm_req)
+pangocairo_dep = dependency('pangocairo', version: pangocairo_req)
+pangomm_deps = [glibmm_dep, cairomm_dep, pangocairo_dep]
+pangomm_requires = ' '.join([
+  'glibmm-2.64', glibmm_req,
+  'cairomm-1.16', cairomm_req,
+  'pangocairo', pangocairo_req,
+])
+
+# Some dependencies are required only in maintainer mode and/or if
+# reference documentation shall be built.
+mm_common_get = find_program('mm-common-get', required: maintainer_mode)
+m4 = find_program('m4', required: maintainer_mode) # Used by gmmproc (in glibmm)
+perl = find_program('perl', required: maintainer_mode or build_documentation)
+doxygen = find_program('doxygen', required: build_documentation)
+dot = find_program('dot', required: build_documentation) # Used by Doxygen
+xsltproc = find_program('xsltproc', required: build_documentation)
+
+# Where to find gmmproc and generate_wrap_init.pl.
+gmmproc_dir = glibmm_dep.get_pkgconfig_variable('gmmprocdir')
+
+script_dir = project_source_root / 'untracked' / 'build_scripts'
+generate_binding = script_dir / 'generate-binding.py'
+doc_reference = script_dir / 'doc-reference.py'
+dist_changelog = script_dir / 'dist-changelog.py'
+dist_build_scripts = script_dir / 'dist-build-scripts.py'
+dist_cmd = project_source_root / 'tools' / 'dist-cmd.py' # Must be committed to git.
+
+if maintainer_mode and mm_common_get.found()
+  # Copy files to untracked/build_scripts and untracked/docs.
+  run_command(mm_common_get, '--force', script_dir,
+    project_source_root / 'untracked' / 'docs')
+endif
+
+cpp_compiler = meson.get_compiler('cpp')
+
+# Set compiler warnings.
+warning_flags = []
+if warning_level == 'min'
+  warning_flags = ['-Wall']
+elif warning_level == 'max' or warning_level == 'fatal'
+  warning_flags = '-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wshadow 
-Wno-long-long'.split()
+  if warning_level == 'fatal'
+    warning_flags += ['-Werror']
+    deprecations = 'G PANGO GLIBMM SIGCXX'.split()
+    foreach d : deprecations
+      warning_flags += '-D@0@_DISABLE_DEPRECATED'.format(d)
+    endforeach
+  endif
+endif
+
+warning_flags = cpp_compiler.get_supported_arguments(warning_flags)
+add_project_arguments(warning_flags, language: 'cpp')
+
+subdir('tools/extra_defs_gen')
+subdir('pango')
+subdir('docs/reference')
+subdir('MSVC_NMake/pangomm')
+
+if not meson.is_subproject()
+  # Add a ChangeLog file to the distribution directory.
+  # (add_dist_script() is not allowed in a subproject)
+  meson.add_dist_script(
+    python3.path(), dist_cmd,
+    python3.path(), dist_changelog,
+    project_source_root,
+  )
+  # Add build scripts to the distribution directory, and delete .gitignore
+  # files and an empty $MESON_DIST_ROOT/build/ directory.
+  meson.add_dist_script(
+    python3.path(), dist_cmd,
+    python3.path(), dist_build_scripts,
+    project_source_root,
+    'untracked' / 'build_scripts',
+  )
+endif
+
+# Print a summary.
+real_maintainer_mode = ''
+if maintainer_mode_opt == 'if-git-build'
+  real_maintainer_mode = ' (@0@)'.format(maintainer_mode)
+endif
+
+real_build_documentation = ''
+if build_documentation_opt == 'if-maintainer-mode'
+  real_build_documentation = ' (@0@)'.format(build_documentation)
+endif
+
+summary = [
+  '',
+  '------',
+  meson.project_name() + ' ' + meson.project_version(),
+  '',
+  '         Maintainer mode: @0@@1@'.format(maintainer_mode_opt, real_maintainer_mode),
+  '       Compiler warnings: @0@'.format(warning_level),
+  '    Build deprecated API: @0@'.format(build_deprecated_api),
+  'Build HTML documentation: @0@@1@'.format(build_documentation_opt, real_build_documentation),
+  'Directories:',
+  '                  prefix: @0@'.format(install_prefix),
+  '              includedir: @0@'.format(install_prefix / install_includedir),
+  '       includepangommdir: @0@'.format(install_prefix / install_includedir / pangomm_pcname),
+  '                  libdir: @0@'.format(install_prefix / install_libdir),
+  '        includeconfigdir: @0@'.format(install_prefix / install_includeconfigdir),
+  '                   m4dir: @0@'.format(install_prefix / install_m4dir),
+  '            pkgconfigdir: @0@'.format(install_prefix / install_pkgconfigdir),
+  '                 datadir: @0@'.format(install_prefix / install_datadir),
+  '                  docdir: @0@'.format(install_prefix / install_docdir),
+  '              devhelpdir: @0@'.format(install_prefix / install_devhelpdir),
+  '------'
+]
+
+message('\n'.join(summary))
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..1c4e122
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,8 @@
+option('maintainer-mode', type: 'combo', choices: ['false', 'if-git-build', 'true'],
+  value: 'if-git-build', description: 'Generate source code from .hg and .ccg files')
+option('warnings', type: 'combo', choices: ['no', 'min', 'max', 'fatal'], value: 'fatal',
+  description: 'Compiler warning level')
+option('build-deprecated-api', type: 'boolean', value: true,
+  description: 'Build deprecated API and include it in the library')
+option('build-documentation', type: 'combo', choices: ['false', 'if-maintainer-mode', 'true'],
+  value: 'if-maintainer-mode', description: 'Build and install the documentation')
diff --git a/pango/meson.build b/pango/meson.build
new file mode 100644
index 0000000..08b0ad4
--- /dev/null
+++ b/pango/meson.build
@@ -0,0 +1,51 @@
+# pango
+
+# Input: install_prefix, install_datadir, install_includedir,
+#        pangomm_pcname, pangomm_api_version, pangomm_requires,
+#        install_pkgconfigdir, install_libdir, build_deprecated_api,
+#        pangomm_major_version, pangomm_minor_version, pangomm_micro_version
+# Output: pkg_conf_data, install_includeconfigdir
+
+pkg_conf_data = configuration_data()
+pkg_conf_data.set('prefix', install_prefix)
+pkg_conf_data.set('exec_prefix', '${prefix}')
+pkg_conf_data.set('libdir', '${prefix}' / install_libdir)
+pkg_conf_data.set('datarootdir', '${prefix}' / install_datadir)
+pkg_conf_data.set('datadir', '${datarootdir}')
+pkg_conf_data.set('includedir', '${prefix}' / install_includedir)
+pkg_conf_data.set('srcdir', meson.current_source_dir())
+pkg_conf_data.set('PACKAGE_TARNAME', meson.project_name())
+pkg_conf_data.set('PACKAGE_VERSION', meson.project_version())
+pkg_conf_data.set('PANGOMM_MODULE_NAME', pangomm_pcname)
+pkg_conf_data.set('PANGOMM_API_VERSION', pangomm_api_version)
+pkg_conf_data.set('PANGOMM_MODULES', pangomm_requires)
+
+if not build_deprecated_api
+  pkg_conf_data.set('PANGOMM_DISABLE_DEPRECATED', true)
+endif
+pkg_conf_data.set('PANGOMM_MAJOR_VERSION', pangomm_major_version)
+pkg_conf_data.set('PANGOMM_MINOR_VERSION', pangomm_minor_version)
+pkg_conf_data.set('PANGOMM_MICRO_VERSION', pangomm_micro_version)
+
+configure_file(
+  input: 'pangomm.pc.in',
+  output: pangomm_pcname + '.pc',
+  configuration: pkg_conf_data,
+  install_dir: install_pkgconfigdir,
+)
+
+configure_file(
+  input: 'pangomm-uninstalled.pc.in',
+  output: pangomm_pcname + '-uninstalled.pc',
+  configuration: pkg_conf_data,
+)
+
+install_includeconfigdir = install_libdir / pangomm_pcname / 'include'
+configure_file(
+  input: 'pangommconfig.h.meson',
+  output: 'pangommconfig.h',
+  configuration: pkg_conf_data,
+  install_dir: install_includeconfigdir,
+)
+
+subdir('pangomm')
diff --git a/pango/pangomm/meson.build b/pango/pangomm/meson.build
new file mode 100644
index 0000000..47d723d
--- /dev/null
+++ b/pango/pangomm/meson.build
@@ -0,0 +1,212 @@
+# pango/pangomm
+
+# Input: pangomm_deps, pangomm_pcname, maintainer_mode, project_source_root,
+#        generate_binding, m4_files, pangomm_libversion, install_includedir,
+#        dist_cmd, python3
+# Output: hg_ccg_basenames, extra_h_files, built_file_targets, built_files_root
+
+defs_basefiles = [
+  'pango.defs',
+  'pango_methods.defs',
+  'pango_enums.defs',
+  'pango_vfuncs.defs',
+  'pango_extra_objects.defs',
+  'pango_docs.xml',
+  'pango_docs_override.xml',
+]
+
+defs_files = []
+foreach file : defs_basefiles
+  defs_files += '..' / 'src' / file
+endforeach
+
+hg_ccg_basenames = [
+  'attributes',
+  'attriter',
+  'attrlist',
+  'cairofontmap',
+  'color',
+  'context',
+  'coverage',
+  'font',
+  'fontdescription',
+  'fontface',
+  'fontfamily',
+  'fontmap',
+  'fontmetrics',
+  'fontset',
+  'glyph',
+  'glyphstring',
+  'item',
+  'language',
+  'layout',
+  'layoutiter',
+  'layoutline',
+  'layoutrun',
+  'rectangle',
+  'renderer',
+  'tabarray',
+]
+
+extra_cc_files = [
+  'init.cc',
+]
+
+extra_h_files = [
+  'init.h',
+  'types.h',
+  'wrap_init.h',
+]
+
+install_headers('..' / 'pangomm.h', subdir: pangomm_pcname)
+install_headers(extra_h_files, subdir: pangomm_pcname / 'pangomm')
+
+untracked_pangomm = 'untracked' / 'pango' / 'pangomm'
+src_untracked_pangomm = project_source_root / untracked_pangomm
+
+if maintainer_mode
+
+  # Maintainer mode. Generate .h and .cc files from .hg and .ccg files in ../src.
+
+  # docs/reference/meson.build needs this.
+  built_files_root = project_build_root
+
+  hg_files = []
+  foreach file : hg_ccg_basenames
+    hg_files += '..' / 'src' / file + '.hg'
+  endforeach
+
+  # Create wrap_init.cc in project_build_root/pango/pangomm.
+  wrap_init_target = custom_target('wrap_init.cc',
+    input: hg_files,
+    output: 'wrap_init.cc',
+    command: [
+      python3, generate_binding, 'generate_wrap_init',
+      gmmproc_dir,
+      '@OUTPUT@',
+      'Pango', # namespace
+      '@INPUT@',
+    ],
+    build_by_default: maintainer_mode,
+    install: false,
+  )
+
+  # Force meson+ninja to generate source files before anything is compiled.
+  # Compilation must depend on these targets.
+  built_file_targets = []
+
+  # Create .h/_p.h/.cc files from .hg/.ccg files in project_build_root/pango/pangomm.
+  foreach file : hg_ccg_basenames
+    hg_file = '..' / 'src' / file + '.hg'
+    ccg_file = '..' / 'src' / file + '.ccg'
+    built_file_targets += custom_target(file + '.cc',
+      input: [hg_file, ccg_file],
+      output: [file + '.stamp', file + '.cc'],
+      command: [
+        python3, generate_binding, 'gmmproc',
+        gmmproc_dir,
+        '@OUTPUT0@',
+        file,
+        meson.current_source_dir() / '..' / 'src',
+        project_source_root / 'tools' / 'm4',
+      ],
+      depend_files: defs_files + m4_files,
+      build_by_default: maintainer_mode,
+      install: false,
+    )
+  endforeach
+
+  pangomm_library = library(pangomm_pcname,
+    wrap_init_target, built_file_targets, extra_cc_files,
+    version: pangomm_libversion,
+    include_directories: '..',
+    dependencies: pangomm_deps,
+    install: true,
+  )
+
+  # Install built .h and _p.h files.
+  meson.add_install_script(
+    python3.path(), generate_binding, 'install_built_h_files',
+    meson.current_build_dir(),
+    install_includedir / pangomm_pcname / 'pangomm', # subdir below {prefix}
+    hg_ccg_basenames
+  )
+
+  if not meson.is_subproject()
+    # Distribute built files.
+    # (add_dist_script() is not allowed in a subproject)
+    meson.add_dist_script(
+      python3.path(), dist_cmd,
+      python3.path(), generate_binding, 'dist_built_files',
+      meson.current_build_dir(),
+      untracked_pangomm,
+      hg_ccg_basenames,
+    )
+  endif
+
+else # not maintainer_mode
+
+  # Not maintainer mode. Compile built source code files in
+  # project_source_root/untracked/pango/pangomm.
+
+  # docs/reference/meson.build needs these.
+  built_file_targets = []
+  built_files_root = project_source_root / 'untracked'
+
+  # Two cases:
+  # 1. The source code comes from a tarball, where the built files
+  #    are stored in project_source_root/untracked.
+  #    There are no built files in the build tree.
+  # 2. Files have been built in the build tree. Then maintainer_mode has
+  #    been changed from true to false. Files that are missing or not up to date
+  #    in project_source_root/untracked are copied from the build tree.
+
+  # Try to copy built source code files to the source tree.
+  run_command(
+    python3, generate_binding, 'copy_built_files',
+    meson.current_build_dir(),
+    src_untracked_pangomm,
+    hg_ccg_basenames,
+  )
+
+  built_cc_files = [ src_untracked_pangomm / 'wrap_init.cc' ]
+  foreach file : hg_ccg_basenames
+    built_cc_files += src_untracked_pangomm / file + '.cc'
+  endforeach
+
+  pangomm_library = library(pangomm_pcname,
+    built_cc_files, extra_cc_files,
+    version: pangomm_libversion,
+    include_directories: [ '..', '..' / '..' / 'untracked' / 'pango' ],
+    dependencies: pangomm_deps,
+    install: true,
+  )
+
+  # Install built .h and _p.h files.
+  meson.add_install_script(
+    python3.path(), generate_binding, 'install_built_h_files',
+    src_untracked_pangomm,
+    install_includedir / pangomm_pcname / 'pangomm', # subdir below {prefix}
+    hg_ccg_basenames
+  )
+
+  if not meson.is_subproject()
+    # Distribute built files.
+    # (add_dist_script() is not allowed in a subproject)
+    meson.add_dist_script(
+      python3.path(), dist_cmd,
+      python3.path(), generate_binding, 'dist_built_files',
+      src_untracked_pangomm,
+      untracked_pangomm,
+      hg_ccg_basenames,
+    )
+  endif
+
+endif
+
+# This is useful in the main project when pangomm is used as a subproject.
+pangomm_dep = declare_dependency(
+  link_with: pangomm_library,
+  include_directories: '..',
+  dependencies: pangomm_deps
+)
diff --git a/pango/pangommconfig.h.meson b/pango/pangommconfig.h.meson
new file mode 100644
index 0000000..e28f310
--- /dev/null
+++ b/pango/pangommconfig.h.meson
@@ -0,0 +1,19 @@
+/* This file is part of pangomm. */
+#ifndef PANGOMM_PANGOMMCONFIG_H_INCLUDED
+#define PANGOMM_PANGOMMCONFIG_H_INCLUDED
+
+#include <glibmmconfig.h>
+
+/* Define to omit deprecated API from the library. */
+#mesondefine PANGOMM_DISABLE_DEPRECATED
+
+/* Major version number of pangomm. */
+#mesondefine PANGOMM_MAJOR_VERSION
+
+/* Minor version number of pangomm. */
+#mesondefine PANGOMM_MINOR_VERSION
+
+/* Micro version number of pangomm. */
+#mesondefine PANGOMM_MICRO_VERSION
+
+#endif /* !PANGOMM_PANGOMMCONFIG_H_INCLUDED */
diff --git a/tools/dist-cmd.py b/tools/dist-cmd.py
new file mode 100755
index 0000000..30da5da
--- /dev/null
+++ b/tools/dist-cmd.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+# External command, intended to be called with meson.add_dist_script() in meson.build.
+# meson.add_dist_script() can't call a script that's not committed to git.
+# This script shall be committed. It can be used for calling other non-committed scripts.
+
+# dist-cmd.py <cmd> <args>...
+
+import sys
+import subprocess
+
+sys.exit(subprocess.run(sys.argv[1:]).returncode)
diff --git a/tools/extra_defs_gen/meson.build b/tools/extra_defs_gen/meson.build
new file mode 100644
index 0000000..e4764c9
--- /dev/null
+++ b/tools/extra_defs_gen/meson.build
@@ -0,0 +1,27 @@
+# tools/extra_defs_gen
+
+# Input: cpp_compiler, glibmm_dep, pangocairo_dep, install_libdir, pangomm_pcname
+# Output: m4_files, install_m4dir
+
+glibmm_generate_extra_defs_dep = cpp_compiler.find_library(
+  'glibmm_generate_extra_defs-2.64',
+)
+
+executable('generate_extra_defs', 'generate_defs_pango.cc',
+  dependencies: [glibmm_dep, pangocairo_dep, glibmm_generate_extra_defs_dep],
+  install: false,
+)
+
+# Install m4 files for reuse by other *mm projects, when building from git.
+m4_basefiles = [
+  'convert.m4',
+  'convert_pango.m4',
+  'convert_pangomm.m4',
+]
+m4_files = []
+foreach file : m4_basefiles
+  m4_files += '..' / 'm4' / file
+endforeach
+m4_files = files(m4_files)
+install_m4dir = install_libdir / pangomm_pcname / 'proc' / 'm4'
+install_data(m4_files, install_dir: install_m4dir)
diff --git a/untracked/README b/untracked/README
new file mode 100644
index 0000000..2eeaa8b
--- /dev/null
+++ b/untracked/README
@@ -0,0 +1,36 @@
+untracked/README
+
+This directory contains files not tracked by a source code control program,
+such as git. (This README file is the exception.)
+
+The files can have one of two origins.
+
+1. Copied by the mm-common-get command.
+2. Generated when pangomm is built.
+
+Files of type 2 exist here only if pangomm is built with maintainer-mode=false,
+or the directory comes from a tarball.
+Files of both types exist here only if pangomm is built with Meson,
+or the tarball is created with Meson.
+
+1. Files copied by mm-common-get
+--------------------------------
+untracked/docs/doc-install.pl
+               doc-postprocess.pl
+               doxygen-extra.css
+               tagfile-to-devhelp2.xsl
+untracked/build_scripts/dist-build-scripts.py
+                        dist-changelog.py
+                        doc-reference.py
+                        generate-binding.py
+
+mm-common-get may copy more files, but they are not used by pangomm.
+
+2. Generated files
+------------------
+untracked/pango/pangomm/*.h
+                        *.cc
+                        private/*_p.h
+untracked/docs/reference/pangomm-2.44.devhelp2
+                         pangomm-2.44.tag
+                         html/*


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