[mm-common] meson.build: Specify 'check' option in run_command()



commit dfe1f363170e1182f6eeb2f2589fc80a057ca634
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Sun Feb 6 14:51:07 2022 +0100

    meson.build: Specify 'check' option in run_command()
    
    The default value will be changed in future Meson releases.
    
    Don't use deprecated python3.path() and execute(..., gui_app: ...).
    Let import('python').find_installation() always find the python
    installation used to run Meson.

 meson.build                                | 25 ++++++++++++++++---------
 skeletonmm/doc/reference/meson.build       |  4 ++--
 skeletonmm/examples/meson.build            |  2 +-
 skeletonmm/meson.build                     | 22 ++++++++++++----------
 skeletonmm/skeleton/skeletonmm/meson.build |  5 +++--
 skeletonmm/tests/meson.build               |  1 -
 6 files changed, 34 insertions(+), 25 deletions(-)
---
diff --git a/meson.build b/meson.build
index 71381be..0e6e822 100644
--- a/meson.build
+++ b/meson.build
@@ -2,11 +2,12 @@
 
 project('mm-common',
   version: '1.0.3',
-  meson_version: '>= 0.54.0', # required for meson.override_dependency()
-  license: 'GPLv2+'
+  license: 'GPLv2+',
+  meson_version: '>= 0.55.0', # required for meson.add_dist_script(python3, ...)
+                              # and meson.add_install_script(python3, ...)
 )
 
-python3 = import('python').find_installation('python3')
+python3 = import('python').find_installation()
 python_version = python3.language_version()
 python_version_req = '>= 3.5'
 if not python_version.version_compare(python_version_req)
@@ -113,8 +114,7 @@ configure_file(
 
 if find_program('aclocal', required: false).found()
   meson.add_install_script(
-    python3.path(),
-    script_dir / 'extra-install-cmd.py',
+    python3, script_dir / 'extra-install-cmd.py',
     install_prefix / install_aclocal_macrodir
   )
 endif
@@ -253,7 +253,10 @@ endforeach
 
 # Create tar archive of skeletonmm for installation.
 skeletonmm_tarball_script = script_dir / 'skeletonmm-tarball.py'
-tarball_filetype = run_command(python3, skeletonmm_tarball_script, 'check')
+tarball_filetype = run_command(python3,
+  skeletonmm_tarball_script, 'check',
+  check: true,
+)
 tarball_filename = 'skeletonmm' + tarball_filetype.stdout()
 custom_target(tarball_filename,
   input: skeletonmm_files,
@@ -304,8 +307,7 @@ if not meson.is_subproject() or meson.version().version_compare('>= 0.58.0')
   # Modify the contents of the distribution directory.
   # (not allowed in a subproject if meson.version() < 0.58.0)
   meson.add_dist_script(
-    python3.path(),
-    script_dir / 'extra-dist-cmd.py',
+    python3, script_dir / 'extra-dist-cmd.py',
     project_source_root,
     project_build_root,
   )
@@ -328,7 +330,10 @@ if meson.is_subproject()
 import os
 import sys
 os.chmod(sys.argv[1], 0o755)'''
-  run_command(python3, '-c', cmd_py, project_build_root / 'mm-common-get2')
+  run_command(python3, '-c', cmd_py,
+    project_build_root / 'mm-common-get2',
+    check: true,
+  )
 
   # A main project that looks for mm-common-get shall find mm_common_get2.
   meson.override_find_program('mm-common-get', mm_common_get2)
@@ -339,11 +344,13 @@ os.chmod(sys.argv[1], 0o755)'''
     project_source_root / 'util' / 'build_scripts',
     project_build_root / meson.project_name() / 'build',
     meson_build_support_basefiles,
+    check: true,
   )
   run_command(python3, script_dir / 'copy-files.py',
     project_source_root / 'util',
     project_build_root / meson.project_name() / 'doctool',
     doctool_basefiles,
+    check: true,
   )
 
   mm_common_libstdc_dep = declare_dependency(
diff --git a/skeletonmm/doc/reference/meson.build b/skeletonmm/doc/reference/meson.build
index 2d28a15..4252bf4 100644
--- a/skeletonmm/doc/reference/meson.build
+++ b/skeletonmm/doc/reference/meson.build
@@ -144,7 +144,7 @@ devhelp_file = custom_target('devhelp',
 
 # Install Devhelp file and html files.
 meson.add_install_script(
-  python3.path(), doc_reference, 'install_doc',
+  python3, doc_reference, 'install_doc',
   doctool_dir,
   devhelp_file.full_path(),
   install_devhelpdir,
@@ -155,7 +155,7 @@ meson.add_install_script(
 if can_add_dist_script
   # Distribute built files and files copied by mm-common-prepare.
   meson.add_dist_script(
-    python3.path(), doc_reference, 'dist_doc',
+    python3, doc_reference, 'dist_doc',
     doctool_dir,
     doctool_dist_dir,
     meson.current_build_dir(),
diff --git a/skeletonmm/examples/meson.build b/skeletonmm/examples/meson.build
index e76a99b..514582b 100644
--- a/skeletonmm/examples/meson.build
+++ b/skeletonmm/examples/meson.build
@@ -29,7 +29,7 @@ foreach ex : examples
   exe_file = executable(ex_name, ex_sources, resources,
     dependencies: skeletonmm_own_dep,
     implicit_include_directories: false,
-    gui_app: true,
+    win_subsystem: 'windows',
     build_by_default: build_examples
   )
 endforeach
diff --git a/skeletonmm/meson.build b/skeletonmm/meson.build
index 003697a..c60c9b2 100644
--- a/skeletonmm/meson.build
+++ b/skeletonmm/meson.build
@@ -6,8 +6,7 @@ project('skeletonmm', 'cpp',
   default_options: [
     'cpp_std=c++17'
   ],
-  meson_version: '>= 0.54.0', # required for meson.override_dependency()
-                              # and dep.get_variable(internal:)
+  meson_version: '>= 0.56.0', # required for executable(..., win_subsystem: ...)
 )
 
 skeletonmm_api_version = '1.0'
@@ -42,7 +41,7 @@ macos_darwin_versions = [
 project_source_root = meson.current_source_dir()
 project_build_root = meson.current_build_dir()
 
-python3 = import('python').find_installation('python3')
+python3 = import('python').find_installation()
 python_version = python3.language_version()
 python_version_req = '>= 3.5'
 if not python_version.version_compare(python_version_req)
@@ -56,7 +55,7 @@ import os
 import sys
 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
+is_git_build = run_command(python3, '-c', cmd_py, check: false).returncode() != 0
 
 # Are we testing a dist tarball while it's being built?
 is_dist_check = project_source_root.contains('dist-unpack') and \
@@ -132,25 +131,28 @@ check_dllexport_usage = script_dir / 'check-dllexport-usage.py'
 if maintainer_mode
   # Copy files to untracked/build_scripts and untracked/doc.
   run_command(mm_common_get, '--force', script_dir,
-    project_source_root / 'untracked' / 'doc')
+    project_source_root / 'untracked' / 'doc',
+    check: true,
+  )
 else
   cmd_py = '''
 import os
 import sys
 sys.exit(os.path.isfile("@0@"))
 '''.format(generate_binding)
-  file_exists = run_command(python3, '-c', cmd_py).returncode() != 0
+  file_exists = run_command(python3, '-c', cmd_py, check: false).returncode() != 0
   if not file_exists
     error('Missing files in untracked/. You must enable maintainer-mode.')
   endif
 endif
 
 # Check if perl is required and available.
-# Done now, when the doc_reference script is available.
 doc_perl_prop = run_command(
   python3, doc_reference, 'get_script_property',
   '', # MMDOCTOOLDIR is not used
-  'requires_perl')
+  'requires_perl',
+  check: false,
+)
 doc_requires_perl = true
 if doc_perl_prop.returncode() == 0 and doc_perl_prop.stdout() == 'false'
   doc_requires_perl = false
@@ -191,13 +193,13 @@ subdir('doc/reference')
 if can_add_dist_script
   # Add a ChangeLog file to the distribution directory.
   meson.add_dist_script(
-    python3.path(), dist_changelog,
+    python3, dist_changelog,
     project_source_root,
   )
   # Add build scripts to the distribution directory, and delete .gitignore
   # files and an empty $MESON_PROJECT_DIST_ROOT/build/ directory.
   meson.add_dist_script(
-    python3.path(), dist_build_scripts,
+    python3, dist_build_scripts,
     project_source_root,
     'untracked' / 'build_scripts',
   )
diff --git a/skeletonmm/skeleton/skeletonmm/meson.build b/skeletonmm/skeleton/skeletonmm/meson.build
index a0760b5..60eac50 100644
--- a/skeletonmm/skeleton/skeletonmm/meson.build
+++ b/skeletonmm/skeleton/skeletonmm/meson.build
@@ -129,6 +129,7 @@ else # not maintainer_mode
     meson.current_build_dir(),
     src_untracked_skeletonmm,
     hg_ccg_basenames,
+    check: true,
   )
 
   built_cc_files = [ rel_untracked_skeletonmm / 'wrap_init.cc' ]
@@ -153,7 +154,7 @@ endif
 
 # Install built .h and _p.h files.
 meson.add_install_script(
-  python3.path(), generate_binding, 'install_built_h_files',
+  python3, generate_binding, 'install_built_h_files',
   built_h_cc_dir,
   install_includedir / skeletonmm_pcname / 'skeletonmm', # subdir below {prefix}
   hg_ccg_basenames
@@ -162,7 +163,7 @@ meson.add_install_script(
 if can_add_dist_script
   # Distribute built files.
   meson.add_dist_script(
-    python3.path(), generate_binding, 'dist_built_files',
+    python3, generate_binding, 'dist_built_files',
     built_h_cc_dir,
     untracked_skeletonmm,
     hg_ccg_basenames,
diff --git a/skeletonmm/tests/meson.build b/skeletonmm/tests/meson.build
index 49a5baf..e77edbe 100644
--- a/skeletonmm/tests/meson.build
+++ b/skeletonmm/tests/meson.build
@@ -30,7 +30,6 @@ foreach ex : tests
   exe_file = executable(ex_name, ex_sources, resources,
     dependencies: skeletonmm_own_dep,
     implicit_include_directories: false,
-    gui_app: false,
     build_by_default: true
   )
 


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