summaryrefslogtreecommitdiff
path: root/util/mm-common-get.in
blob: e843dd8f6c64512ec203d98999a8f32e7ab3c795 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3

# Copyright (C) 2019 The gtkmm Development Team
#
# @configure_input@
#
# mm-common is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License,
# or (at your option) any later version.
#
# mm-common is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with mm-common.  If not, see <http://www.gnu.org/licenses/>.

import sys
import os
import argparse
import shutil
import filecmp

pkgdatadir = os.path.join('@datadir_py@', '@PACKAGE_TARNAME@')
progname = os.path.basename(sys.argv[0])

parser = argparse.ArgumentParser(
  description='Copy files from mm-common to a C++ binding module that uses Meson')
parser.add_argument('--version', action='version', version='%(prog)s @PACKAGE_VERSION@')
parser.add_argument('-f', '--force', help='replace existing files', action='store_true')
parser.add_argument('buildscript_dir', help='where to store build scripts')
parser.add_argument('doctool_dir', help='where to store doc tool files')
args = parser.parse_args()

forceflag = args.force
buildscriptdir = args.buildscript_dir
doctooldir = args.doctool_dir

print(progname + ': putting Meson build scripts in ' + buildscriptdir)
# Create the destination directory, if it does not exist.
os.makedirs(buildscriptdir, exist_ok=True)
for file in ['check-dllexport-usage.py', 'dist-build-scripts.py', 'dist-changelog.py', 'doc-reference.py', 'generate-binding.py']:
  src_file = os.path.join(pkgdatadir, 'build', file)
  dest_file = os.path.join(buildscriptdir, file)
  # Don't update the timestamp of dest_file, if it's equal to src_file.
  # if file-does-not-exist or (force and files-are-not-equal)
  if (not os.path.isfile(dest_file)) or (forceflag and (not filecmp.cmp(src_file, dest_file))):
    print(progname + ': copying file ' + file)
    # shutil.copy() does not copy timestamps.
    shutil.copy(src_file, dest_file)

print(progname + ': putting documentation utilities in ' + doctooldir)
os.makedirs(doctooldir, exist_ok=True)
for file in ['doc_install.py', 'doc_postprocess.py',
             'doxygen.css', 'doxygen-extra.css', 'tagfile-to-devhelp2.xsl']:
  src_file = os.path.join(pkgdatadir, 'doctool', file)
  dest_file = os.path.join(doctooldir, file)
  if (not os.path.isfile(dest_file)) or (forceflag and (not filecmp.cmp(src_file, dest_file))):
    print(progname + ': copying file ' + file)
    shutil.copy(src_file, dest_file)