summaryrefslogtreecommitdiff
path: root/recipes/build-tools/meson.recipe
blob: 584cc8ae03f15e364aecb56539901f5c1bb2b63a (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
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python

import glob
import shutil
from pathlib import PurePath

class Recipe(recipe.Recipe):
    name = 'meson'
    version = '1.3.1'
    licenses = [License.Apachev2]
    btype = BuildType.CUSTOM

    meson_commit = os.environ.get('MESON_COMMIT')
    if meson_commit:
        stype = SourceType.GIT
        remotes = {'origin': 'https://github.com/mesonbuild/meson.git'}
        commit = meson_commit
    else:
        stype = SourceType.TARBALL
        url = 'https://github.com/mesonbuild/meson/releases/download/%(version)s/meson-%(version)s.tar.gz'
        tarball_checksum = '6020568bdede1643d4fb41e28215be38eff5d52da28ac7d125457c59e0032ad7'

    files_bin = ['bin/meson']
    files_python = []

    async def install(self):
        # setup.py barfs if using posix paths on Windows
        if self.config.platform == Platform.WINDOWS:
            prefix = str(PurePath(self.config.prefix))
        else:
            prefix = self.config.prefix
        # Some distros have changed the default sysconfig scheme to
        # manually add 'local' to all install dirs for setuptools.
        # Reverting this is far too much work and will be fragile as heck,
        # so just accept it and move on.
        # Fedora: https://src.fedoraproject.org/rpms/python3.10/blob/f36/f/00251-change-user-install-location.patch
        # Debian: https://salsa.debian.org/cpython-team/python3/-/blob/3.10.4-4/debian/patches/sysconfig-debian-schemes.diff
        #
        # Our workaround is to only install the script into bin. This also
        # fixes things on Windows, where the script is installed into Scripts/
        # instead of bin/
        await shell.async_call([self.config.python_exe, '-m', 'pip', 'install', '--prefix', prefix, '.'],
                               cmd_dir=self.build_dir, env=self.env, logfile=self.logfile)
        if self.config.platform == Platform.WINDOWS:
            # Python insists on using Scripts instead of bin on Windows for
            # scripts. Insist back, and use bin again.
            scriptsdir = os.path.join(prefix, 'Scripts')
            bindir = os.path.join(prefix, 'bin')
            os.makedirs(bindir, exist_ok=True)
            for f in glob.glob('*', root_dir=scriptsdir):
                tof = os.path.join(bindir, f)
                if os.path.isfile(tof):
                    os.remove(tof)
                shutil.move(os.path.join(scriptsdir, f), tof)
            os.rmdir(scriptsdir)