Skip to content

Commit

Permalink
Fixed|Builder|macOS: Handling file name containing a space
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 1622507 commit 50ef7ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions doomsday/build/scripts/apple_install_names.py
@@ -1,4 +1,4 @@
# This script goes through the contents of an application bundle
# This script goes through the contents of an application bundle
# (both MacOS and Frameworks) and fixes the install names so that
# they use "@rpath" for all the dynamically linked libraries.

Expand All @@ -9,14 +9,15 @@
chmod_cmd = '/bin/chmod'
otool_cmd = '/usr/bin/otool'
name_cmd = '/usr/bin/install_name_tool'
print("Fixing install names in:", sys.argv[1])
root = os.path.join(sys.argv[1], 'Contents')
binaries = list(
map(lambda n: '/MacOS/' + n, os.listdir(root + '/MacOS')) + \
map(lambda n: '/Frameworks/' + n, os.listdir(root + '/Frameworks')))
actions = {}
for binary in binaries:
if binary.startswith('/Frameworks/'):
subprocess.check_call([chmod_cmd, '0644', root + binary])
subprocess.check_call([chmod_cmd, '0644', root + binary])
# ver3 = re.match(r'(.*)\.((\d+)\.\d+\.\d+)\.(.*)', binary)
# if ver3:
# print('version found:', binary, ver3.group(3))
Expand All @@ -26,7 +27,7 @@
# if not os.path.exists(ver_symlink):
# subprocess.check_call([ln_cmd, '-s', target, ver_symlink])
libraries = set()
while len(binaries) > 0:
while len(binaries) > 0:
binary = binaries[0]
del binaries[0]
print(binary)
Expand All @@ -40,7 +41,7 @@
dep_path = dep.group(1)
dep_name = os.path.basename(dep_path)
if dep_name.startswith('lib') and not dep_path.startswith('/usr/lib') \
and not dep_path.startswith('/System'):
and not dep_path.startswith('/System'):
libraries.add(dep_name)
if dep_path.startswith('@rpath') or dep_path.startswith('/System') or \
dep_path.startswith('/usr/lib'):
Expand All @@ -65,15 +66,15 @@
subprocess.check_call([name_cmd, '-change', old_path, new_path, path])
avail_fws = os.listdir(os.path.join(root, 'Frameworks'))
def base_name(fn):
return fn[:fn.find('.')]
return fn[:fn.find('.')]
for lib in libraries:
if not os.path.exists(os.path.join(root, 'Frameworks', lib)):
print('%s: missing link' % lib)
name = base_name(lib)
for avail in avail_fws:
if base_name(avail) == name:
print(' -> to %s' % avail)
subprocess.check_call([ln_cmd, '-s',
avail,
subprocess.check_call([ln_cmd, '-s',
avail,
os.path.join(root, 'Frameworks', lib)])
break
2 changes: 1 addition & 1 deletion doomsday/cmake/Macros.cmake
Expand Up @@ -470,7 +470,7 @@ function (deng_deploy_target target)
install (CODE "
execute_process (COMMAND ${PYTHON_EXECUTABLE}
${DE_SOURCE_DIR}/build/scripts/apple_install_names.py
${DE_DISTRIB_DIR}/${outName}.app
\"${DE_DISTRIB_DIR}/${outName}.app\"
)")
endif ()
endfunction ()
Expand Down

0 comments on commit 50ef7ac

Please sign in to comment.