diff options
author | Thiago Santos <thiago.sousa.santos@collabora.com> | 2013-03-04 09:06:18 -0300 |
---|---|---|
committer | Thiago Santos <thiago.sousa.santos@collabora.com> | 2013-03-07 16:02:42 -0300 |
commit | d10159f0218a729eab279c94a9e1142e826d41d3 (patch) | |
tree | 0ef395fc0dfea7796128878a5eae564b8b127a5c | |
parent | 6f0278e84d1943af57fec9feacd002e47033bd78 (diff) |
ide: xcode: frameworks: crate dynamic and static framework lib creator classes
Split the apple's framework creation class into 2 subclasses for creating
dynamic and static frameworks.
The dynamic one is used of OSX packaging, the static should be used for
iOS
-rw-r--r-- | cerbero/ide/xcode/fwlib.py | 36 | ||||
-rw-r--r-- | recipes/gstreamer-osx-framework.recipe | 4 |
2 files changed, 37 insertions, 3 deletions
diff --git a/cerbero/ide/xcode/fwlib.py b/cerbero/ide/xcode/fwlib.py index 2d2d6b3..a81c535 100644 --- a/cerbero/ide/xcode/fwlib.py +++ b/cerbero/ide/xcode/fwlib.py @@ -18,6 +18,8 @@ # Boston, MA 02111-1307, USA. import os +import tempfile +import shutil from cerbero.config import Architecture from cerbero.ide.pkgconfig import PkgConfig @@ -47,7 +49,7 @@ class FrameworkLibrary(object): libspaths = [] for lib in libs: for libdir in libdirs: - libpath = os.path.join(libdir, 'lib%s.dylib' % lib) + libpath = os.path.join(libdir, self._get_lib_file_name (lib)) if not os.path.exists(libpath): continue libspaths.append(os.path.realpath(libpath)) @@ -55,8 +57,40 @@ class FrameworkLibrary(object): return libspaths def _create_framework_library(self, libname, install_name, libraries, arch): + raise NotImplemented + + def _get_lib_file_name(self, lib): + return lib + + +class DynamicFrameworkLibrary(FrameworkLibrary): + def _create_framework_library(self, libname, install_name, libraries, arch): + extra_options = self._get_create_framework_options (libname) libraries = ' '.join(['-Wl,-reexport_library %s' % x for x in libraries]) shell.call('gcc -dynamiclib -o %s -arch %s -install_name %s %s' % (libname, arch, install_name, libraries)) + def _get_lib_file_name(self, lib): + return 'lib%s.dylib' % lib + +class StaticFrameworkLibrary(FrameworkLibrary): + def _get_lib_file_name(self, lib): + return 'lib%s.a' % lib + + def _create_framework_library(self, libname, install_name, libraries, arch): + tmpdir = tempfile.mkdtemp() + + for lib in libraries: + libprefix = os.path.split(lib)[-1].replace('.', '_') + lib_tmpdir = tempfile.mkdtemp() + shutil.copy(lib, lib_tmpdir) + + tmplib = os.path.join(lib_tmpdir, os.path.basename(lib)) + shell.call('ar -x %s' % tmplib, lib_tmpdir) + + obj_files = shell.ls_files(['*.o'], lib_tmpdir) + for obj_f in obj_files: + shell.call('cp %s %s' % (os.path.join(lib_tmpdir, obj_f), '%s-%s' % (libprefix, obj_f)), tmpdir) + shell.call('ar -cqS %s %s-%s' % (libname, libprefix, obj_f), tmpdir) + shell.call('ar -s %s' % (libname), tmpdir) diff --git a/recipes/gstreamer-osx-framework.recipe b/recipes/gstreamer-osx-framework.recipe index 21b98bd..de6fa0f 100644 --- a/recipes/gstreamer-osx-framework.recipe +++ b/recipes/gstreamer-osx-framework.recipe @@ -1,6 +1,6 @@ # -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python -from cerbero.ide.xcode.fwlib import FrameworkLibrary +from cerbero.ide.xcode.fwlib import DynamicFrameworkLibrary class Recipe(recipe.Recipe): name = 'gstreamer-osx-framework' @@ -13,7 +13,7 @@ class Recipe(recipe.Recipe): files_library = ['lib/GStreamer'] def install(self): - fwlib = FrameworkLibrary() + fwlib = DynamicFrameworkLibrary() install_name = os.path.join(self.config.prefix, 'lib', 'GStreamer') libs = ['gstreamer-0.10', 'gstreamer-app-0.10', 'gstreamer-audio-0.10', 'gstreamer-base-0.10', 'gstreamer-cdda-0.10', |