Speedup the default 'libs' property search ... (#7553)
* Speedup the default 'libs' property search - important for external packages. * As advised by @alalazo, use tuples instead of lists inside _libs_default_handler.
This commit is contained in:
parent
a0494003a2
commit
4ddbc96c7b
1 changed files with 20 additions and 23 deletions
|
@ -729,31 +729,28 @@ def _libs_default_handler(descriptor, spec, cls):
|
|||
# unlikely).
|
||||
name = 'lib' + spec.name.replace('-', '?')
|
||||
|
||||
if '+shared' in spec:
|
||||
libs = find_libraries(
|
||||
name, root=spec.prefix, shared=True, recursive=True
|
||||
)
|
||||
elif '~shared' in spec:
|
||||
libs = find_libraries(
|
||||
name, root=spec.prefix, shared=False, recursive=True
|
||||
)
|
||||
else:
|
||||
# Prefer shared
|
||||
libs = find_libraries(
|
||||
name, root=spec.prefix, shared=True, recursive=True
|
||||
)
|
||||
if libs:
|
||||
return libs
|
||||
# To speedup the search for external packages configured e.g. in /usr,
|
||||
# perform first non-recursive search in prefix.lib then in prefix.lib64 and
|
||||
# finally search all of prefix recursively. The search stops when the first
|
||||
# match is found.
|
||||
prefix = spec.prefix
|
||||
search_paths = [(prefix.lib, False), (prefix.lib64, False), (prefix, True)]
|
||||
|
||||
libs = find_libraries(
|
||||
name, root=spec.prefix, shared=False, recursive=True
|
||||
)
|
||||
# If '+shared' search only for shared library; if '~shared' search only for
|
||||
# static library; otherwise, first search for shared and then for static.
|
||||
search_shared = [True] if ('+shared' in spec) else \
|
||||
([False] if ('~shared' in spec) else [True, False])
|
||||
|
||||
if libs:
|
||||
return libs
|
||||
else:
|
||||
msg = 'Unable to recursively locate {0} libraries in {1}'
|
||||
raise RuntimeError(msg.format(spec.name, spec.prefix))
|
||||
for shared in search_shared:
|
||||
for path, recursive in search_paths:
|
||||
libs = find_libraries(
|
||||
name, root=path, shared=shared, recursive=recursive
|
||||
)
|
||||
if libs:
|
||||
return libs
|
||||
|
||||
msg = 'Unable to recursively locate {0} libraries in {1}'
|
||||
raise RuntimeError(msg.format(spec.name, prefix))
|
||||
|
||||
|
||||
class ForwardQueryToPackage(object):
|
||||
|
|
Loading…
Reference in a new issue