add to_lib_name() to get library name from a path
This commit is contained in:
parent
069de3f008
commit
992250ddea
@ -42,7 +42,7 @@
|
|||||||
'FileFilter', 'change_sed_delimiter', 'is_exe', 'force_symlink',
|
'FileFilter', 'change_sed_delimiter', 'is_exe', 'force_symlink',
|
||||||
'set_executable', 'copy_mode', 'unset_executable_mode',
|
'set_executable', 'copy_mode', 'unset_executable_mode',
|
||||||
'remove_dead_links', 'remove_linked_tree', 'find_library_path',
|
'remove_dead_links', 'remove_linked_tree', 'find_library_path',
|
||||||
'fix_darwin_install_name', 'to_link_flags']
|
'fix_darwin_install_name', 'to_link_flags', 'to_lib_name']
|
||||||
|
|
||||||
|
|
||||||
def filter_file(regex, repl, *filenames, **kwargs):
|
def filter_file(regex, repl, *filenames, **kwargs):
|
||||||
@ -430,6 +430,11 @@ def fix_darwin_install_name(path):
|
|||||||
subprocess.Popen(["install_name_tool", "-change", dep, loc, lib], stdout=subprocess.PIPE).communicate()[0] # NOQA: ignore=E501
|
subprocess.Popen(["install_name_tool", "-change", dep, loc, lib], stdout=subprocess.PIPE).communicate()[0] # NOQA: ignore=E501
|
||||||
break
|
break
|
||||||
|
|
||||||
|
def to_lib_name(library):
|
||||||
|
"""Transforms a path to the library /path/to/lib<name>.xyz into <name>
|
||||||
|
"""
|
||||||
|
# Assume libXYZ.suffix
|
||||||
|
return os.path.basename(library)[3:].split(".")[0]
|
||||||
|
|
||||||
def to_link_flags(library):
|
def to_link_flags(library):
|
||||||
"""Transforms a path to a <library> into linking flags -L<dir> -l<name>.
|
"""Transforms a path to a <library> into linking flags -L<dir> -l<name>.
|
||||||
@ -438,8 +443,7 @@ def to_link_flags(library):
|
|||||||
A string of linking flags.
|
A string of linking flags.
|
||||||
"""
|
"""
|
||||||
dir = os.path.dirname(library)
|
dir = os.path.dirname(library)
|
||||||
# Assume libXYZ.suffix
|
name = to_lib_name(library)
|
||||||
name = os.path.basename(library)[3:].split(".")[0]
|
|
||||||
res = '-L%s -l%s' % (dir, name)
|
res = '-L%s -l%s' % (dir, name)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user