From 992250ddeab77a605c1e0c47363bd750949d59a5 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Sat, 16 Jul 2016 07:24:05 +0200 Subject: add to_lib_name() to get library name from a path --- lib/spack/llnl/util/filesystem.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index e800c6717a..adb6b8034e 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -42,7 +42,7 @@ __all__ = ['set_install_permissions', 'install', 'install_tree', 'FileFilter', 'change_sed_delimiter', 'is_exe', 'force_symlink', 'set_executable', 'copy_mode', 'unset_executable_mode', '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): @@ -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 break +def to_lib_name(library): + """Transforms a path to the library /path/to/lib.xyz into + """ + # Assume libXYZ.suffix + return os.path.basename(library)[3:].split(".")[0] def to_link_flags(library): """Transforms a path to a into linking flags -L -l. @@ -438,8 +443,7 @@ def to_link_flags(library): A string of linking flags. """ dir = os.path.dirname(library) - # Assume libXYZ.suffix - name = os.path.basename(library)[3:].split(".")[0] + name = to_lib_name(library) res = '-L%s -l%s' % (dir, name) return res -- cgit v1.2.3-70-g09d2