mirror of
https://github.com/plasma-umass/coz.git
synced 2024-09-11 04:55:25 +03:00
Corrected search for coz runtime library to support custom install prefix
This commit is contained in:
parent
539b975fca
commit
3eb5b720ad
37
coz
37
coz
@ -44,11 +44,38 @@ def _coz_run(args):
|
||||
sys.exit(1)
|
||||
|
||||
env = copy.deepcopy(os.environ)
|
||||
if os.path.exists('/usr/lib/coz-profiler/libcoz.so'):
|
||||
coz_runtime = '/usr/lib/coz-profiler/libcoz.so'
|
||||
else:
|
||||
coz_prefix = dirname(realpath(sys.argv[0]))
|
||||
coz_runtime = coz_prefix + path_sep + 'libcoz' + path_sep + 'libcoz.so'
|
||||
|
||||
# Find libcoz
|
||||
coz_prefix = dirname(realpath(sys.argv[0]))
|
||||
|
||||
# Candidate runtime library locations
|
||||
library_locations = [
|
||||
# Check for library adjacent to this script
|
||||
os.path.join(coz_prefix, '..', 'lib', 'libcoz.so'),
|
||||
|
||||
# Check for library under the coz-profiler subdirectory
|
||||
os.path.join(coz_prefix, '..', 'lib', 'coz-profiler', 'libcoz.so'),
|
||||
|
||||
# Local library under development directory
|
||||
os.path.join(coz_prefix, 'libcoz', 'libcoz.so') # Local library during development
|
||||
]
|
||||
|
||||
# Find the first library location that exists
|
||||
coz_runtime_found = False
|
||||
coz_runtime = None
|
||||
|
||||
while len(library_locations) > 0 and not coz_runtime_found:
|
||||
candidate = library_locations.pop(0)
|
||||
if os.path.exists(candidate):
|
||||
coz_runtime_found = True
|
||||
coz_runtime = candidate
|
||||
|
||||
if not coz_runtime_found:
|
||||
sys.stderr.write('error: unable to locate coz runtime library\n')
|
||||
sys.exit(1)
|
||||
|
||||
print(coz_runtime)
|
||||
sys.exit(0)
|
||||
|
||||
if 'LD_PRELOAD' in env:
|
||||
env['LD_PRELOAD'] += ':' + coz_runtime
|
||||
|
Loading…
Reference in New Issue
Block a user