summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Davydov <davydden@gmail.com>2016-07-16 07:24:05 +0200
committerDenis Davydov <davydden@gmail.com>2016-07-16 07:24:05 +0200
commit992250ddeab77a605c1e0c47363bd750949d59a5 (patch)
tree4f38a977ccf7bf4e9fc7380fc08d99cc7a7be454
parent069de3f00897b0108243539730c00a83ecb55f09 (diff)
downloadspack-992250ddeab77a605c1e0c47363bd750949d59a5.tar.gz
spack-992250ddeab77a605c1e0c47363bd750949d59a5.tar.bz2
spack-992250ddeab77a605c1e0c47363bd750949d59a5.tar.xz
spack-992250ddeab77a605c1e0c47363bd750949d59a5.zip
add to_lib_name() to get library name from a path
-rw-r--r--lib/spack/llnl/util/filesystem.py10
1 files changed, 7 insertions, 3 deletions
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<name>.xyz into <name>
+ """
+ # Assume libXYZ.suffix
+ return os.path.basename(library)[3:].split(".")[0]
def to_link_flags(library):
"""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.
"""
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