[pangomm/pangomm-2-42] Meson build: Set default value of the 'warnings' option to 'min'



commit 00c83e4d3cca81fa09c5cab13fff62e9652b2bf9
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Tue Apr 7 15:57:08 2020 +0200

    Meson build: Set default value of the 'warnings' option to 'min'
    
    And add 'dist-warnings' with default value 'fatal'. It's used when a
    tarball is tested by 'ninja dist' or 'meson dist'.
    https://mail.gnome.org/archives/gtkmm-list/2020-March/msg00025.html
    
    Add a better error message if mm-common-get is required but not found.

 docs/reference/meson.build |  2 +-
 meson.build                | 20 +++++++++++++++++---
 meson_options.txt          |  8 +++++---
 3 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
index de7476d..d0e25dc 100644
--- a/docs/reference/meson.build
+++ b/docs/reference/meson.build
@@ -148,7 +148,7 @@ 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.
+  # Distribute built files and files copied by mm-common-get.
   # (add_dist_script() is not allowed in a subproject)
   meson.add_dist_script(
     python3.path(), doc_reference_py, 'dist_doc',
diff --git a/meson.build b/meson.build
index efeef25..1951172 100644
--- a/meson.build
+++ b/meson.build
@@ -55,11 +55,22 @@ sys.exit(os.path.isdir("@0@") or os.path.isfile("@0@"))
 '''.format(project_source_root / '.git')
 is_git_build = run_command(python3, '-c', cmd_py).returncode() != 0
 
+# Are we testing a dist tarball while it's being built?
+# There ought to be a better way. https://github.com/mesonbuild/meson/issues/6866
+is_dist_check = project_source_root.contains('dist-unpack') and \
+                project_build_root.contains('dist-build')
+
 # 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')
+if is_dist_check
+  message('Looks like a tarball is being tested. ' + \
+  'Option "dist-warnings" is used instead of "warnings".')
+  warning_level = get_option('dist-warnings')
+else
+  warning_level = get_option('warnings')
+endif
 build_deprecated_api = get_option('build-deprecated-api')
 build_documentation_opt = get_option('build-documentation')
 build_documentation = build_documentation_opt == 'true' or \
@@ -193,7 +204,10 @@ endif
 
 # 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)
+mm_common_get = find_program('mm-common-get', required: false)
+if maintainer_mode and not mm_common_get.found()
+  error('mm-common-get not found. mm-common >= 1.0.0 is required.')
+endif
 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)
@@ -208,7 +222,7 @@ dist_changelog_py = script_dir / 'dist-changelog.py'
 dist_build_scripts_py = script_dir / 'dist-build-scripts.py'
 check_dllexport_usage_py = script_dir / 'check-dllexport-usage.py'
 
-if maintainer_mode and mm_common_get.found()
+if maintainer_mode
   # Copy files to untracked/build_scripts and untracked/docs.
   run_command(mm_common_get, '--force', script_dir,
     project_source_root / 'untracked' / 'docs')
diff --git a/meson_options.txt b/meson_options.txt
index e137e93..0a88938 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,10 +1,12 @@
 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',
+option('warnings', type: 'combo', choices: ['no', 'min', 'max', 'fatal'], value: 'min',
   description: 'Compiler warning level')
+option('dist-warnings', type: 'combo', choices: ['no', 'min', 'max', 'fatal'], value: 'fatal',
+  description: 'Compiler warning level when a tarball is created')
 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')
-option('gmmproc-dir', type : 'string',
-  value : '', description : 'Directory containing gmmproc and its PERL modules (for MSVC builds only)')
+option('gmmproc-dir', type: 'string', value: '',
+  description: 'Directory containing gmmproc and its PERL modules (for MSVC builds only)')


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