Fix name detection in HeaderList and LibraryList (#5118)

* Fix name detection in HeaderList and LibraryList

* Add support for CUDA header files
This commit is contained in:
Adam J. Stewart
2017-09-09 15:22:56 -05:00
committed by Massimiliano Culpo
parent 51828dd982
commit 2eb8db1dd2
2 changed files with 68 additions and 34 deletions

View File

@@ -647,19 +647,6 @@ def basenames(self):
"""
return list(dedupe(os.path.basename(x) for x in self.files))
@property
def names(self):
"""Stable de-duplication of file names in the list without extensions
>>> h = HeaderList(['/dir1/a.h', '/dir2/b.h', '/dir3/a.h'])
>>> h.names
['a', 'b']
Returns:
list of strings: A list of files without extensions
"""
return list(dedupe(x.split('.')[0] for x in self.basenames))
def __getitem__(self, item):
cls = type(self)
if isinstance(item, numbers.Integral):
@@ -709,6 +696,34 @@ def headers(self):
"""
return self.files
@property
def names(self):
"""Stable de-duplication of header names in the list without extensions
>>> h = HeaderList(['/dir1/a.h', '/dir2/b.h', '/dir3/a.h'])
>>> h.names
['a', 'b']
Returns:
list of strings: A list of files without extensions
"""
names = []
for x in self.basenames:
name = x
# Valid extensions include: ['.cuh', '.hpp', '.hh', '.h']
for ext in ['.cuh', '.hpp', '.hh', '.h']:
i = name.rfind(ext)
if i != -1:
names.append(name[:i])
break
else:
# No valid extension, should we still include it?
names.append(name)
return list(dedupe(names))
@property
def include_flags(self):
"""Include flags
@@ -833,7 +848,24 @@ def names(self):
Returns:
list of strings: A list of library names
"""
return list(dedupe(x.split('.')[0][3:] for x in self.basenames))
names = []
for x in self.basenames:
name = x
if x.startswith('lib'):
name = x[3:]
# Valid extensions include: ['.dylib', '.so', '.a']
for ext in ['.dylib', '.so', '.a']:
i = name.rfind(ext)
if i != -1:
names.append(name[:i])
break
else:
# No valid extension, should we still include it?
names.append(name)
return list(dedupe(names))
@property
def search_flags(self):