From 10d94a12b85ba19dc2bcfc6296632eaf74f5d4f0 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 16 Feb 2021 10:48:20 -0800 Subject: Environment: Fix passing envrionment variables CPPFLAGS and CFLAGS Or other language flags that use CPPFLAGS (like CXXFLAGS). The problem here is actually rather simple, `dict.setdefault()` doesn't work like I thought it did, I thought it created a weak entry, but it actually is equivalent to: ```python if k not in dict: dict[k] = v ``` Instead we'll use an intermediate dictionary (a default dictionary actually, since that makes things a little cleaner) and then add the keys from that dict to self.options as applicable. Test case written by Jussi, Fix by Dylan Co-authored-by: Jussi Pakkanen Fixes: #8361 Fixes: #8345 --- run_unittests.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'run_unittests.py') diff --git a/run_unittests.py b/run_unittests.py index 0bd6d4bf9..3aa1cb31f 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -5476,6 +5476,14 @@ class AllPlatformTests(BasePlatformTests): projinfo = self.introspect('--projectinfo') self.assertEqual(projinfo['version'], '1.0.0') + def test_cflags_cppflags(self): + envs = {'CPPFLAGS': '-DCPPFLAG', + 'CFLAGS': '-DCFLAG', + 'CXXFLAGS': '-DCXXFLAG'} + srcdir = os.path.join(self.unit_test_dir, '90 multiple envvars') + self.init(srcdir, override_envvars=envs) + self.build() + class FailureTests(BasePlatformTests): ''' -- cgit v1.2.3