Skip to content

Commit

Permalink
Deduplicate dependencies resolved to absolute paths
Browse files Browse the repository at this point in the history
If paths are absolute the order of search directories is not relevant as the path is already resolved.
  • Loading branch information
trilader authored and nirbheek committed Apr 13, 2018
1 parent 7806175 commit 57654bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 10 additions & 3 deletions mesonbuild/compilers/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,15 +526,22 @@ def to_native(self):
def append_direct(self, arg):
'''
Append the specified argument without any reordering or de-dup
except for absolute paths where the order of include search directories
is not relevant
'''
super().append(arg)
if os.path.isabs(arg):
self.append(arg)
else:
super().append(arg)

def extend_direct(self, iterable):
'''
Extend using the elements in the specified iterable without any
reordering or de-dup
reordering or de-dup except for absolute paths where the order of
include search directories is not relevant
'''
super().extend(iterable)
for elem in iterable:
self.append_direct(elem)

def __add__(self, args):
new = CompilerArgs(self, self.compiler)
Expand Down
6 changes: 6 additions & 0 deletions run_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ def test_compiler_args_class(self):
# Direct-adding the same library again still adds it
l.append_direct('-lbar')
self.assertEqual(l, ['-Lfoodir', '-lfoo', '-Lbardir', '-lbar', '-lbar'])
# Direct-adding with absolute path deduplicates
l.append_direct('/libbaz.a')
self.assertEqual(l, ['-Lfoodir', '-lfoo', '-Lbardir', '-lbar', '-lbar', '/libbaz.a'])
# Adding libbaz again does nothing
l.append_direct('/libbaz.a')
self.assertEqual(l, ['-Lfoodir', '-lfoo', '-Lbardir', '-lbar', '-lbar', '/libbaz.a'])

def test_string_templates_substitution(self):
dictfunc = mesonbuild.mesonlib.get_filenames_templates_dict
Expand Down

0 comments on commit 57654bf

Please sign in to comment.