Merge pull request #1951 from mesonbuild/dedupfix

Preserve standalone -D arguments
pull/1954/head
Jussi Pakkanen 8 years ago committed by GitHub
commit 3bc7651907
  1. 11
      mesonbuild/compilers.py
  2. 9
      run_unittests.py
  3. 6
      test cases/unit/10 d dedup/meson.build
  4. 14
      test cases/unit/10 d dedup/prog.c

@ -430,6 +430,17 @@ class CompilerArgs(list):
to recursively search for symbols in the libraries. This is not needed
with other linkers.
'''
# A standalone argument must never be deduplicated because it is
# defined by what comes _after_ it. Thus dedupping this:
# -D FOO -D BAR
# would yield either
# -D FOO BAR
# or
# FOO -D BAR
# both of which are invalid.
if arg in cls.dedup2_prefixes:
return 0
if arg in cls.dedup2_args or \
arg.startswith(cls.dedup2_prefixes) or \
arg.endswith(cls.dedup2_suffixes):

@ -1221,6 +1221,15 @@ int main(int argc, char **argv) {
for path in rpath.split(':'):
self.assertTrue(path.startswith('$ORIGIN'), msg=(each, path))
def test_dash_d_dedup(self):
testdir = os.path.join(self.unit_test_dir, '10 d dedup')
self.init(testdir)
cmd = self.get_compdb()[0]['command']
self.assertTrue('-D FOO -D BAR' in cmd or
'"-D" "FOO" "-D" "BAR"' in cmd or
'/D FOO /D BAR' in cmd or
'"/D" "FOO" "/D" "BAR"' in cmd)
class FailureTests(BasePlatformTests):
'''

@ -0,0 +1,6 @@
project('d dedup', 'c')
add_project_arguments('-D', 'FOO', '-D', 'BAR', language : 'c')
executable('prog', 'prog.c')

@ -0,0 +1,14 @@
#include<stdio.h>
#ifndef FOO
#error FOO is not defined.
#endif
#ifndef BAR
#error BAR is not defined.
#endif
int main(int argc, char **argv) {
printf("All is well.\n");
return 0;
}
Loading…
Cancel
Save