Skip to content

Commit

Permalink
Added notes + warnings to mac app bundle tool.
Browse files Browse the repository at this point in the history
  • Loading branch information
ianrrees committed Jan 27, 2016
1 parent c674016 commit 641a3ab
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions src/Tools/MakeMacBundleRelocatable.py
Expand Up @@ -4,7 +4,23 @@
import pprint
import re

SYS_PATHS = ["/System/", "/usr/lib/", "/Library/Frameworks/"]
# This script is intended to help copy dynamic libraries used by FreeCAD into
# a Mac application bundle and change dyld commands as appropriate. There are
# two key items that this currently does differently from other similar tools:
#
# * @rpath is used rather than @executable_path because the libraries need to
# be loadable through a Python interpreter and the FreeCAD binaries.
# * We need to be able to add multiple rpaths in some libraries.

# Assume any libraries in these paths don't need to be bundled
systemPaths = [ "/System/", "/usr/lib/",
"/Library/Frameworks/3DconnexionClient.framework/" ]

# If a library is in these paths, but not systemPaths, a warning will be
# issued and it will NOT be bundled. Generally, libraries installed by
# MacPorts or Homebrew won't end up in /Library/Frameworks, so we assume
# that libraries found there aren't meant to be bundled.
warnPaths = ["/Library/Frameworks/"]

class LibraryNotFound(Exception):
pass
Expand Down Expand Up @@ -73,9 +89,14 @@ def is_macho(path):
return False

def is_system_lib(lib):
for p in SYS_PATHS:
for p in systemPaths:
if lib.startswith(p):
return True
for p in warnPaths:
if lib.startswith(p):
print "WARNING: library %s will not be bundled!" % lib
print "See MakeMacRelocatable.py for more information."
return True
return False

def get_path(name, search_paths):
Expand Down Expand Up @@ -250,19 +271,13 @@ def get_rpaths(library):

if "cmd LC_RPATH" in line:
expectingRpath = True
continue

if "Load command" in line:
expectingRpath = False
continue

if not expectingRpath:
continue

m = re.match(pathRegex, line)
if m:
rpaths.append(m.group(1))
elif "Load command" in line:
expectingRpath = False
elif expectingRpath:
m = re.match(pathRegex, line)
if m:
rpaths.append(m.group(1))
expectingRpath = False

return rpaths

Expand Down

0 comments on commit 641a3ab

Please sign in to comment.