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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
import shutil
class Recipe(recipe.Recipe):
name = 'mingw-runtime'
version = '0.1'
licenses = [License.LGPL]
btype = BuildType.CUSTOM
stype = SourceType.CUSTOM
runtime_dep = True
files_libs = ['libstdc++', 'libwinpthread', 'libgomp', 'libgcc_s_sjlj-1']
files_satic = []
files_headers = ['include/GL']
def prepare(self):
if self.config.target_platform != Platform.WINDOWS:
raise InvalidRecipeError(self, "Invalid platform")
# mingw's static libraries
self.mingw_static_files = ['%(host)s/lib/libmingwex.a',
'%(host)s/lib/libdxerr9.a',
'%(host)s/lib/libmoldname.a']
if self.config.platform == Platform.WINDOWS:
self.mingw_static_files += ['%(mingw)s/lib/gcc/%(host)s/4.7.3/libgcc.a']
# static build deps
if self.config.platform == Platform.WINDOWS:
# the native compiler install libraries in 'lib' and
# not in the cross prefix
mingw = '.'
else:
mingw = self.config.host
self.mingw_static_files = [f % {'mingw':mingw, 'host':self.config.host} for f in self.mingw_static_files]
self.files_static = [os.path.join('lib', os.path.basename(f)) for f in self.mingw_static_files]
def install(self):
# Copy libstdc++ to the prefix and update the .la files with the
# the prefix path.
if self.config.platform == Platform.WINDOWS:
# the native compiler install dll's in 'bin' and
# not in the cross prefix
binmingw = 'bin'
libmingw = 'lib'
else:
binmingw = os.path.join(self.config.host, 'lib')
libmingw = os.path.join(self.config.host, 'lib')
# copy the dll
if not os.path.exists(os.path.join(self.config.prefix, 'bin')):
os.makedirs(os.path.join(self.config.prefix, 'bin'))
if not os.path.exists(os.path.join(self.config.prefix, 'lib')):
os.makedirs(os.path.join(self.config.prefix, 'lib'))
for f in ['libwinpthread-1']:
shutil.copy(
os.path.join(self.config.toolchain_prefix, 'bin', f + '.dll'),
os.path.join(self.config.prefix, 'bin', f + '.dll'))
for f in ['libgomp-1', 'libstdc++-6']:
shutil.copy(
os.path.join(self.config.toolchain_prefix, binmingw, f + '.dll'),
os.path.join(self.config.prefix, 'bin', f + '.dll'))
for f in ['libgcc_s_sjlj-1']:
shutil.copy(
os.path.join(self.config.toolchain_prefix, libmingw, f + '.dll'),
os.path.join(self.config.prefix, 'bin', f + '.dll'))
# copy the development libraries
for f in ['libstdc++', 'libgomp']:
# Copy the dll.a
shutil.copy(
os.path.join(self.config.toolchain_prefix, libmingw, f + '.dll.a'),
os.path.join(self.config.prefix, 'lib', f + '.dll.a'))
# Copy and update the .la
src = os.path.join(self.config.toolchain_prefix, libmingw, f + '.la')
dest = os.path.join(self.config.prefix, 'lib', f + '.la')
if os.path.exists(dest):
os.remove(dest)
with open(src, 'r') as f:
content = f.readlines()[:-1]
content.append("libdir='%s'" % os.path.join(self.config.prefix, 'lib'))
with open(dest, 'w+') as d:
d.writelines(content)
# copy winpthreads
for f in ['libpthread', 'libwinpthread']:
shutil.copy(os.path.join(self.config.toolchain_prefix, 'lib', f + '.dll.a'),
os.path.join(self.config.prefix, 'lib', f + '.dll.a'))
shutil.copy(os.path.join(self.config.toolchain_prefix, 'lib', f + '.a'),
os.path.join(self.config.prefix, 'lib', f + '.a'))
src = os.path.join(self.config.toolchain_prefix, 'lib', 'libwinpthread' + '.la')
dest = os.path.join(self.config.prefix, 'lib', f + '.la')
if os.path.exists(dest):
os.remove(dest)
with open(src, 'r') as f:
content = f.readlines()[:-1]
content.append("libdir='%s'" % os.path.join(self.config.prefix, 'lib'))
with open(dest, 'w+') as d:
d.writelines(content)
# install headers and static libraries
for f in self.files_headers:
src = os.path.join(self.config.toolchain_prefix, self.config.host, f)
dest = os.path.join(self.config.prefix, f)
if os.path.exists(dest):
shutil.rmtree(dest)
shutil.copytree(src, dest)
for f in self.mingw_static_files:
out_file = os.path.join('lib', os.path.basename(f))
self.files_static.append(out_file)
shutil.copy(os.path.join(self.config.toolchain_prefix, f),
os.path.join(self.config.prefix, out_file))
|