34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
#!/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:])
|