[gtk-mac-bundler] Move private function definitions for resolve_library_dependencies outside of the loop.



commit 996d0dac57a0b6c1617084448ecd594fa9eac51f
Author: John Ralls <jralls ceridwen us>
Date:   Sat Oct 29 14:53:29 2016 -0700

    Move private function definitions for resolve_library_dependencies outside of the loop.

 bundler/bundler.py |   60 ++++++++++++++++++++++++++-------------------------
 1 files changed, 31 insertions(+), 29 deletions(-)
---
diff --git a/bundler/bundler.py b/bundler/bundler.py
index e9d435f..9fe9dac 100644
--- a/bundler/bundler.py
+++ b/bundler/bundler.py
@@ -362,44 +362,46 @@ class Bundler:
         n_iterations = 0
         n_paths = 0
         paths = self.list_copied_binaries()
-        while n_paths != len(paths):
-            cmds = [ "otool -L " ]
-            for path in paths:
-                cmds.append(path + " ")
 
-            cmd = ''.join(cmds)
-            f = os.popen(cmd)
+        def relative_path_map(line):
+            if not os.path.isabs(line):
+                for prefix in list(prefixes.values()):
+                    path = os.path.join(prefix, "lib", line)
+                    if os.path.exists(path):
+                        return path
+                print("Cannot find a matching prefix for %s" % (line))
+            return line
+
+        def prefix_filter(line):
+            if not "(compatibility" in line:
+                print "Removed %s" % line
+                return False
 
-            prefixes = self.meta.prefixes
+            if line.startswith("/usr/X11"):
+                print("Warning, found X11 library dependency, you most likely don't want that:", 
line.strip().split()[0])
 
-            def relative_path_map(line):
-                if not os.path.isabs(line):
-                    for prefix in list(prefixes.values()):
-                        path = os.path.join(prefix, "lib", line)
-                        if os.path.exists(path):
-                            return path
-                    print("Cannot find a matching prefix for %s" % (line))
-                return line
+            if os.path.isabs(line):
+                for prefix in list(prefixes.values()):
+                    if prefix in line:
+                        return True
 
-            def prefix_filter(line):
-                if not "(compatibility" in line:
-                    return False
+                if not line.startswith("/usr/lib") and not line.startswith("/System/Library"):
+                    print("Warning, library not available in any prefix:",
+                          line.strip().split()[0])
 
-                if line.startswith("/usr/X11"):
-                    print("Warning, found X11 library dependency, you most likely don't want that:", 
line.strip().split()[0])
+                return False
 
-                if os.path.isabs(line):
-                    for prefix in list(prefixes.values()):
-                        if prefix in line:
-                            return True
-                    
-                    if not line.startswith("/usr/lib") and not line.startswith("/System/Library"):
-                        print("Warning, library not available in any prefix:", line.strip().split()[0])
+            return True
 
-                    return False
+        while n_paths != len(paths):
+            cmds = [ "otool -L " ]
+            for path in paths:
+                cmds.append(path + " ")
 
-                return True
+            cmd = ''.join(cmds)
+            f = os.popen(cmd)
 
+            prefixes = self.meta.prefixes
             lines = list(filter(prefix_filter, [line.strip() for line in f]))
             p = re.compile("(.*\.dylib\.?.*)\s\(compatibility.*$")
             lines = utils.filterlines(p, lines)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]