modules : restored previous logic for path inspection
This commit is contained in:
parent
ac762e95a6
commit
9cdd79e33f
1 changed files with 29 additions and 21 deletions
|
@ -74,29 +74,37 @@ def print_help():
|
||||||
"")
|
"")
|
||||||
|
|
||||||
|
|
||||||
def inspect_path(path):
|
def inspect_path(prefix):
|
||||||
class PathInspector(object):
|
"""
|
||||||
dirname2varname = {
|
Inspects the prefix of an installation to search for common layouts. Issues a request to modify the environment
|
||||||
'bin': ('PATH',),
|
accordingly when an item is found.
|
||||||
'man': ('MANPATH',),
|
|
||||||
'lib': ('LIBRARY_PATH', 'LD_LIBRARY_PATH'),
|
|
||||||
'lib64': ('LIBRARY_PATH', 'LD_LIBRARY_PATH'),
|
|
||||||
'include': ('CPATH',),
|
|
||||||
'pkgconfig': ('PKG_CONFIG_PATH',)
|
|
||||||
}
|
|
||||||
|
|
||||||
def __call__(self, env, directory, names):
|
Args:
|
||||||
for name in names:
|
prefix: prefix of the installation
|
||||||
variables = PathInspector.dirname2varname.get(name, None)
|
|
||||||
if variables is None:
|
|
||||||
continue
|
|
||||||
absolute_path = join_path(os.path.abspath(directory), name)
|
|
||||||
for variable in variables:
|
|
||||||
env.prepend_path(variable, absolute_path)
|
|
||||||
|
|
||||||
env, inspector = EnvironmentModifications(), PathInspector()
|
Returns:
|
||||||
os.path.walk(path, inspector, env)
|
instance of EnvironmentModifications containing the requested modifications
|
||||||
env.prepend_path('CMAKE_PREFIX_PATH', path)
|
"""
|
||||||
|
env = EnvironmentModifications()
|
||||||
|
# Inspect the prefix to check for the existence of common directories
|
||||||
|
prefix_inspections = {
|
||||||
|
'bin': ('PATH',),
|
||||||
|
'man': ('MANPATH',),
|
||||||
|
'lib': ('LIBRARY_PATH', 'LD_LIBRARY_PATH'),
|
||||||
|
'lib64': ('LIBRARY_PATH', 'LD_LIBRARY_PATH'),
|
||||||
|
'include': ('CPATH',)
|
||||||
|
}
|
||||||
|
for attribute, variables in prefix_inspections.items():
|
||||||
|
expected = getattr(prefix, attribute)
|
||||||
|
if os.path.isdir(expected):
|
||||||
|
for variable in variables:
|
||||||
|
env.prepend_path(variable, expected)
|
||||||
|
# PKGCONFIG
|
||||||
|
for expected in (join_path(prefix.lib, 'pkgconfig'), join_path(prefix.lib64, 'pkgconfig')):
|
||||||
|
if os.path.isdir(expected):
|
||||||
|
env.prepend_path('PKG_CONFIG_PATH', expected)
|
||||||
|
# CMake related variables
|
||||||
|
env.prepend_path('CMAKE_PREFIX_PATH', prefix)
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue