summaryrefslogtreecommitdiff
path: root/recipes/gnustl.recipe
blob: e07ff4eb55fb5bc8884ff7b5888ddfec8deb68f9 (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
# -*- 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

    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()

    def install(self):
        stl_prefix = os.path.join(self.config.toolchain_prefix, 'sources',
                'cxx-stl', 'gnu-libstdc++', '4.6')
        if self.config.target_arch == Architecture.X86:
            stl_libdir = os.path.join(stl_prefix, 'libs', 'x86')
        elif self.config.target_arch == Architecture.ARMv7:
            stl_libdir = os.path.join(stl_prefix, 'libs', 'armeabi-v7a')
        else:
            stl_libdir = os.path.join(stl_prefix, 'libs', 'armeabi')
        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)