[mm-common] meson.build: Make it possible to use mm-common as a subproject
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mm-common] meson.build: Make it possible to use mm-common as a subproject
- Date: Fri, 12 Mar 2021 15:32:19 +0000 (UTC)
commit 5461f51e1f2e8ba55615c233ca41efa16da04005
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Fri Mar 12 16:29:01 2021 +0100
meson.build: Make it possible to use mm-common as a subproject
If mm-common is a subproject, make mm-common-get2 that can be executed
without being installed. The main project is built before the subprojects
have been installed.
Makefile.am | 1 +
meson.build | 47 +++++++++++++++++++++++++++++++++++++++++++-
util/meson_aux/copy-files.py | 33 +++++++++++++++++++++++++++++++
3 files changed, 80 insertions(+), 1 deletion(-)
---
diff --git a/Makefile.am b/Makefile.am
index 3d8762e..c7511bd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -130,6 +130,7 @@ MAINTAINERCLEANFILES = $(dist_doctags_DATA)
EXTRA_DIST = \
meson.build \
meson_options.txt \
+ util/meson_aux/copy-files.py \
util/meson_aux/extra-dist-cmd.py \
util/meson_aux/extra-install-cmd.py \
util/meson_aux/libstdcxx-tag.py \
diff --git a/meson.build b/meson.build
index b89ea25..3f91718 100644
--- a/meson.build
+++ b/meson.build
@@ -2,7 +2,7 @@
project('mm-common',
version: '1.0.2',
- meson_version: '>= 0.50.0', # required for python3.path()
+ meson_version: '>= 0.54.0', # required for meson.override_dependency()
license: 'GPLv2+'
)
@@ -205,6 +205,51 @@ configure_file(
install_dir: install_man1dir
)
+if meson.is_subproject()
+ # A version of mm-common-get that can be executed uninstalled.
+ conf_data_subproj = configuration_data()
+ conf_data_subproj.merge_from(conf_data)
+ conf_data_subproj.set('configure_input', 'mm-common-get2 (for execution uninstalled). Generated from
util/mm-common-get.in')
+ conf_data_subproj.set('datadir_py', project_build_root)
+ mm_common_get2 = configure_file(
+ input: 'util' / 'mm-common-get.in',
+ output: 'mm-common-get2',
+ configuration: conf_data_subproj,
+ install: false,
+ )
+ # Make the uninstalled mm-common-get2 executable.
+ cmd_py = '''
+import os
+import sys
+os.chmod(sys.argv[1], 0o755)'''
+ run_command(python3, '-c', cmd_py, project_build_root / 'mm-common-get2')
+
+ # A main project that looks for mm-common-get shall find mm_common_get2.
+ meson.override_find_program('mm-common-get', mm_common_get2)
+
+ # Copy files needed by mm-common-get2 from source dir to build dir.
+ # The directory structure must be the same as in the installation directory.
+ run_command(python3, script_dir / 'copy-files.py',
+ project_source_root / 'util' / 'build_scripts',
+ project_build_root / meson.project_name() / 'build',
+ meson_build_support_basefiles,
+ )
+ run_command(python3, script_dir / 'copy-files.py',
+ project_source_root / 'util',
+ project_build_root / meson.project_name() / 'doctool',
+ doctool_basefiles,
+ )
+
+ mm_common_libstdc_dep = declare_dependency(
+ variables: {
+ 'doxytagfile': project_build_root / 'libstdc++.tag',
+ 'htmlrefpub': 'http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/'
+ }
+ )
+ # A main project that looks for mm-common-libstdc++.pc shall find mm_common_libstdc_dep.
+ meson.override_dependency('mm-common-libstdc++', mm_common_libstdc_dep)
+endif
+
# Skeleton project.
skeletonmm_basefiles = [
'.gitignore',
diff --git a/util/meson_aux/copy-files.py b/util/meson_aux/copy-files.py
new file mode 100755
index 0000000..b6963e2
--- /dev/null
+++ b/util/meson_aux/copy-files.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+
+# External command, intended to be called with run_command() in meson.build.
+
+# argv[1] argv[2] argv[3:]
+# copy-files.py <from_dir> <to_dir> <file_names>...
+
+import os
+import sys
+import shutil
+
+# <from_dir> is an absolute or relative path of the directory to copy from.
+# <to_dir> is an absolute or relative path of the directory to copy to.
+from_dir_root = sys.argv[1]
+to_dir_root = sys.argv[2]
+
+# Copy some files if they exist in from_dir, but not in the destination
+# directory, or if they are not up to date in the destination directory.
+# (The term "source directory" is avoided here, because from_dir might not
+# be what Meson calls a source directory as opposed to a build directory.)
+
+for file in sys.argv[3:]:
+ from_file = os.path.join(from_dir_root, file)
+ to_file = os.path.join(to_dir_root, file)
+ if os.path.isfile(from_file) and ((not os.path.isfile(to_file))
+ or (os.stat(from_file).st_mtime > os.stat(to_file).st_mtime)):
+
+ # Create the destination directory, if it does not exist.
+ os.makedirs(os.path.dirname(to_file), exist_ok=True)
+
+ # shutil.copy2() copies timestamps and some other file metadata.
+ shutil.copy2(from_file, to_file)
+sys.exit(0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]