diff options
author | Xavier Claessens <xclaesse@gmail.com> | 2018-09-05 10:36:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-05 10:36:42 -0400 |
commit | b3a35f92b4955120e142e34f8a4f0afd348e2bcb (patch) | |
tree | 90f842fcff5569c64194f766910cc7d6ce9ed606 /mesonbuild | |
parent | 226eaba369c3c7d1d4efd4e766855e3cbd6c688c (diff) | |
parent | ef231d3edd01df4d3e0f55ccc6f1c683f1bb112f (diff) | |
download | meson-b3a35f92b4955120e142e34f8a4f0afd348e2bcb.zip meson-b3a35f92b4955120e142e34f8a4f0afd348e2bcb.tar.gz meson-b3a35f92b4955120e142e34f8a4f0afd348e2bcb.tar.bz2 |
Merge pull request #4006 from xclaesse/fatal-warnings
Add --fatal-meson-warnings command line option
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/mesonmain.py | 4 | ||||
-rw-r--r-- | mesonbuild/mlog.py | 11 |
2 files changed, 12 insertions, 3 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 7dddb58..b150731 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -41,6 +41,8 @@ def create_parser(): help='Special wrap mode to use') p.add_argument('--profile-self', action='store_true', dest='profile', 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('sourcedir', nargs='?', default=None) return p @@ -110,7 +112,7 @@ class MesonApp: def generate(self): 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: mlog.set_timestamp_start(time.monotonic()) with mesonlib.BuildDirLock(self.build_dir): diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index b8d3ccc..095b8fd 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -46,11 +46,13 @@ log_file = None log_fname = 'meson-log.txt' log_depth = 0 log_timestamp_start = None +log_fatal_warnings = False -def initialize(logdir): - global log_dir, log_file +def initialize(logdir, fatal_warnings=False): + global log_dir, log_file, log_fatal_warnings log_dir = logdir log_file = open(os.path.join(logdir, log_fname), 'w', encoding='utf8') + log_fatal_warnings = fatal_warnings def set_timestamp_start(start): global log_timestamp_start @@ -145,6 +147,7 @@ def log(*args, **kwargs): def _log_error(severity, *args, **kwargs): from .mesonlib import get_error_location_string from .environment import build_filename + from .mesonlib import MesonException if severity == 'warning': args = (yellow('WARNING:'),) + args elif severity == 'error': @@ -162,6 +165,10 @@ def _log_error(severity, *args, **kwargs): log(*args, **kwargs) + global log_fatal_warnings + if log_fatal_warnings: + raise MesonException("Fatal warnings enabled, aborting") + def error(*args, **kwargs): return _log_error('error', *args, **kwargs) |