summaryrefslogtreecommitdiff
path: root/subprojects/dbus-gmain/tests/use-as-subproject.py
blob: 3f45c5b808f34ab30a4ecba1cb6aa8670a348232 (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
#!/usr/bin/env python3
# Copyright 2022 Collabora Ltd.
# SPDX-License-Identifier: MIT

import os
import shutil
import subprocess
import tempfile

HERE = os.path.dirname(os.path.abspath(__file__))

if __name__ == '__main__':
    if shutil.which('meson') is None:
        print('SKIP: meson not found in PATH')
        raise SystemExit(0)

    with tempfile.TemporaryDirectory() as temp:
        shutil.copytree(
            os.path.join(HERE, 'use-as-subproject'),
            os.path.join(temp, 'src'),
        )
        os.makedirs(os.path.join(temp, 'src', 'subprojects'), exist_ok=True)
        os.symlink(
            os.path.dirname(HERE),
            os.path.join(temp, 'src', 'subprojects', 'dbus-gmain'),
        )
        subprocess.run(
            ['meson', os.path.join(temp, 'src'), os.path.join(temp, 'build')],
            check=True,
        )
        subprocess.run(
            ['meson', 'compile', '-C', os.path.join(temp, 'build')],
            check=True,
        )