Use python3 to run MakeMacBundleRelocatable.py (#6784)
* To use this script with python 3, fix the incompatible types text and bytes.
This commit is contained in:
committed by
GitHub
parent
03f0fe2039
commit
573a184d62
@@ -130,7 +130,7 @@ install(CODE
|
||||
# The top-level CMakeLists.txt should prevent multiple package manager
|
||||
# prefixes from being set, so the lib path will resolve correctly...
|
||||
execute_process(
|
||||
COMMAND python2.7
|
||||
COMMAND python3
|
||||
${CMAKE_SOURCE_DIR}/src/Tools/MakeMacBundleRelocatable.py
|
||||
${APP_PATH} ${HOMEBREW_PREFIX}${MACPORTS_PREFIX}/lib ${ICU_PREFIX}/lib/ /usr/local/opt ${CONFIG_NGLIB} ${Qt5Core_DIR}/../../.. ${XCTEST_PATH} ${WEBKIT_FRAMEWORK_DIR}
|
||||
)"
|
||||
|
||||
@@ -51,7 +51,7 @@ class DepsGraph:
|
||||
graph = {}
|
||||
|
||||
def in_graph(self, node):
|
||||
return node.name in self.graph.keys()
|
||||
return node.name in list(self.graph)
|
||||
|
||||
def add_node(self, node):
|
||||
self.graph[node.name] = node
|
||||
@@ -68,10 +68,10 @@ class DepsGraph:
|
||||
"""
|
||||
stack = []
|
||||
|
||||
for k in self.graph.keys():
|
||||
for k in list(self.graph):
|
||||
self.graph[k]._marked = False
|
||||
|
||||
for k in self.graph.keys():
|
||||
for k in list(self.graph):
|
||||
if not self.graph[k]._marked:
|
||||
stack.append(k)
|
||||
while stack:
|
||||
@@ -84,11 +84,14 @@ class DepsGraph:
|
||||
|
||||
|
||||
def is_macho(path):
|
||||
output = check_output(["file", path])
|
||||
if output.count("Mach-O") != 0:
|
||||
return True
|
||||
return b'Mach-O' in check_output(['file', path])
|
||||
|
||||
return False
|
||||
def get_token(txt, delimiter=' (', first=True):
|
||||
result = txt.decode().split(delimiter)
|
||||
if first:
|
||||
return result[0]
|
||||
else:
|
||||
return result
|
||||
|
||||
def is_system_lib(lib):
|
||||
for p in systemPaths:
|
||||
@@ -109,18 +112,18 @@ def get_path(name, search_paths):
|
||||
|
||||
def list_install_names(path_macho):
|
||||
output = check_output(["otool", "-L", path_macho])
|
||||
lines = output.split("\t")
|
||||
lines = output.split(b"\t")
|
||||
libs = []
|
||||
|
||||
#first line is the filename, and if it is a library, the second line
|
||||
#is the install name of it
|
||||
if path_macho.endswith(os.path.basename(lines[1].split(" (")[0])):
|
||||
if path_macho.endswith(os.path.basename(get_token(lines[1]))):
|
||||
lines = lines[2:]
|
||||
else:
|
||||
lines = lines[1:]
|
||||
|
||||
for line in lines:
|
||||
lib = line.split(" (")[0]
|
||||
lib = get_token(line)
|
||||
if not is_system_lib(lib):
|
||||
libs.append(lib)
|
||||
return libs
|
||||
@@ -223,7 +226,7 @@ def build_deps_graph(graph, bundle_path, dirs_filter=None, search_paths=[]):
|
||||
visited[fpath] = False
|
||||
|
||||
stack = []
|
||||
for k in visited.keys():
|
||||
for k in list(visited):
|
||||
if not visited[k]:
|
||||
stack.append(k)
|
||||
while stack:
|
||||
@@ -245,7 +248,7 @@ def build_deps_graph(graph, bundle_path, dirs_filter=None, search_paths=[]):
|
||||
node.children.append(d.name)
|
||||
|
||||
dk = os.path.join(d.path, d.name)
|
||||
if dk not in visited.keys():
|
||||
if dk not in list(visited):
|
||||
visited[dk] = False
|
||||
if not visited[dk]:
|
||||
stack.append(dk)
|
||||
@@ -276,7 +279,7 @@ def get_rpaths(library):
|
||||
pathRegex = r"^path (.*) \(offset \d+\)$"
|
||||
expectingRpath = False
|
||||
rpaths = []
|
||||
for line in out.split('\n'):
|
||||
for line in get_token(out, '\n', False):
|
||||
line = line.strip()
|
||||
|
||||
if "cmd LC_RPATH" in line:
|
||||
@@ -385,4 +388,4 @@ def main():
|
||||
logging.info("Done.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
Reference in New Issue
Block a user