summaryrefslogtreecommitdiff
path: root/recipes/gnustl.recipe
blob: 7276fe060cde8ed997c6cd9c07077dcd7cbbe3c5 (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
69
70
71
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
import shutil

from cerbero.tools.libtool import LibtoolLibrary
from cerbero.tools.pkgconfig import PkgConfigWritter

class Recipe(recipe.Recipe):
    name = 'gnustl'
    version = '0.1'
    licenses = [License.LGPLv2_1]
    stype = SourceType.CUSTOM
    btype = BuildType.CUSTOM
    runtime_dep = True

    files_stl = [
            'lib/libgnustl.so']
    files_devel= [
            'lib/pkgconfig/gnustl.pc',
            'lib/libgnustl.la',
            'lib/libgnustl.a',
            'lib/libsupc++.a',
            ]

    def prepare(self):
        if self.config.target_platform != Platform.ANDROID:
            raise InvalidRecipeError(self, "Invalid platform")

    def install(self):
        stl_prefix = os.path.join(self.config.toolchain_prefix, 'sources',
                  'cxx-stl', 'gnu-libstdc++', self.config.toolchain_version)
        if self.config.target_arch == Architecture.X86:
            stl_libdir = os.path.join(stl_prefix, 'libs', 'x86')
        elif self.config.target_arch == Architecture.X86_64:
            stl_libdir = os.path.join(stl_prefix, 'libs', 'x86_64')
        elif self.config.target_arch == Architecture.ARMv7:
            stl_libdir = os.path.join(stl_prefix, 'libs', 'armeabi-v7a')
        elif self.config.target_arch == Architecture.ARM64:
            stl_libdir = os.path.join(stl_prefix, 'libs', 'arm64-v8a')
        elif self.config.target_arch == Architecture.ARM:
            stl_libdir = os.path.join(stl_prefix, 'libs', 'armeabi')
        else:
            raise FatalError("Unsupported Android architecture %s" % self.config.target_arch)
        libdir = os.path.join(self.config.prefix, 'lib')
        if not os.path.exists(libdir):
            os.makedirs(libdir)

        # Copies libraries to the prefix
        shutil.copy(os.path.join(stl_libdir, 'libgnustl_shared.so'),
                    os.path.join(libdir, 'libgnustl.so'))
        shutil.copy(os.path.join(stl_libdir, 'libgnustl_static.a'),
                    os.path.join(libdir, 'libgnustl.a'))
        shutil.copy(os.path.join(stl_libdir, 'libsupc++.a'),
                    os.path.join(libdir, 'libsupc++.a'))


        # Create a libtool library for gnustl (libgnustl.la)
        lib = LibtoolLibrary('gnustl', None, None, None, libdir,
                self.config.target_platform)
        lib.change_value('dependency_libs', ' -lstdc++')
        lib.save()

        # Create pkg-config file (gnustl.pc)
        pkgdir = os.path.join(self.config.prefix, 'lib', 'pkgconfig')
        if not os.path.exists(pkgdir):
            os.makedirs(pkgdir)
        stl_pc = PkgConfigWritter('gnustl', 'gnustl', '1.0',
                '', '-L${libdir} -lgnustl -lsupc++ -lstdc++ ',
                '-I%s/include -I%s/libs/armeabi/include' % (stl_prefix, stl_prefix), self.config.prefix)
        stl_pc.libs_priv = '${libdir}/libgnustl.a ${libdir}/libsupc++.a'
        stl_pc.rel_incldir = 'include'
        stl_pc.save('gnustl', pkgdir)