summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndoni Morales Alastruey <ylatuya@gmail.com>2013-04-12 21:11:50 +0200
committerAndoni Morales Alastruey <ylatuya@gmail.com>2013-04-12 21:11:50 +0200
commitec0278e61a1d9e180f9dd791fd6fff1754080e53 (patch)
treeb8e68389e2867381675f71b522d76be2ef76a7ff
parent29cce55eb5014de60ad90e026292bc30e69f7e67 (diff)
fwlib: fix extration of object files with duplicated names
-rw-r--r--cerbero/ide/xcode/fwlib.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/cerbero/ide/xcode/fwlib.py b/cerbero/ide/xcode/fwlib.py
index f98d0d3..cf679bf 100644
--- a/cerbero/ide/xcode/fwlib.py
+++ b/cerbero/ide/xcode/fwlib.py
@@ -107,6 +107,28 @@ class StaticFrameworkLibrary(FrameworkLibrary):
tmplib = os.path.join (lib_tmpdir, newname)
shell.call('ar -x %s' % tmplib, lib_tmpdir)
+
+ # object files with the same name in an archive are overwritten
+ # when they are extracted. osx's ar does not support the N count
+ # modifier so after extracting all the files we remove them from
+ # the archive to extract those with duplicated names.
+ # eg:
+ # ar t libavcodec.a -> mlpdsp.o mlpdsp.o (2 objects with the same name)
+ # ar d libavcodec.a mlpdsp.o (we remove the first one)
+ # ar t libavcodec.a -> mlpdsp.o (we only the second one now)
+ files = shell.check_call('ar -t %s' % tmplib, lib_tmpdir).split('\n')
+ # We should use collections.Count but it's only available in python 2.7+
+ dups = set([x for x in files if files.count(x) > 1])
+ # FIXME: handle more than one duplicate
+ for f in dups:
+ path = os.path.join(lib_tmpdir, f)
+ new_path = os.path.join(lib_tmpdir, 'dup_' + f)
+ # The duplicated overwrote the first one, so extract it again
+ shell.call('ar -x %s %s' % (tmplib, f), lib_tmpdir)
+ shutil.move (path, new_path)
+ shell.call('ar -d %s %s' % (tmplib, f), lib_tmpdir)
+ shell.call('ar -x %s %s' % (tmplib, f), lib_tmpdir)
+
return lib_tmpdir
def _create_framework_library(self, libraries):