Bug 1307886 - [2.3] Compress libraries with XZ during packaging. r=glandium
authorEugen Sawin <esawin@mozilla.com>
Mon, 22 Aug 2016 18:39:24 +0200
changeset 319986 a4e85e8b39695146370873efafee0f881c565e81
parent 319985 ff6f8253d511b7c11b180c386236392ddbc48739
child 319987 d523f32cf87f2122fbbca86e0e3d2d0a26942ab6
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1307886
milestone52.0a1
Bug 1307886 - [2.3] Compress libraries with XZ during packaging. r=glandium
old-configure.in
python/mozbuild/mozbuild/action/package_fennec_apk.py
--- a/old-configure.in
+++ b/old-configure.in
@@ -1289,16 +1289,17 @@ AC_SUBST_LIST(MMX_FLAGS)
 AC_SUBST_LIST(SSE_FLAGS)
 AC_SUBST_LIST(SSE2_FLAGS)
 AC_SUBST_LIST(SSSE3_FLAGS)
 
 AC_SUBST(MOZ_LINKER)
 if test -n "$MOZ_LINKER"; then
   AC_DEFINE(MOZ_LINKER)
   MOZ_LINKER_EXTRACT=1
+  AC_CHECK_PROGS(XZ, xz)
 fi
 
 dnl Only one oddball right now (QNX), but this gives us flexibility
 dnl if any other platforms need to override this in the future.
 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
 
 dnl ========================================================
 dnl = Flags to strip unused symbols from .so components and
--- a/python/mozbuild/mozbuild/action/package_fennec_apk.py
+++ b/python/mozbuild/mozbuild/action/package_fennec_apk.py
@@ -59,16 +59,40 @@ def package_fennec_apk(inputs=[], omni_j
             add(mozpath.join('assets', 'features', p), f, False)
 
     for assets_dir in assets_dirs:
         finder = FileFinder(assets_dir, find_executables=False)
         for p, f in finder.find('**'):
             compress = None  # Take default from Jarrer.
             if p.endswith('.so'):
                 # Asset libraries are special.
+                if f.open().read(5)[1:] == '7zXZ':
+                    print('%s is already compressed' % p)
+                    # We need to store (rather than deflate) compressed libraries
+                    # (even if we don't compress them ourselves).
+                    compress = False
+                elif buildconfig.substs.get('XZ'):
+                    cmd = [buildconfig.substs.get('XZ'), '-zkf',
+                           mozpath.join(finder.base, p)]
+
+                    bcj = None
+                    if buildconfig.substs.get('MOZ_THUMB2'):
+                        bcj = '--armthumb'
+                    elif buildconfig.substs.get('CPU_ARCH') == 'arm':
+                        bcj = '--arm'
+                    elif buildconfig.substs.get('CPU_ARCH') == 'x86':
+                        bcj = '--x86'
+
+                    if bcj:
+                        cmd.extend([bcj, '--lzma2'])
+                    print('xz-compressing %s with %s' % (p, ' '.join(cmd)))
+                    subprocess.check_output(cmd)
+                    os.rename(f.path + '.xz', f.path)
+                    compress = False
+
             add(mozpath.join('assets', p), f, compress=compress)
 
     for lib_dir in lib_dirs:
         finder = FileFinder(lib_dir, find_executables=False)
         for p, f in finder.find('**'):
             add(mozpath.join('lib', p), f)
 
     for root_file in root_files: