File tree 2 files changed +20
-9
lines changed
2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change 24
24
25
25
build_filename = 'meson.build'
26
26
27
+ # Environment variables that each lang uses.
28
+ cflags_mapping = {'c' : 'CFLAGS' ,
29
+ 'cpp' : 'CXXFLAGS' ,
30
+ 'objc' : 'OBJCFLAGS' ,
31
+ 'objcpp' : 'OBJCXXFLAGS' ,
32
+ 'fortran' : 'FFLAGS' ,
33
+ 'd' : 'DFLAGS' ,
34
+ 'vala' : 'VALAFLAGS' }
35
+
36
+
27
37
def find_coverage_tools ():
28
38
gcovr_exe = 'gcovr'
29
39
lcov_exe = 'lcov'
@@ -809,15 +819,6 @@ def log_var(var, val):
809
819
if hasattr (compiler , 'get_linker_exelist' ):
810
820
compiler_is_linker = (compiler .get_exelist () == compiler .get_linker_exelist ())
811
821
812
- # Compile flags
813
- cflags_mapping = {'c' : 'CFLAGS' ,
814
- 'cpp' : 'CXXFLAGS' ,
815
- 'objc' : 'OBJCFLAGS' ,
816
- 'objcpp' : 'OBJCXXFLAGS' ,
817
- 'fortran' : 'FFLAGS' ,
818
- 'd' : 'DFLAGS' ,
819
- 'vala' : 'VALAFLAGS' }
820
-
821
822
if lang not in cflags_mapping .keys ():
822
823
return [], [], []
823
824
Original file line number Diff line number Diff line change @@ -1556,5 +1556,15 @@ def test_subdir(self):
1556
1556
self .assertEqual (s2 , self .read_contents ('sub2/meson.build' ))
1557
1557
1558
1558
1559
+ def unset_envs ():
1560
+ # For unit tests we must fully control all commend lines
1561
+ # so that there are no unexpected changes coming from the
1562
+ # environment, for example when doing a package build.
1563
+ varnames = ['CPPFLAGS' , 'LDFLAGS' ] + list (mesonbuild .environment .cflags_mapping .values ())
1564
+ for v in varnames :
1565
+ if v in os .environ :
1566
+ del os .environ [v ]
1567
+
1559
1568
if __name__ == '__main__' :
1569
+ unset_envs ()
1560
1570
unittest .main (buffer = True )
You can’t perform that action at this time.
0 commit comments