mirror of
https://github.com/plasma-umass/coz.git
synced 2024-09-11 04:55:25 +03:00
Merge pull request #119 from plasma-umass/custom-prefix
Fix for custom prefix library search. Fixes #111 and #113
This commit is contained in:
commit
5e0550c0e8
1
Makefile
1
Makefile
@ -12,6 +12,7 @@ install:: all
|
||||
@$(INSTALL) -D coz $(DESTDIR)$(bindir)/coz
|
||||
@$(INSTALL) -D libcoz/libcoz.so $(DESTDIR)$(pkglibdir)/libcoz.so
|
||||
@$(INSTALL) -D include/coz.h $(DESTDIR)$(incdir)/coz.h
|
||||
@mkdir -p $(DESTDIR)$(man1dir)
|
||||
@$(RST2MAN) docs/coz.rst $(DESTDIR)$(man1dir)/coz.1
|
||||
|
||||
bench::
|
||||
|
34
coz
34
coz
@ -44,11 +44,35 @@ 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)
|
||||
|
||||
if 'LD_PRELOAD' in env:
|
||||
env['LD_PRELOAD'] += ':' + coz_runtime
|
||||
|
Loading…
Reference in New Issue
Block a user