aboutsummaryrefslogtreecommitdiff
path: root/src/tools/install_test_files
blob: 8e0b36a74d189824c56027545eb93bc79558a4ec (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
#!/usr/bin/env python3

# Helper to install additional files into the temporary installation
# for tests, beyond those that are installed by meson/ninja install.

import argparse
import shutil
import os
from pathlib import PurePath

parser = argparse.ArgumentParser()

parser.add_argument('--destdir', type=str, default=os.environ.get('DESTDIR', None))
parser.add_argument('--prefix', type=str)
parser.add_argument('--install', type=str, nargs='+', action='append')

args = parser.parse_args()

def copy_files(prefix: str, destdir: str, targetdir: str, src_list: list):
    if not os.path.isabs(targetdir):
        targetdir = os.path.join(prefix, targetdir)

    if destdir is not None:
        # copy of meson's logic for joining destdir and install paths
        targetdir = str(PurePath(destdir, *PurePath(targetdir).parts[1:]))

    os.makedirs(targetdir, exist_ok=True)

    for src in src_list:
        shutil.copy2(src, targetdir)

for installs in args.install:
    copy_files(args.prefix, args.destdir, installs[0], installs[1:])