diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2016-08-25 14:06:21 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2016-08-25 14:06:21 +0300 |
commit | 420637a01eeb99c38af47865553ccbd22bca4050 (patch) | |
tree | e0694a6b56a13819ce98a762f31a97589f6e372e | |
parent | 8585dcde12bdcf395a0f1717cc60574681013b3a (diff) |
Revert "LibtoolLibrary: Auto-detect libraries and versions"
This reverts commit 40779ea8eb0ead12ad8de19021adc94d272f3d7a.
It only works on Linux right now and was not meant to be merged yet.
-rw-r--r-- | cerbero/tools/libtool.py | 94 | ||||
-rw-r--r-- | recipes/bzip2.recipe | 11 | ||||
-rw-r--r-- | recipes/gnustl.recipe | 5 | ||||
-rw-r--r-- | recipes/gst-libav-1.0-static.recipe | 4 | ||||
-rw-r--r-- | recipes/librtmp/librtmp.recipe | 5 | ||||
-rw-r--r-- | recipes/libsrtp.recipe | 3 | ||||
-rw-r--r-- | recipes/nettle/nettle.recipe | 4 | ||||
-rw-r--r-- | recipes/openh264.recipe | 2 | ||||
-rw-r--r-- | recipes/stlport.recipe | 5 | ||||
-rw-r--r-- | recipes/taglib.recipe | 5 | ||||
-rw-r--r-- | recipes/x264.recipe | 2 | ||||
-rw-r--r-- | recipes/zlib.recipe | 2 |
12 files changed, 65 insertions, 77 deletions
diff --git a/cerbero/tools/libtool.py b/cerbero/tools/libtool.py index 60255e39..152ff072 100644 --- a/cerbero/tools/libtool.py +++ b/cerbero/tools/libtool.py @@ -17,11 +17,9 @@ # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. -import re import os from cerbero.config import Platform -from cerbero.build.filesprovider import find_shlib_regex, FilesProvider -from cerbero.errors import FatalError + class LibtoolLibrary(object): ''' @@ -29,7 +27,7 @@ class LibtoolLibrary(object): ''' LIBTOOL_TPL = '''\ -# %(laname)s - a libtool library file +# %(libname)s - a libtool library file # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 # # Please DO NOT delete this file! @@ -53,7 +51,7 @@ dependency_libs='%(dependency_libs)s' # Names of additional weak libraries provided by this library weak_library_names='' -# Version information for %(libname)s. +# Version information for libglib-2.0. current=%(current)s age=%(age)s revision=%(revision)s @@ -72,10 +70,10 @@ dlpreopen='' libdir='%(libdir)s' ''' - def __init__(self, libname, libdir, platform, deps=None): + def __init__(self, libname, major, minor, micro, libdir, platform, + deps=None): self.libtool_vars = { 'libname': '', - 'laname': '', 'dlname': '', 'library_names': '', 'old_library': '', @@ -85,64 +83,48 @@ libdir='%(libdir)s' 'revision': '', 'libdir': ''} + if platform == Platform.WINDOWS: + shared_ext = 'dll.a' + elif platform in [Platform.DARWIN, Platform.IOS]: + shared_ext = 'dylib' + else: + shared_ext = 'so' + + if not libname.startswith('lib'): + libname = 'lib%s' % libname if deps is None: deps = '' self.libname = libname self.libdir = libdir - self.laname = 'lib{}.la'.format(libname) - - regex = FilesProvider.EXTENSIONS[platform]['sregex'] - regex = regex.format(re.escape(self.libname)) - # Find shared libraries - shlibs = self._find_shlibs(regex, platform) - # libfoo.so.2 or libfoo.so (if no versioning at all) - try: - dlname = shlibs[-2] or shlibs[-1] - except IndexError: - # No shared library was installed by the recipe - dlname = '' - # Auto-detect major/minor/micro versions - major, minor, micro = self._autodetect_versions(regex, shlibs) - old_library = 'lib{}.a'.format(libname) - self.change_value('laname', self.laname) - self.change_value('libname', 'lib' + self.libname) + self.laname = '%s.la' % libname + dlname_base = '%s.%s' % (libname, shared_ext) + dlname = dlname_base + dlname_all = dlname_base + major_str = '' + minor_str = '' + micro_str = '' + + if major is not None: + dlname = '%s.%s' % (dlname_base, major) + major_str = major + if minor is not None: + dlname_all = '%s.%s' % (dlname, minor) + minor_str = minor + if micro is not None: + dlname_all = '%s.%s' % (dlname_all, micro) + micro_str = micro + old_library = '%s.a' % libname + self.change_value('libname', self.laname) self.change_value('dlname', dlname) - self.change_value('library_names', ' '.join(shlibs)) + self.change_value('library_names', '%s %s %s' % (dlname_all, dlname, + dlname_base)) self.change_value('old_library', old_library) - self.change_value('current', minor) - self.change_value('age', minor) - self.change_value('revision', micro) + self.change_value('current', minor_str) + self.change_value('age', minor_str) + self.change_value('revision', micro_str) self.change_value('libdir', libdir) self.change_value('dependency_libs', self._parse_deps(deps)) - def _find_shlibs(self, regex, platform): - if self.libdir.endswith('/'): - self.libdir = self.libdir[:-1] - prefix = os.path.dirname(self.libdir) - libdir = os.path.basename(self.libdir) - ext = FilesProvider.EXTENSIONS[platform]['srext'] - libs = find_shlib_regex(self.libname, prefix, libdir, ext, regex) - # Return in order from most version components to least. F.ex: - # ['libfoo.so.2.4800.1', 'libfoo.so.2', 'libfoo.so'] - return sorted([os.path.basename(lib) for lib in libs], reverse=True) - - def _autodetect_versions(self, regex, libs): - "Auto-detect major/minor/micro versions" - if not libs: - return [''] * 3 - # Find the library with the most version components - # So if we have: - # ['lib/libfoo.so.0.11.0', 'lib/libfoo.so', 'lib/libfoo.so.0'] - # This will yield - # 'libfoo.so.0.11.0' - # Usually, this is the actual library and the rest are symlinks - actual_lib = os.path.basename(sorted(libs, reverse=True)[0]) - # Get the version components. This would yield: - # ('0', '11', '0') - # For libfoo.2.6, this will yield: - # ('2', '6', '') - return [v[1:] if v else '' for v in re.match(regex, actual_lib).groups()] - def save(self): path = os.path.join(self.libdir, self.laname) with open(path, 'w') as f: diff --git a/recipes/bzip2.recipe b/recipes/bzip2.recipe index bdc8f758..02d47eea 100644 --- a/recipes/bzip2.recipe +++ b/recipes/bzip2.recipe @@ -29,14 +29,17 @@ class Recipe(recipe.Recipe): (shared_makefile, self.config.prefix, extension, self.config.prefix) def post_install(self): + libtool_la = LibtoolLibrary('bz2', 1, 0, 6, self.config.libdir, + self.config.target_platform) + libtool_la.save() src = None dst = None libdir = os.path.join(self.config.prefix, 'lib') if self.config.target_platform in [Platform.LINUX, Platform.ANDROID]: - src = 'libbz2.so.{}'.format(self.version) + src = 'libbz2.so.1.0.6' dst = 'libbz2.so' elif self.config.target_platform == Platform.DARWIN: - src = 'libbz2.{}.dylib'.format(self.version) + src = 'libbz2.1.0.6.dylib' dst = 'libbz2.dylib' elif self.config.target_platform == Platform.IOS: src = 'libbz2.dylib' @@ -46,7 +49,3 @@ class Recipe(recipe.Recipe): if os.path.exists(p) or os.path.islink(p): os.remove(p) shell.call('ln -s %s %s' % (src, dst), libdir) - - libtool_la = LibtoolLibrary('bz2', self.config.libdir, - self.config.target_platform) - libtool_la.save() diff --git a/recipes/gnustl.recipe b/recipes/gnustl.recipe index 2b0867ac..7276fe06 100644 --- a/recipes/gnustl.recipe +++ b/recipes/gnustl.recipe @@ -54,8 +54,9 @@ class Recipe(recipe.Recipe): # Create a libtool library for gnustl (libgnustl.la) - lib = LibtoolLibrary('gnustl', libdir, self.config.target_platform, - deps=['-lstdc++']) + 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) diff --git a/recipes/gst-libav-1.0-static.recipe b/recipes/gst-libav-1.0-static.recipe index 8535310b..8e9baeeb 100644 --- a/recipes/gst-libav-1.0-static.recipe +++ b/recipes/gst-libav-1.0-static.recipe @@ -89,8 +89,10 @@ class Recipe(custom.GStreamerStatic): deps += ['avutil'] if n == 'avfilter': deps += ['avutil', 'avcodec', 'avformat'] - libtool_la = LibtoolLibrary(n, self.config.libdir, + libtool_la = LibtoolLibrary(n, None, None, None, self.config.libdir, self.config.target_platform, deps) + libtool_la.change_value ('dlname', '') + libtool_la.change_value ('library_names', '') libtool_la.save() super(Recipe, self).post_install() gstlibavlib = os.path.join(self.config.prefix, 'lib', 'gstreamer-1.0', diff --git a/recipes/librtmp/librtmp.recipe b/recipes/librtmp/librtmp.recipe index 5fee0b89..a5df815b 100644 --- a/recipes/librtmp/librtmp.recipe +++ b/recipes/librtmp/librtmp.recipe @@ -33,6 +33,7 @@ class Recipe(recipe.Recipe): self.make_install = 'make install SYS=%s prefix=$CERBERO_PREFIX CRYPTO=GNUTLS XLDFLAGS="$LDFLAGS" XCFLAGS="$CFLAGS" CC="$CC" LD="$LD"' % (system) def post_install(self): - libtool_la = LibtoolLibrary('rtmp', self.config.libdir, - self.config.target_platform, deps=['gnutls']) + deps = ['gnutls'] + libtool_la = LibtoolLibrary('rtmp', 0, None, None, self.config.libdir, + self.config.target_platform, deps) libtool_la.save() diff --git a/recipes/libsrtp.recipe b/recipes/libsrtp.recipe index 02008c98..91013a71 100644 --- a/recipes/libsrtp.recipe +++ b/recipes/libsrtp.recipe @@ -27,6 +27,7 @@ class Recipe(recipe.Recipe): shutil.copy(os.path.join(self.build_dir, 'srtp.def'), libdir) def post_install(self): - libtool_la = LibtoolLibrary('srtp', self.config.libdir, + # XXX: Don't forget to keep this in sync with the library version! + libtool_la = LibtoolLibrary('srtp', 1, None, None, self.config.libdir, self.config.target_platform) libtool_la.save() diff --git a/recipes/nettle/nettle.recipe b/recipes/nettle/nettle.recipe index cf0d74ce..7e24c6ab 100644 --- a/recipes/nettle/nettle.recipe +++ b/recipes/nettle/nettle.recipe @@ -32,7 +32,7 @@ class Recipe(recipe.Recipe): def post_install(self): # Create libtool libraries (.la) - libtool_la = LibtoolLibrary('nettle', self.config.libdir, + libtool_la = LibtoolLibrary('nettle', 6, 2, None, self.config.libdir, self.config.target_platform) libtool_la.save() deps = ['nettle', 'gmp'] @@ -43,7 +43,7 @@ class Recipe(recipe.Recipe): if self.config.target_platform != Platform.WINDOWS: deps += ['-lc'] - libtool_la = LibtoolLibrary('hogweed', self.config.libdir, + libtool_la = LibtoolLibrary('hogweed', 4, 2, None, self.config.libdir, self.config.target_platform, deps) libtool_la.save() diff --git a/recipes/openh264.recipe b/recipes/openh264.recipe index ae376ed7..1785744c 100644 --- a/recipes/openh264.recipe +++ b/recipes/openh264.recipe @@ -107,7 +107,7 @@ class Recipe(recipe.Recipe): else: raise NotImplementedError - libtool_la = LibtoolLibrary('openh264', self.config.libdir, + libtool_la = LibtoolLibrary('openh264', 0, None, None, self.config.libdir, self.config.target_platform, deps=dependency_libs) libtool_la.save() diff --git a/recipes/stlport.recipe b/recipes/stlport.recipe index eedd7ead..caba70bd 100644 --- a/recipes/stlport.recipe +++ b/recipes/stlport.recipe @@ -37,8 +37,9 @@ class Recipe(recipe.Recipe): # Create a libtool library for stlport (libstlport.la) - lib = LibtoolLibrary('stlport', libdir, self.config.target_platform, - deps=['-lstdc++']) + lib = LibtoolLibrary('stlport', None, None, None, libdir, + self.config.target_platform) + lib.change_value('dependency_libs', ' -lstdc++') lib.save() # Create pkg-config file (stlport.pc) diff --git a/recipes/taglib.recipe b/recipes/taglib.recipe index ea29b6cb..3986528f 100644 --- a/recipes/taglib.recipe +++ b/recipes/taglib.recipe @@ -40,8 +40,9 @@ class Recipe(recipe.Recipe): os.path.join(self.config.prefix, 'lib', 'libtag.a')) def post_install(self): + deps = ['z'] if self.config.target_platform == Platform.ANDROID: deps.append('gnustl') - libtool_la = LibtoolLibrary('tag', self.config.libdir, - self.config.target_platform, deps=['z']) + libtool_la = LibtoolLibrary('tag', 1, 7, None, self.config.libdir, + self.config.target_platform, deps) libtool_la.save() diff --git a/recipes/x264.recipe b/recipes/x264.recipe index aa1f238c..7ba1de28 100644 --- a/recipes/x264.recipe +++ b/recipes/x264.recipe @@ -54,6 +54,6 @@ class Recipe(recipe.Recipe): self.configure_options += ' --disable-asm ' def post_install(self): - libtool_la = LibtoolLibrary('x264', self.config.libdir, + libtool_la = LibtoolLibrary('x264', 148, None, None, self.config.libdir, self.config.target_platform) libtool_la.save() diff --git a/recipes/zlib.recipe b/recipes/zlib.recipe index fa30ec55..8900c837 100644 --- a/recipes/zlib.recipe +++ b/recipes/zlib.recipe @@ -36,7 +36,7 @@ class Recipe(recipe.Recipe): self.configure_options += " --uname=arm-linux-androideabi " def post_install(self): - libtool_la = LibtoolLibrary('z', self.config.libdir, + libtool_la = LibtoolLibrary('z', 1, 2, 8, self.config.libdir, self.config.target_platform) libtool_la.save() # FIXME This is to workaround a build issue trying to ld to libz.so |