aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/Builtin-options.md2
-rw-r--r--docs/markdown/Configuring-a-build-directory.md2
-rw-r--r--docs/markdown/snippets/warning_level_0.md3
-rw-r--r--mesonbuild/compilers/c.py17
-rw-r--r--mesonbuild/compilers/compilers.py11
-rw-r--r--mesonbuild/compilers/cpp.py12
-rw-r--r--mesonbuild/compilers/cuda.py3
-rw-r--r--mesonbuild/compilers/d.py7
-rw-r--r--mesonbuild/compilers/fortran.py18
-rw-r--r--mesonbuild/compilers/objc.py6
-rw-r--r--mesonbuild/compilers/objcpp.py6
-rw-r--r--mesonbuild/coredata.py2
-rwxr-xr-xrun_unittests.py31
-rw-r--r--test cases/common/213 warning level 0/main.cpp12
-rw-r--r--test cases/common/213 warning level 0/meson.build3
15 files changed, 103 insertions, 32 deletions
diff --git a/docs/markdown/Builtin-options.md b/docs/markdown/Builtin-options.md
index 0d1a16b..5db6e02 100644
--- a/docs/markdown/Builtin-options.md
+++ b/docs/markdown/Builtin-options.md
@@ -40,7 +40,7 @@ Installation options are all relative to the prefix, except:
| localstatedir | var | Localstate data directory |
| sharedstatedir | com | Architecture-independent data directory |
| werror | false | Treat warnings as errors |
-| warning_level {1, 2, 3} | 1 | Set the warning level. From 1 = lowest to 3 = highest |
+| warning_level {0, 1, 2, 3} | 1 | Set the warning level. From 0 = none to 3 = highest |
| layout {mirror,flat} | mirror | Build directory layout. |
| default_library {shared, static, both} | shared | Default library type. |
| backend {ninja, vs,<br>vs2010, vs2015, vs2017, xcode} | | Backend to use (default: ninja). |
diff --git a/docs/markdown/Configuring-a-build-directory.md b/docs/markdown/Configuring-a-build-directory.md
index 91ad6f7..ddda6fe 100644
--- a/docs/markdown/Configuring-a-build-directory.md
+++ b/docs/markdown/Configuring-a-build-directory.md
@@ -33,7 +33,7 @@ sample output for a simple project.
optimization 3 [0, g, 1, 2, 3, s] Optimization level
strip false [true, false] Strip targets on install
unity off [on, off, subprojects] Unity build
- warning_level 1 [1, 2, 3] Compiler warning level to use
+ warning_level 1 [0, 1, 2, 3] Compiler warning level to use
werror false [true, false] Treat warnings as errors
Backend options:
diff --git a/docs/markdown/snippets/warning_level_0.md b/docs/markdown/snippets/warning_level_0.md
new file mode 100644
index 0000000..4836b14
--- /dev/null
+++ b/docs/markdown/snippets/warning_level_0.md
@@ -0,0 +1,3 @@
+## Add warning_level 0 option
+
+Adds support for a warning level 0 which does not enable any static analysis checks from the compiler
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index a1a8fb9..3f3aba8 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -1152,7 +1152,7 @@ class CCompiler(Compiler):
# flags, so when we are testing a flag like "-Wno-forgotten-towel", also
# check the equivalent enable flag too "-Wforgotten-towel"
if arg.startswith('-Wno-'):
- args.append('-W' + arg[5:])
+ args.append('-W' + arg[5:])
if arg.startswith('-Wl,'):
mlog.warning('{} looks like a linker argument, '
'but has_argument and other similar methods only '
@@ -1209,7 +1209,8 @@ class ClangCCompiler(ClangCompiler, CCompiler):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)
ClangCompiler.__init__(self, compiler_type)
default_warn_args = ['-Wall', '-Winvalid-pch']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
@@ -1243,7 +1244,8 @@ class ArmclangCCompiler(ArmclangCompiler, CCompiler):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)
ArmclangCompiler.__init__(self, compiler_type)
default_warn_args = ['-Wall', '-Winvalid-pch']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
@@ -1271,7 +1273,8 @@ class GnuCCompiler(GnuCompiler, CCompiler):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)
GnuCompiler.__init__(self, compiler_type, defines)
default_warn_args = ['-Wall', '-Winvalid-pch']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
@@ -1341,7 +1344,8 @@ class IntelCCompiler(IntelCompiler, CCompiler):
IntelCompiler.__init__(self, compiler_type)
self.lang_header = 'c-header'
default_warn_args = ['-Wall', '-w3', '-diag-disable:remark']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra']}
@@ -1383,7 +1387,8 @@ class VisualStudioCCompiler(CCompiler):
# /showIncludes is needed for build dependency tracking in Ninja
# See: https://ninja-build.org/manual.html#_deps
self.always_args = ['/nologo', '/showIncludes']
- self.warn_args = {'1': ['/W2'],
+ self.warn_args = {'0': ['/W1'],
+ '1': ['/W2'],
'2': ['/W3'],
'3': ['/W4']}
self.base_options = ['b_pch', 'b_ndebug', 'b_vscrt'] # FIXME add lto, pgo and the like
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 3d4cce8..7955f3d 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -21,7 +21,7 @@ from .. import coredata
from .. import mlog
from .. import mesonlib
from ..mesonlib import (
- EnvironmentException, MachineChoice, MesonException, OrderedSet,
+ EnvironmentException, MesonException, OrderedSet,
version_compare, Popen_safe
)
@@ -1636,7 +1636,8 @@ class PGICompiler:
self.compiler_type = compiler_type
default_warn_args = ['-Minform=inform']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args,
'3': default_warn_args}
@@ -1937,7 +1938,8 @@ class ArmCompiler:
self.id = 'arm'
self.compiler_type = compiler_type
default_warn_args = []
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + [],
'3': default_warn_args + []}
# Assembly
@@ -2029,7 +2031,8 @@ class CcrxCompiler:
# Assembly
self.can_compile_suffixes.update('s')
default_warn_args = []
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + [],
'3': default_warn_args + []}
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index bad71f6..67de684 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -135,7 +135,8 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler):
CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)
ClangCompiler.__init__(self, compiler_type)
default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
@@ -166,7 +167,8 @@ class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler):
CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)
ArmclangCompiler.__init__(self, compiler_type)
default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
@@ -194,7 +196,8 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler):
CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap, **kwargs)
GnuCompiler.__init__(self, compiler_type, defines)
default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
@@ -272,7 +275,8 @@ class IntelCPPCompiler(IntelCompiler, CPPCompiler):
self.lang_header = 'c++-header'
default_warn_args = ['-Wall', '-w3', '-diag-disable:remark',
'-Wpch-messages', '-Wnon-virtual-dtor']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra']}
diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py
index 1ea67d3..66dcf33 100644
--- a/mesonbuild/compilers/cuda.py
+++ b/mesonbuild/compilers/cuda.py
@@ -28,7 +28,8 @@ class CudaCompiler(Compiler):
self.exe_wrapper = exe_wrapper
self.id = 'nvcc'
default_warn_args = []
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Xcompiler=-Wextra'],
'3': default_warn_args + ['-Xcompiler=-Wextra',
'-Xcompiler=-Wpedantic']}
diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py
index afc287f..f1580b6 100644
--- a/mesonbuild/compilers/d.py
+++ b/mesonbuild/compilers/d.py
@@ -498,7 +498,8 @@ class GnuDCompiler(DCompiler):
DCompiler.__init__(self, exelist, version, is_cross, arch, **kwargs)
self.id = 'gcc'
default_warn_args = ['-Wall', '-Wdeprecated']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
self.base_options = ['b_colorout', 'b_sanitize', 'b_staticpic', 'b_vscrt']
@@ -569,8 +570,10 @@ class LLVMDCompiler(DCompiler):
def get_warn_args(self, level):
if level == '2' or level == '3':
return ['-wi', '-dw']
- else:
+ elif level == '1':
return ['-wi']
+ else:
+ return []
def get_buildtype_args(self, buildtype):
if buildtype != 'plain':
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index 59c4214..6c260b6 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -280,7 +280,8 @@ class GnuFortranCompiler(GnuCompiler, FortranCompiler):
FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)
GnuCompiler.__init__(self, compiler_type, defines)
default_warn_args = ['-Wall']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
@@ -307,7 +308,8 @@ class G95FortranCompiler(FortranCompiler):
FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags)
self.id = 'g95'
default_warn_args = ['-Wall']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-pedantic']}
@@ -352,7 +354,8 @@ class IntelFortranCompiler(IntelCompiler, FortranCompiler):
IntelCompiler.__init__(self, CompilerType.ICC_STANDARD)
self.id = 'intel'
default_warn_args = ['-warn', 'general', '-warn', 'truncated_source']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-warn', 'unused'],
'3': ['-warn', 'all']}
@@ -374,7 +377,8 @@ class PathScaleFortranCompiler(FortranCompiler):
FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags)
self.id = 'pathscale'
default_warn_args = ['-fullwarn']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args,
'3': default_warn_args}
@@ -394,7 +398,8 @@ class FlangFortranCompiler(ClangCompiler, FortranCompiler):
ClangCompiler.__init__(self, CompilerType.CLANG_STANDARD)
self.id = 'flang'
default_warn_args = ['-Minform=inform']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args,
'3': default_warn_args}
@@ -403,7 +408,8 @@ class Open64FortranCompiler(FortranCompiler):
FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags)
self.id = 'open64'
default_warn_args = ['-fullwarn']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args,
'3': default_warn_args}
diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py
index cf58ffb..8dfd0a2 100644
--- a/mesonbuild/compilers/objc.py
+++ b/mesonbuild/compilers/objc.py
@@ -55,7 +55,8 @@ class GnuObjCCompiler(GnuCompiler, ObjCCompiler):
ObjCCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
GnuCompiler.__init__(self, compiler_type, defines)
default_warn_args = ['-Wall', '-Winvalid-pch']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
@@ -65,7 +66,8 @@ class ClangObjCCompiler(ClangCompiler, ObjCCompiler):
ObjCCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
ClangCompiler.__init__(self, compiler_type)
default_warn_args = ['-Wall', '-Winvalid-pch']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage']
diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py
index add888f..e66d730 100644
--- a/mesonbuild/compilers/objcpp.py
+++ b/mesonbuild/compilers/objcpp.py
@@ -53,7 +53,8 @@ class GnuObjCPPCompiler(GnuCompiler, ObjCPPCompiler):
ObjCPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
GnuCompiler.__init__(self, compiler_type, defines)
default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
@@ -63,7 +64,8 @@ class ClangObjCPPCompiler(ClangCompiler, ObjCPPCompiler):
ObjCPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
ClangCompiler.__init__(self, compiler_type)
default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
- self.warn_args = {'1': default_warn_args,
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage']
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index a026584..0e11f5c 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -834,7 +834,7 @@ builtin_options = {
'localstatedir': [UserStringOption, 'Localstate data directory', 'var'],
'sharedstatedir': [UserStringOption, 'Architecture-independent data directory', 'com'],
'werror': [UserBooleanOption, 'Treat warnings as errors', False],
- 'warning_level': [UserComboOption, 'Compiler warning level to use', ['1', '2', '3'], '1'],
+ 'warning_level': [UserComboOption, 'Compiler warning level to use', ['0', '1', '2', '3'], '1'],
'layout': [UserComboOption, 'Build directory layout', ['mirror', 'flat'], 'mirror'],
'default_library': [UserComboOption, 'Default library type', ['shared', 'static', 'both'], 'shared'],
'backend': [UserComboOption, 'Backend to use', backendlist, 'ninja'],
diff --git a/run_unittests.py b/run_unittests.py
index f63fc18..c855edf 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -63,7 +63,7 @@ from run_tests import (
def get_dynamic_section_entry(fname, entry):
if is_cygwin() or is_osx():
- raise unittest.SkipTest('Test only applicable to ELF platforms')
+ raise unittest.SkipTest('Test only applicable to ELF platforms')
try:
raw_out = subprocess.check_output(['readelf', '-d', fname],
@@ -1642,7 +1642,7 @@ class AllPlatformTests(BasePlatformTests):
def test_testsetups(self):
if not shutil.which('valgrind'):
- raise unittest.SkipTest('Valgrind not installed.')
+ raise unittest.SkipTest('Valgrind not installed.')
testdir = os.path.join(self.unit_test_dir, '2 testsetups')
self.init(testdir)
self.build()
@@ -2970,6 +2970,33 @@ recommended as it is not supported on some platforms''')
# they used to fail this test with Meson 0.46 an earlier versions.
pass
+ def test_warning_level_0(self):
+ testdir = os.path.join(self.common_test_dir, '213 warning level 0')
+
+ # Verify default values when passing no args
+ self.init(testdir)
+ obj = mesonbuild.coredata.load(self.builddir)
+ self.assertEqual(obj.builtins['warning_level'].value, '0')
+ self.wipe()
+
+ # verify we can override w/ --warnlevel
+ self.init(testdir, extra_args=['--warnlevel=1'])
+ obj = mesonbuild.coredata.load(self.builddir)
+ self.assertEqual(obj.builtins['warning_level'].value, '1')
+ self.setconf('--warnlevel=0')
+ obj = mesonbuild.coredata.load(self.builddir)
+ self.assertEqual(obj.builtins['warning_level'].value, '0')
+ self.wipe()
+
+ # verify we can override w/ -Dwarning_level
+ self.init(testdir, extra_args=['-Dwarning_level=1'])
+ obj = mesonbuild.coredata.load(self.builddir)
+ self.assertEqual(obj.builtins['warning_level'].value, '1')
+ self.setconf('-Dwarning_level=0')
+ obj = mesonbuild.coredata.load(self.builddir)
+ self.assertEqual(obj.builtins['warning_level'].value, '0')
+ self.wipe()
+
def test_feature_check_usage_subprojects(self):
testdir = os.path.join(self.unit_test_dir, '41 featurenew subprojects')
out = self.init(testdir)
diff --git a/test cases/common/213 warning level 0/main.cpp b/test cases/common/213 warning level 0/main.cpp
new file mode 100644
index 0000000..954d9ce
--- /dev/null
+++ b/test cases/common/213 warning level 0/main.cpp
@@ -0,0 +1,12 @@
+#include <iostream>
+
+#define PROJECT_NAME "demo"
+
+int main(int argc, char **argv) {
+ if(argc != 1) {
+ std::cout << argv[0] << "takes no arguments.\n";
+ return 1;
+ }
+ std::cout << "This is project " << PROJECT_NAME << ".\n";
+ return 0;
+}
diff --git a/test cases/common/213 warning level 0/meson.build b/test cases/common/213 warning level 0/meson.build
new file mode 100644
index 0000000..f2bd339
--- /dev/null
+++ b/test cases/common/213 warning level 0/meson.build
@@ -0,0 +1,3 @@
+project('warning_level', 'cpp', default_options : ['warning_level=0'])
+
+exe = executable('main', 'main.cpp', install : false)