From 5461f51e1f2e8ba55615c233ca41efa16da04005 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 12 Mar 2021 16:29:01 +0100 Subject: 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. --- util/meson_aux/copy-files.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 util/meson_aux/copy-files.py (limited to 'util') 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 ... + +import os +import sys +import shutil + +# is an absolute or relative path of the directory to copy from. +# 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) -- cgit v1.2.1