Merge pull request #4006 from xclaesse/fatal-warnings

Add --fatal-meson-warnings command line option
pull/4077/head
Xavier Claessens 6 years ago committed by GitHub
commit b3a35f92b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      docs/markdown/snippets/fatal_warnings.md
  2. 4
      mesonbuild/mesonmain.py
  3. 11
      mesonbuild/mlog.py

@ -0,0 +1,6 @@
## Fatal warnings
A new command line option has been added: `--fatal-meson-warnings`. When enabled, any
warning message printed by Meson will be fatal and raise an exception. It is
intended to be used by developers and CIs to easily catch deprecation warnings,
or any other potential issues.

@ -41,6 +41,8 @@ def create_parser():
help='Special wrap mode to use') help='Special wrap mode to use')
p.add_argument('--profile-self', action='store_true', dest='profile', p.add_argument('--profile-self', action='store_true', dest='profile',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
p.add_argument('--fatal-meson-warnings', action='store_true', dest='fatal_warnings',
help='Make all Meson warnings fatal')
p.add_argument('builddir', nargs='?', default=None) p.add_argument('builddir', nargs='?', default=None)
p.add_argument('sourcedir', nargs='?', default=None) p.add_argument('sourcedir', nargs='?', default=None)
return p return p
@ -110,7 +112,7 @@ class MesonApp:
def generate(self): def generate(self):
env = environment.Environment(self.source_dir, self.build_dir, self.options) env = environment.Environment(self.source_dir, self.build_dir, self.options)
mlog.initialize(env.get_log_dir()) mlog.initialize(env.get_log_dir(), self.options.fatal_warnings)
if self.options.profile: if self.options.profile:
mlog.set_timestamp_start(time.monotonic()) mlog.set_timestamp_start(time.monotonic())
with mesonlib.BuildDirLock(self.build_dir): with mesonlib.BuildDirLock(self.build_dir):

@ -46,11 +46,13 @@ log_file = None
log_fname = 'meson-log.txt' log_fname = 'meson-log.txt'
log_depth = 0 log_depth = 0
log_timestamp_start = None log_timestamp_start = None
log_fatal_warnings = False
def initialize(logdir): def initialize(logdir, fatal_warnings=False):
global log_dir, log_file global log_dir, log_file, log_fatal_warnings
log_dir = logdir log_dir = logdir
log_file = open(os.path.join(logdir, log_fname), 'w', encoding='utf8') log_file = open(os.path.join(logdir, log_fname), 'w', encoding='utf8')
log_fatal_warnings = fatal_warnings
def set_timestamp_start(start): def set_timestamp_start(start):
global log_timestamp_start global log_timestamp_start
@ -145,6 +147,7 @@ def log(*args, **kwargs):
def _log_error(severity, *args, **kwargs): def _log_error(severity, *args, **kwargs):
from .mesonlib import get_error_location_string from .mesonlib import get_error_location_string
from .environment import build_filename from .environment import build_filename
from .mesonlib import MesonException
if severity == 'warning': if severity == 'warning':
args = (yellow('WARNING:'),) + args args = (yellow('WARNING:'),) + args
elif severity == 'error': elif severity == 'error':
@ -162,6 +165,10 @@ def _log_error(severity, *args, **kwargs):
log(*args, **kwargs) log(*args, **kwargs)
global log_fatal_warnings
if log_fatal_warnings:
raise MesonException("Fatal warnings enabled, aborting")
def error(*args, **kwargs): def error(*args, **kwargs):
return _log_error('error', *args, **kwargs) return _log_error('error', *args, **kwargs)

Loading…
Cancel
Save