summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjellahlstedt@gmail.com>2021-03-12 16:29:01 +0100
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2021-03-12 16:29:01 +0100
commit5461f51e1f2e8ba55615c233ca41efa16da04005 (patch)
treeb22ea38bad3fc248afe9ca2806c2163116347631 /util
parent62bf2765cf7eea7a74d083a36376f43ab01a5604 (diff)
downloadmm-common-5461f51e1f2e8ba55615c233ca41efa16da04005.tar.gz
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.
Diffstat (limited to 'util')
-rwxr-xr-xutil/meson_aux/copy-files.py33
1 files changed, 33 insertions, 0 deletions
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)