diff options
-rw-r--r-- | docs/markdown/Builtin-options.md | 2 | ||||
-rw-r--r-- | docs/markdown/Configuring-a-build-directory.md | 2 | ||||
-rw-r--r-- | docs/markdown/Dependencies.md | 2 | ||||
-rw-r--r-- | docs/markdown/Reference-manual.md | 4 | ||||
-rw-r--r-- | docs/markdown/snippets/generator_with_multiple_outputs_4760.md | 3 | ||||
-rw-r--r-- | docs/markdown/snippets/warning_level_0.md | 3 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 26 | ||||
-rw-r--r-- | mesonbuild/compilers/c.py | 17 | ||||
-rw-r--r-- | mesonbuild/compilers/compilers.py | 15 | ||||
-rw-r--r-- | mesonbuild/compilers/cpp.py | 12 | ||||
-rw-r--r-- | mesonbuild/compilers/cuda.py | 3 | ||||
-rw-r--r-- | mesonbuild/compilers/d.py | 18 | ||||
-rw-r--r-- | mesonbuild/compilers/fortran.py | 18 | ||||
-rw-r--r-- | mesonbuild/compilers/objc.py | 6 | ||||
-rw-r--r-- | mesonbuild/compilers/objcpp.py | 6 | ||||
-rw-r--r-- | mesonbuild/coredata.py | 2 | ||||
-rw-r--r-- | mesonbuild/mconf.py | 16 | ||||
-rw-r--r-- | mesonbuild/mesonmain.py | 1 | ||||
-rwxr-xr-x | run_unittests.py | 31 | ||||
-rw-r--r-- | test cases/common/213 warning level 0/main.cpp | 12 | ||||
-rw-r--r-- | test cases/common/213 warning level 0/meson.build | 3 |
21 files changed, 158 insertions, 44 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/Dependencies.md b/docs/markdown/Dependencies.md index 608f3b2..e243e94 100644 --- a/docs/markdown/Dependencies.md +++ b/docs/markdown/Dependencies.md @@ -427,7 +427,7 @@ include path of the given module(s) to the compiler flags. (since v0.47.0) **Note** using private headers in your project is a bad idea, do so at your own risk. -`method` may be `auto`, `pkgconfig` or `qmake`. +`method` may be `auto`, `pkg-config` or `qmake`. ## SDL2 diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index db43813..4b61ca0 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -2133,8 +2133,8 @@ an external dependency with the following methods: partial dependency with the same rules. So , given: ```meson - dep1 = declare_dependency(compiler_args : '-Werror=foo', link_with : 'libfoo') - dep2 = declare_dependency(compiler_args : '-Werror=bar', dependencies : dep1) + dep1 = declare_dependency(compile_args : '-Werror=foo', link_with : 'libfoo') + dep2 = declare_dependency(compile_args : '-Werror=bar', dependencies : dep1) dep3 = dep2.partial_dependency(compile_args : true) ``` diff --git a/docs/markdown/snippets/generator_with_multiple_outputs_4760.md b/docs/markdown/snippets/generator_with_multiple_outputs_4760.md new file mode 100644 index 0000000..af9a751 --- /dev/null +++ b/docs/markdown/snippets/generator_with_multiple_outputs_4760.md @@ -0,0 +1,3 @@ +## Fix ninja console log from generators with multiple output nodes + +This resolves ticket #4760 where a generator w/ multiple output nodes printed an empty string to the console 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/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 5e2f863..16962a4 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1748,11 +1748,11 @@ rule FORTRAN_DEP_HACK%s outfilelist = genlist.get_outputs() extra_dependencies = [os.path.join(self.build_to_src, i) for i in genlist.extra_depends] for i in range(len(infilelist)): + curfile = infilelist[i] if len(generator.outputs) == 1: sole_output = os.path.join(self.get_target_private_dir(target), outfilelist[i]) else: - sole_output = '' - curfile = infilelist[i] + sole_output = '{}'.format(curfile) infilename = curfile.rel_to_builddir(self.build_to_src) base_args = generator.get_arglist(infilename) outfiles = genlist.get_outputs_for(curfile) @@ -1769,7 +1769,7 @@ rule FORTRAN_DEP_HACK%s for x in args] args = self.replace_outputs(args, self.get_target_private_dir(target), outfilelist) # We have consumed output files, so drop them from the list of remaining outputs. - if sole_output == '': + if len(generator.outputs) > 1: outfilelist = outfilelist[len(generator.outputs):] args = self.replace_paths(target, args, override_subdir=subdir) cmdlist = exe_arr + self.replace_extra_args(args, genlist) @@ -1792,7 +1792,11 @@ rule FORTRAN_DEP_HACK%s elem.add_item('DEPFILE', depfile) if len(extra_dependencies) > 0: elem.add_dep(extra_dependencies) - elem.add_item('DESC', 'Generating {!r}.'.format(sole_output)) + if len(generator.outputs) == 1: + elem.add_item('DESC', 'Generating {!r}.'.format(sole_output)) + else: + # since there are multiple outputs, we log the source that caused the rebuild + elem.add_item('DESC', 'Generating source from {!r}.'.format(sole_output)) if isinstance(exe, build.BuildTarget): elem.add_dep(self.get_target_filename(exe)) elem.add_item('COMMAND', cmd) @@ -2323,8 +2327,6 @@ rule FORTRAN_DEP_HACK%s if isinstance(target, build.Executable): # Currently only used with the Swift compiler to add '-emit-executable' commands += linker.get_std_exe_link_args() - # If gui_app is significant on this platform, add the appropriate linker arguments - commands += linker.get_gui_app_args(target.gui_app) # If export_dynamic, add the appropriate linker arguments if target.export_dynamic: commands += linker.gen_export_dynamic_link_args(self.environment) @@ -2357,6 +2359,15 @@ rule FORTRAN_DEP_HACK%s raise RuntimeError('Unknown build target type.') return commands + def get_target_type_link_args_post_dependencies(self, target, linker): + commands = [] + if isinstance(target, build.Executable): + # If gui_app is significant on this platform, add the appropriate linker arguments. + # Unfortunately this can't be done in get_target_type_link_args, because some misguided + # libraries (such as SDL2) add -mwindows to their link flags. + commands += linker.get_gui_app_args(target.gui_app) + return commands + def get_link_whole_args(self, linker, target): target_args = self.build_target_link_arguments(linker, target.link_whole_targets) return linker.get_link_whole_for(target_args) if len(target_args) else [] @@ -2535,6 +2546,9 @@ rule FORTRAN_DEP_HACK%s if need_threads: commands += linker.thread_link_flags(self.environment) + # Add link args specific to this BuildTarget type that must not be overridden by dependencies + commands += self.get_target_type_link_args_post_dependencies(target, linker) + # Add link args for c_* or cpp_* build options. Currently this only # adds c_winlibs and cpp_winlibs when building for Windows. This needs # to be after all internal and external libraries so that unresolved 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 65df0e7..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 ) @@ -1578,8 +1578,8 @@ class GnuLikeCompiler(abc.ABC): return ['-Wl,--allow-shlib-undefined'] def get_gui_app_args(self, value): - if self.compiler_type.is_windows_compiler and value: - return ['-mwindows'] + if self.compiler_type.is_windows_compiler: + return ['-mwindows' if value else '-mconsole'] return [] def compute_parameters_with_absolute_paths(self, parameter_list, build_dir): @@ -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 40906c5..f1580b6 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -380,6 +380,17 @@ class DCompiler(Compiler): # translate library link flag dcargs.append('-L=' + arg) continue + elif arg.startswith('-isystem'): + # translate -isystem system include path + # this flag might sometimes be added by C library Cflags via + # pkg-config. + # NOTE: -isystem and -I are not 100% equivalent, so this is just + # a workaround for the most common cases. + if arg.startswith('-isystem='): + dcargs.append('-I=' + arg[9:]) + else: + dcargs.append('-I') + continue elif arg.startswith('-L/') or arg.startswith('-L./'): # we need to handle cases where -L is set by e.g. a pkg-config # setting to select a linker search path. We can however not @@ -487,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'] @@ -558,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/mesonbuild/mconf.py b/mesonbuild/mconf.py index 18bb37b..cd9d35a 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -41,6 +41,7 @@ class Conf: if 'meson.build' in [os.path.basename(self.build_dir), self.build_dir]: self.build_dir = os.path.dirname(self.build_dir) self.build = None + self.max_choices_line_length = 60 if os.path.isdir(os.path.join(self.build_dir, 'meson-private')): self.build = build.load(self.build_dir) @@ -100,7 +101,20 @@ class Conf: if opt['choices']: choices_found = True if isinstance(opt['choices'], list): - choices_col.append('[{0}]'.format(', '.join(make_lower_case(opt['choices'])))) + choices_list = make_lower_case(opt['choices']) + current = '[' + while choices_list: + i = choices_list.pop(0) + if len(current) + len(i) >= self.max_choices_line_length: + choices_col.append(current + ',') + name_col.append('') + value_col.append('') + descr_col.append('') + current = ' ' + if len(current) > 1: + current += ', ' + current += i + choices_col.append(current + ']') else: choices_col.append(make_lower_case(opt['choices'])) else: diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index f0f287f..516c411 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -80,6 +80,7 @@ class CommandLineParser: def run_runpython_command(self, options): import runpy sys.argv[1:] = options.script_args + sys.path.insert(0, os.path.dirname(options.script_file)) runpy.run_path(options.script_file, run_name='__main__') return 0 diff --git a/run_unittests.py b/run_unittests.py index aeb56c6..e4e74d6 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) |