summaryrefslogtreecommitdiff
path: root/recipes/fontconfig.recipe
blob: 82eaa557511dc183bb4fe6e96d534a5dafc669e1 (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
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
import os
import shutil
from cerbero.tools.libtool import LibtoolLibrary
from cerbero.tools.libtool import get_libtool_versions

class Recipe(recipe.Recipe):
    name = 'fontconfig'
    version = '2.14.1'
    stype = SourceType.TARBALL
    url = 'https://www.freedesktop.org/software/fontconfig/release/fontconfig-%(version)s.tar.xz'
    tarball_checksum = '298e883f6e11d2c5e6d53c8a8394de58d563902cfab934e6be12fb5a5f361ef0'
    licenses = [{License.MIT: ['COPYING']}]
    btype = BuildType.MESON
    meson_options = {'doc': 'disabled', 'tests': 'disabled', 'tools': 'disabled'}
    deps = ['expat', 'freetype', 'zlib', 'bzip2']
    patches = [
        # Proper fix is pending, upstream issue is:
        # https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/247
        'fontconfig/0001-fcobjs-Remove-duplicate-function-prototypes.patch',
        # https://gitlab.freedesktop.org/fontconfig/fontconfig/-/merge_requests/283
        'fontconfig/0001-meson-Always-write-utf-8-files-with-LF-newlines.patch',
    ]

    files_libs = ['libfontconfig']
    files_etc = [
        'etc/fonts/conf.d',
        'etc/fonts/fonts.conf',
        'share/fontconfig'
        ]
    files_devel = ['%(libdir)s/pkgconfig/fontconfig.pc', 'include/fontconfig']


    def prepare(self):
        if self.config.target_platform in (Platform.WINDOWS, Platform.ANDROID):
            self.deps.append('libiconv')

    def post_install(self):
        # Meson does not generate la files
        major, minor, micro = get_libtool_versions(self.version)
        libtool_la = LibtoolLibrary('fontconfig', major, minor, micro,
                                    self.config.libdir, self.config.target_platform,
                                    deps=['expat', 'freetype', 'bz2', 'z'])
        libtool_la.save()
        # Either make symlinks relative, or convert to a copy to prevent
        # breakage during packaging
        confddir = os.path.join(self.config.prefix, 'etc', 'fonts', 'conf.d')
        confsrc = os.path.join(self.config.prefix, 'share', 'fontconfig', 'conf.avail')
        linksrc = os.path.join('..', '..', '..', 'share', 'fontconfig', 'conf.avail')
        for f in os.listdir(confddir):
            if not f.endswith('.conf'):
                continue
            os.remove(os.path.join(confddir, f))
            if self.config.platform == Platform.WINDOWS:
                # We sometimes get broken symlinks on Windows, so just make it a copy
                shutil.copyfile(os.path.join(confsrc, f), os.path.join(confddir, f))
            else:
                os.symlink(os.path.join(linksrc, f), os.path.join(confddir, f))
        super().post_install()