summaryrefslogtreecommitdiff
path: root/recipes/toolchain/gcc.recipe
blob: 902de4e449716ff1087ba247180f4a32cf0b2b54 (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
72
73
74
75
76
77
78
79
80
81
import shutil

class Recipe(recipe.Recipe):
    name = 'gcc'
    version = '4.7.2'
    licenses = [License.GPLv3]
    supports_non_src_build = True
    stype = SourceType.CUSTOM
    deps = ['mingw-w64', 'winpthreads']

    files_bins = ['gcc', 'cpp', 'gcov', 'jcf-dump', 'c++', 'gcj', 'g++',
                 'gcc-4.7.2', 'gfortran']
    files_gcc = ['%(host)s/include/c++',
                 '%(host)s/bin/c++%(bext)s',
                 '%(host)s/bin/g++%(bext)s',
                 '%(host)s/bin/gfortran%(bext)s',
                 '%(host)s/bin/gcc%(bext)s',
                 '%(host)s/lib/libobjc.a',
                 '%(host)s/lib/libobjc-3.dll',
                 '%(host)s/lib/libquadmath-0.dll',
                 '%(host)s/lib/libssp.a',
                 '%(host)s/lib/libquadmath.dll.a',
                 '%(host)s/lib/libgfortran-3.dll',
                 '%(host)s/lib/libgfortran.dll.a',
                 '%(host)s/lib/libgfortran.la',
                 '%(host)s/lib/libstdc++.dll.a-gdb.py',
                 '%(host)s/lib/libssp.la',
                 '%(host)s/lib/libobjc.la',
                 '%(host)s/lib/libssp.dll.a',
                 '%(host)s/lib/libssp_nonshared.a',
                 '%(host)s/lib/libgcc_s_sjlj-1.dll',
                 '%(host)s/lib/libstdc++-6.dll',
                 '%(host)s/lib/libgfortran.spec',
                 '%(host)s/lib/libstdc++.dll.a',
                 '%(host)s/lib/libstdc++.a',
                 '%(host)s/lib/libquadmath.a',
                 '%(host)s/lib/libsupc++.a',
                 '%(host)s/lib/libssp-0.dll',
                 '%(host)s/lib/libssp_nonshared.la',
                 '%(host)s/lib/libquadmath.la',
                 '%(host)s/lib/libgfortran.a',
                 '%(host)s/lib/libgcc_s.a',
                 '%(host)s/lib/libstdc++.la',
                 '%(host)s/lib/libobjc.dll.a',
                 '%(host)s/lib/libsupc++.la',
                 'lib/libiberty.a',
            ]
    files_lib_gcc = ['lib/gcc/%(host)s/4.7.2',
                     'libexec/gcc/%(host)s/4.7.2']
    files_lang = ['gcc', 'cpplib']

    def configure(self):
        pass
    def do_make(self):
        pass

    def prepare(self):
        self._remove_steps([BuildSteps.CONFIGURE])
        if self.config.target_arch == Architecture.X86:
            self._host = 'i686-w64-mingw32'
        else:
            self._host = 'x86_64-w64-mingw32'
        # Append the host prefix to the binaries
        self.files_bins = ['%s-%s' % (self._host, x) for x in self.files_bins]
        # Replace host in files
        files = [x % {'host': self._host, 'bext': '%(bext)s'} for x in self.files_gcc]
        # Add mingw symlink files
        files.extend([x % {'host': 'mingw', 'bext': '%(bext)s'} for x in self.files_gcc])
        self.files_gcc = files
        # Replace host in lib/gcc and libexec/gcc
        self.files_lib_gcc = [x % {'host': self._host} for x in self.files_lib_gcc]
        # Add mingw symlink files
        self.files_lib_gcc.extend([x % {'host': 'mingw'} for x in self.files_lib_gcc])

    def post_install(self):
        if self.config.target_platform == Platform.WINDOWS:
            cpp = os.path.join(self.config.prefix, 'bin', 'cpp.exe')
            prefixed_cpp = os.path.join(self.config.prefix, 'bin', '%s-cpp.exe' % self._host)
            if os.path.exists(prefixed_cpp):
                os.remove(prefixed_cpp)
            shutil.move(cpp, prefixed_cpp)