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



commit 37e6ef80eb603d51cabc255f40e54ebcc99aed39
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Fri Sep 13 19:16:01 2019 +0200

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

 docs/reference/meson.build | 14 +++++++-------
 meson.build                | 44 +++++++++++++++++++++++++-------------------
 pango/pangomm/meson.build  | 22 +++++++++++-----------
 tools/dist-cmd.py          | 12 ++++++++++++
 tools/dist-cmd.sh          |  9 ---------
 untracked/README           | 16 ++++++++--------
 6 files changed, 63 insertions(+), 54 deletions(-)
---
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
index 783f8a0..161e3d1 100644
--- a/docs/reference/meson.build
+++ b/docs/reference/meson.build
@@ -2,7 +2,7 @@
 
 # Input: built_files_root, project_source_root, pangomm_pcname, perl,
 #        hg_ccg_basenames, extra_h_files, built_file_targets, install_datadir,
-#        dist_cmd_sh
+#        dist_cmd
 # Output: install_docdir, install_devhelpdir
 
 tag_file_modules = [
@@ -89,7 +89,7 @@ if built_file_targets.length() > 0
     input: src_h_files,
     output: book_name + '.tag',
     command: [
-      doc_reference_sh, 'doxygen',
+      doc_reference, 'doxygen',
       doctool_dir,
       '@OUTPUT@',
       built_h_files,
@@ -106,7 +106,7 @@ else
     input: src_h_files + built_h_files,
     output: book_name + '.tag',
     command: [
-      doc_reference_sh, 'doxygen',
+      doc_reference, 'doxygen',
       doctool_dir,
       '@OUTPUT@',
       '@INPUT@',
@@ -121,7 +121,7 @@ devhelp_file = custom_target('devhelp',
   input: tag_file,
   output: book_name + '.devhelp2',
   command: [
-    doc_reference_sh, 'devhelp',
+    doc_reference, 'devhelp',
     doctool_dir,
     '@INPUT@',
     '@OUTPUT@',
@@ -133,7 +133,7 @@ devhelp_file = custom_target('devhelp',
 
 # Install Devhelp file and html files.
 meson.add_install_script(
-  doc_reference_sh, 'install_doc',
+  doc_reference, 'install_doc',
   doctool_dir,
   devhelp_file.full_path(),
   install_devhelpdir,
@@ -157,8 +157,8 @@ 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(
-    dist_cmd_sh,
-    doc_reference_sh, 'dist_doc',
+    dist_cmd,
+    doc_reference, 'dist_doc',
     doctool_dir,
     doctool_dist_dir,
     meson.current_build_dir(),
diff --git a/meson.build b/meson.build
index bf97c66..cd64204 100644
--- a/meson.build
+++ b/meson.build
@@ -37,7 +37,14 @@ project_source_root = meson.current_source_dir()
 project_build_root = meson.current_build_dir()
 
 # Do we build from a git repository?
-is_git_build = run_command('test', '-d', project_source_root / '.git').returncode() == 0
+python = import('python').find_installation('python3')
+cmd_py = 'import os, sys\n' \
+       + 'sys.exit(0 if os.path.isdir("' + (project_source_root/'.git') + '") else 1)\n'
+is_git_build = run_command(python, '-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.
+# Meson requires Python 3.5 or higher.
 
 # Options.
 maintainer_mode_opt = get_option('maintainer-mode')
@@ -72,7 +79,7 @@ pangomm_requires = ' '.join([
 
 # Some dependencies are required only in maintainer mode and/or if
 # reference documentation shall be built.
-mm_common_prepare = find_program('mm-common-prepare', version: '>=0.9.12', required: maintainer_mode)
+mm_common_get = find_program('mm-common-get', version: '>=0.9.12', 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)
@@ -83,17 +90,16 @@ xsltproc = find_program('xsltproc', required: build_documentation)
 gmmproc_dir = glibmm_dep.get_pkgconfig_variable('gmmprocdir')
 
 script_dir = project_source_root / 'untracked' / 'build_scripts'
-generate_binding_sh = script_dir / 'generate-binding.sh'
-doc_reference_sh = script_dir / 'doc-reference.sh'
-dist_changelog_sh = script_dir / 'dist-changelog.sh'
-dist_build_scripts_sh = script_dir / 'dist-build-scripts.sh'
-dist_cmd_sh = project_source_root / 'tools' / 'dist-cmd.sh' # Must be commited to git.
-
-if maintainer_mode and mm_common_prepare.found()
-  # Copy files to untracked/docs and untracked/build_scripts.
-  run_command(mm_common_prepare, '--force', '--copy',
-    '--doctooldir=' + project_source_root / 'untracked' / 'docs',
-    '--buildscriptdir=' + script_dir)
+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')
@@ -101,11 +107,11 @@ cpp_compiler = meson.get_compiler('cpp')
 # Set compiler warnings.
 warning_flags = []
 if warning_level == 'min'
-  warning_flags = [ '-Wall' ]
+  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' ]
+    warning_flags += ['-Werror']
     deprecations = 'G PANGO GLIBMM SIGCXX'.split()
     foreach d : deprecations
       warning_flags += '-D@0@_DISABLE_DEPRECATED'.format(d)
@@ -125,15 +131,15 @@ 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(
-    dist_cmd_sh,
-    dist_changelog_sh,
+    dist_cmd,
+    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(
-    dist_cmd_sh,
-    dist_build_scripts_sh,
+    dist_cmd,
+    dist_build_scripts,
     project_source_root,
     'untracked' / 'build_scripts',
   )
diff --git a/pango/pangomm/meson.build b/pango/pangomm/meson.build
index 5f2177f..fa13a74 100644
--- a/pango/pangomm/meson.build
+++ b/pango/pangomm/meson.build
@@ -1,8 +1,8 @@
 # pango/pangomm
 
 # Input: pangomm_deps, pangomm_pcname, maintainer_mode, project_source_root,
-#        generate_binding_sh, m4_files, pangomm_libversion, install_includedir,
-#        dist_cmd_sh
+#        generate_binding, m4_files, pangomm_libversion, install_includedir,
+#        dist_cmd
 # Output: hg_ccg_basenames, extra_h_files, built_file_targets, built_files_root
 
 defs_basefiles = [
@@ -81,7 +81,7 @@ if maintainer_mode
     input: hg_files,
     output: 'wrap_init.cc',
     command: [
-      generate_binding_sh,
+      generate_binding,
       'generate_wrap_init',
       gmmproc_dir,
       '@OUTPUT@',
@@ -104,7 +104,7 @@ if maintainer_mode
       input: [hg_file, ccg_file],
       output: [file + '.stamp', file + '.cc'],
       command: [
-        generate_binding_sh,
+        generate_binding,
         'gmmproc',
         gmmproc_dir,
         '@OUTPUT0@',
@@ -128,7 +128,7 @@ if maintainer_mode
 
   # Install built .h and _p.h files.
   meson.add_install_script(
-    generate_binding_sh,
+    generate_binding,
     'install_built_h_files',
     meson.current_build_dir(),
     install_includedir / pangomm_pcname / 'pangomm', # subdir below {prefix}
@@ -139,8 +139,8 @@ if maintainer_mode
     # Distribute built files.
     # (add_dist_script() is not allowed in a subproject)
     meson.add_dist_script(
-      dist_cmd_sh,
-      generate_binding_sh, 'dist_built_files',
+      dist_cmd,
+      generate_binding, 'dist_built_files',
       meson.current_build_dir(),
       untracked_pangomm,
       hg_ccg_basenames,
@@ -166,7 +166,7 @@ else # not maintainer_mode
 
   # Try to copy built source code files to the source tree.
   run_command(
-    generate_binding_sh, 'copy_built_files',
+    generate_binding, 'copy_built_files',
     meson.current_build_dir(),
     src_untracked_pangomm,
     hg_ccg_basenames,
@@ -187,7 +187,7 @@ else # not maintainer_mode
 
   # Install built .h and _p.h files.
   meson.add_install_script(
-    generate_binding_sh,
+    generate_binding,
     'install_built_h_files',
     src_untracked_pangomm,
     install_includedir / pangomm_pcname / 'pangomm', # subdir below {prefix}
@@ -198,8 +198,8 @@ else # not maintainer_mode
     # Distribute built files.
     # (add_dist_script() is not allowed in a subproject)
     meson.add_dist_script(
-      dist_cmd_sh,
-      generate_binding_sh, 'dist_built_files',
+      dist_cmd,
+      generate_binding, 'dist_built_files',
       src_untracked_pangomm,
       untracked_pangomm,
       hg_ccg_basenames,
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/untracked/README b/untracked/README
index c788c45..2eeaa8b 100644
--- a/untracked/README
+++ b/untracked/README
@@ -5,7 +5,7 @@ such as git. (This README file is the exception.)
 
 The files can have one of two origins.
 
-1. Copied by the mm-common-prepare command.
+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,
@@ -13,18 +13,18 @@ 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-prepare
-------------------------------------
+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.sh
-                        dist-changelog.sh
-                        doc-reference.sh
-                        generate-binding.sh
+untracked/build_scripts/dist-build-scripts.py
+                        dist-changelog.py
+                        doc-reference.py
+                        generate-binding.py
 
-mm-common-prepare may copy more files, but they are not used by pangomm.
+mm-common-get may copy more files, but they are not used by pangomm.
 
 2. Generated files
 ------------------


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