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).
|
# unlikely).
|
||||||
name = 'lib' + spec.name.replace('-', '?')
|
name = 'lib' + spec.name.replace('-', '?')
|
||||||
|
|
||||||
if '+shared' in spec:
|
# To speedup the search for external packages configured e.g. in /usr,
|
||||||
libs = find_libraries(
|
# perform first non-recursive search in prefix.lib then in prefix.lib64 and
|
||||||
name, root=spec.prefix, shared=True, recursive=True
|
# finally search all of prefix recursively. The search stops when the first
|
||||||
)
|
# match is found.
|
||||||
elif '~shared' in spec:
|
prefix = spec.prefix
|
||||||
libs = find_libraries(
|
search_paths = [(prefix.lib, False), (prefix.lib64, False), (prefix, True)]
|
||||||
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
|
|
||||||
|
|
||||||
libs = find_libraries(
|
# If '+shared' search only for shared library; if '~shared' search only for
|
||||||
name, root=spec.prefix, shared=False, recursive=True
|
# 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:
|
for shared in search_shared:
|
||||||
return libs
|
for path, recursive in search_paths:
|
||||||
else:
|
libs = find_libraries(
|
||||||
msg = 'Unable to recursively locate {0} libraries in {1}'
|
name, root=path, shared=shared, recursive=recursive
|
||||||
raise RuntimeError(msg.format(spec.name, spec.prefix))
|
)
|
||||||
|
if libs:
|
||||||
|
return libs
|
||||||
|
|
||||||
|
msg = 'Unable to recursively locate {0} libraries in {1}'
|
||||||
|
raise RuntimeError(msg.format(spec.name, prefix))
|
||||||
|
|
||||||
|
|
||||||
class ForwardQueryToPackage(object):
|
class ForwardQueryToPackage(object):
|
||||||
|
|
Loading…
Reference in a new issue