summaryrefslogtreecommitdiff
path: root/recipes/mingw-runtime.recipe
diff options
context:
space:
mode:
authorAndoni Morales Alastruey <ylatuya@gmail.com>2013-05-12 15:03:48 +0200
committerAndoni Morales Alastruey <ylatuya@gmail.com>2013-05-27 10:02:39 +0200
commit09e99e31c396afd289cb34e3862f55ef48907004 (patch)
treed9219d40f2146250f62a3cad0f46d1df78bcacfa /recipes/mingw-runtime.recipe
parentb6adfcc23627269f903cf7268c33501d921ceb5f (diff)
mingw: put all the runtime deps into single recipe
Diffstat (limited to 'recipes/mingw-runtime.recipe')
-rw-r--r--recipes/mingw-runtime.recipe96
1 files changed, 96 insertions, 0 deletions
diff --git a/recipes/mingw-runtime.recipe b/recipes/mingw-runtime.recipe
new file mode 100644
index 00000000..2954e18c
--- /dev/null
+++ b/recipes/mingw-runtime.recipe
@@ -0,0 +1,96 @@
+# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
+import shutil
+from cerbero.errors import InvalidRecipeError
+
+
+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']
+ files_satic = []
+ files_headers = ['include/GL']
+
+ def prepare(self):
+ if self.config.target_platform != Platform.WINDOWS:
+ raise InvalidRecipeError()
+ # 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
+ for f in ['libstdc++-6', 'libgomp-1', 'libgcc_s_sjlj-1']:
+ shutil.copy(
+ os.path.join(self.config.toolchain_prefix, binmingw, 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))