summaryrefslogtreecommitdiff
path: root/recipes/librsvg.recipe
blob: 2ec8a2b3fd8891e04df933c545a991299a96a7c6 (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
63
64
65
66
67
68
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
from pathlib import Path

from cerbero.build.build import modify_environment


class Recipe(recipe.Recipe):
    name = 'librsvg'
    version = '2.40.20'
    licenses = [License.LGPLv2Plus]
    deps = ['libcroco', 'gdk-pixbuf', 'pango', 'cairo']
    stype = SourceType.TARBALL
    url = 'gnome://'
    tarball_checksum = 'cff4dd3c3b78bfe99d8fcfad3b8ba1eee3289a0823c0e118d78106be6b84c92b'
    configure_options = ' --disable-always-build-tests --disable-tools '

    files_libs = ['librsvg-2']
    files_bins = ['rsvg-convert']
    licenses_bins = [License.GPLv2Plus]
    files_loader = ['%(libdir)s/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg%(mext)s']
    files_devel = ['include/librsvg-2.0/librsvg/*.h',
                   '%(libdir)s/pkgconfig/librsvg-2.0.pc',
                   '%(libdir)s/librsvg-2.a', '%(libdir)s/librsvg-2.la']
    files_typelibs = ['Rsvg-2.0']

    patches = [
        f'{name}/0001-build-Fix-enumtypes-on-MinGW-inside-MSYS-Windows.patch',
        f'{name}/0004-Add-missing-libcroco-dependency.patch',
    ]

    def prepare(self):
        if self.config.target_platform in [Platform.DARWIN, Platform.IOS]:
            self.configure_options += ' --disable-Bsymbolic'
        # Fails on cross-ios and cross-win32
        if self.config.cross_compiling():
            self.configure_options += ' --disable-pixbuf-loader'
            self.files_loader.clear()

        if self.config.platform != Platform.WINDOWS:
            # GTK3 support just builds rsvg-view-3, which is useless for Cerbero
            self.configure_options += ' --without-gtk3 '
            self.autoreconf = True
            self.autoreconf_sh = 'mkdir -p m4 && autoreconf -fiv'
            self.patches += [
                'librsvg/option-enable-disable-gtk.patch',
                'librsvg/0001-Use-ACLOCAL_FLAGS.patch',
            ]
        else:
            self.autoreconf = False
        if self.config.platform == Platform.WINDOWS:
            # MSYS2 does not add . to PATH, so we need to add this ourselves
            # so that our python3 wrapper script is found"
            self.prepend_env('PATH', self.make_dir, sep=os.pathsep)


    @modify_environment
    async def compile(self):
        # glib-mkenums has #!/usr/bin/env python3, which looks for `python3`,
        # but on Windows Python 3 is `python.exe`. Meson already handles this
        # for us, but Autotools can't.
        # NOTE: Remove this when the recipe is ported to Meson.
        if self.config.platform == Platform.WINDOWS:
            python3 = Path(self.build_dir) / 'python3'
            with python3.open('w') as f:
                f.write('#!/bin/sh\n"{}" "$@"'.format(self.config.python_exe))
            shell.new_call(['chmod', '+x', str(python3)])

        await super().compile()