aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-06-17 13:48:59 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2017-06-18 00:16:45 +0300
commit1c34707aeeedfe499bf2101253788cb41e970383 (patch)
treee3c4a73c75f7a636844d571aa5b016842a062457
parent85a263a6708f865bffe77c2fe9bb5e888c466709 (diff)
downloadmeson-1c34707aeeedfe499bf2101253788cb41e970383.zip
meson-1c34707aeeedfe499bf2101253788cb41e970383.tar.gz
meson-1c34707aeeedfe499bf2101253788cb41e970383.tar.bz2
Preserve standalone -D arguments always.
-rw-r--r--mesonbuild/compilers.py11
-rwxr-xr-xrun_unittests.py7
2 files changed, 15 insertions, 3 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index 2b54cc8..6a9ad4f 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -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):
diff --git a/run_unittests.py b/run_unittests.py
index 7e3a2f1..c21db08 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1225,9 +1225,10 @@ int main(int argc, char **argv) {
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)
-
+ 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):