Implement mlog.warning and use it everywhere for warnings

Prepends the string with 'WARNING:' in ANSI yellow.

Closes https://github.com/mesonbuild/meson/issues/961
pull/1016/head
Nirbheek Chauhan 8 years ago committed by Jussi Pakkanen
parent 841380acfe
commit a2262103fb
  1. 4
      mesonbuild/backend/backends.py
  2. 4
      mesonbuild/backend/ninjabackend.py
  3. 10
      mesonbuild/build.py
  4. 4
      mesonbuild/mesonmain.py
  5. 6
      mesonbuild/mlog.py
  6. 12
      mesonbuild/modules/gnome.py
  7. 4
      mesonbuild/modules/pkgconfig.py
  8. 6
      mesonbuild/modules/qt4.py
  9. 6
      mesonbuild/modules/qt5.py
  10. 13
      mesonbuild/modules/rpm.py
  11. 2
      mesonbuild/scripts/yelphelper.py

@ -81,8 +81,8 @@ class Backend():
def get_target_filename(self, t):
if isinstance(t, build.CustomTarget):
if len(t.get_outputs()) != 1:
mlog.log(mlog.red('WARNING'), 'custom_target {!r} has more ' \
'than one output! Using the first one.'.format(t.name))
mlog.warning('custom_target {!r} has more than one output! ' \
'Using the first one.'.format(t.name))
filename = t.get_outputs()[0]
else:
assert(isinstance(t, build.BuildTarget))

@ -215,7 +215,7 @@ int dummy;
with open(os.path.join(builddir, 'compile_commands.json'), 'wb') as f:
f.write(jsondb)
except Exception:
mlog.log(mlog.red('Warning:', 'Could not create compilation database.'))
mlog.warning('Could not create compilation database.')
# Get all generated headers. Any source file might need them so
# we need to add an order dependency to them.
@ -581,7 +581,7 @@ int dummy;
elem.add_item('DESC', 'Generating HTML coverage report.')
elem.write(outfile)
if not added_rule:
mlog.log(mlog.red('Warning:'), 'coverage requested but neither gcovr nor lcov/genhtml found.')
mlog.warning('coverage requested but neither gcovr nor lcov/genhtml found.')
def generate_install(self, outfile):
install_data_file = os.path.join(self.environment.get_scratch_dir(), 'install.dat')

@ -309,8 +309,8 @@ class BuildTarget():
if not k in known_kwargs:
unknowns.append(k)
if len(unknowns) > 0:
mlog.log(mlog.bold('Warning:'), 'Unknown keyword argument(s) in target %s: %s.' %
(self.name, ', '.join(unknowns)))
mlog.warning('Unknown keyword argument(s) in target %s: %s.' %
(self.name, ', '.join(unknowns)))
def process_objectlist(self, objects):
assert(isinstance(objects, list))
@ -583,7 +583,7 @@ class BuildTarget():
if for_darwin(self.is_cross, self.environment) or for_windows(self.is_cross, self.environment):
self.pic = True
elif '-fPIC' in clist + cpplist:
mlog.log(mlog.red('WARNING:'), "Use the 'pic' kwarg instead of passing -fPIC manually to static library {!r}".format(self.name))
mlog.warning("Use the 'pic' kwarg instead of passing -fPIC manually to static library {!r}".format(self.name))
self.pic = True
else:
self.pic = kwargs.get('pic', False)
@ -1139,8 +1139,8 @@ class CustomTarget:
if k not in CustomTarget.known_kwargs:
unknowns.append(k)
if len(unknowns) > 0:
mlog.log(mlog.bold('Warning:'), 'Unknown keyword arguments in target %s: %s' %
(self.name, ', '.join(unknowns)))
mlog.warning('Unknown keyword arguments in target %s: %s' %
(self.name, ', '.join(unknowns)))
def __repr__(self):
repr_str = "<{0} {1}: {2}>"

@ -121,8 +121,8 @@ itself as required.'''
def check_pkgconfig_envvar(self, env):
curvar = os.environ.get('PKG_CONFIG_PATH', '')
if curvar != env.coredata.pkgconf_envvar:
mlog.log(mlog.red("WARNING:"), 'PKG_CONFIG_PATH has changed between invocations from "%s" to "%s".' %
(env.coredata.pkgconf_envvar, curvar))
mlog.warning('PKG_CONFIG_PATH has changed between invocations from "%s" to "%s".' %
(env.coredata.pkgconf_envvar, curvar))
env.coredata.pkgconf_envvar = curvar
def generate(self):

@ -53,6 +53,9 @@ def red(text):
def green(text):
return AnsiDecorator(text, "\033[1;32m")
def yellow(text):
return AnsiDecorator(text, "\033[1;33m")
def cyan(text):
return AnsiDecorator(text, "\033[1;36m")
@ -81,3 +84,6 @@ def log(*args, **kwargs):
if colorize_console:
arr = process_markup(args, True)
print(*arr, **kwargs)
def warning(*args, **kwargs):
log(yellow('WARNING:'), *args, **kwargs)

@ -44,10 +44,10 @@ class GnomeModule:
global gresource_warning_printed
if not gresource_warning_printed:
if mesonlib.version_compare(self._get_native_glib_version(state), '< 2.50.0'):
mlog.log('Warning, GLib compiled dependencies do not work fully '
'with versions of GLib older than 2.50.0.\n'
'See the following upstream issue:',
mlog.bold('https://bugzilla.gnome.org/show_bug.cgi?id=745754'))
mlog.warning('GLib compiled dependencies do not work fully '
'with versions of GLib older than 2.50.0.\n'
'See the following upstream issue:',
mlog.bold('https://bugzilla.gnome.org/show_bug.cgi?id=745754'))
gresource_warning_printed = True
return []
@ -136,7 +136,7 @@ class GnomeModule:
cwd=state.environment.get_source_dir())
(stdout, _) = pc.communicate()
if pc.returncode != 0:
mlog.log(mlog.bold('Warning:'), 'glib-compile-resources has failed to get the dependencies for {}'.format(cmd[1]))
mlog.warning('glib-compile-resources has failed to get the dependencies for {}'.format(cmd[1]))
raise subprocess.CalledProcessError(pc.returncode, cmd)
dep_files = stdout.split('\n')[:-1]
@ -297,7 +297,7 @@ class GnomeModule:
except Exception:
global girwarning_printed
if not girwarning_printed:
mlog.log(mlog.bold('Warning:'), 'gobject-introspection dependency was not found, disabling gir generation.')
mlog.warning('gobject-introspection dependency was not found, disabling gir generation.')
girwarning_printed = True
return []
pkgargs = pkgstr.decode().strip().split()

@ -34,7 +34,7 @@ class PkgConfigModule:
return l.name
# In other cases, we can't guarantee that the compiler will be able to
# find the library via '-lfoo', so tell the user that.
mlog.log(mlog.red('WARNING:'), msg.format(l.name, 'name_prefix', l.name, pcfile))
mlog.warning(msg.format(l.name, 'name_prefix', l.name, pcfile))
return l.name
def generate_pkgconfig_file(self, state, libraries, subdirs, name, description,
@ -79,7 +79,7 @@ class PkgConfigModule:
# If using a custom suffix, the compiler may not be able to
# find the library
if l.name_suffix_set:
mlog.log(mlog.red('WARNING:'), msg.format(l.name, 'name_suffix', lname, pcfile))
mlog.warning(msg.format(l.name, 'name_suffix', lname, pcfile))
yield '-l%s' % lname
if len(libraries) > 0:
ofile.write('Libs: {}\n'.format(' '.join(generate_libs_flags(libraries))))

@ -90,7 +90,7 @@ class Qt4Module():
result = []
for child in root[0]:
if child.tag != 'file':
mlog.log("Warning, malformed rcc file: ", os.path.join(state.subdir, fname))
mlog.warning("malformed rcc file: ", os.path.join(state.subdir, fname))
break
else:
result.append(os.path.join(state.subdir, relative_part, child.text))
@ -150,6 +150,6 @@ class Qt4Module():
return sources
def initialize():
mlog.log('Warning, rcc dependencies will not work properly until this upstream issue is fixed:',
mlog.bold('https://bugreports.qt.io/browse/QTBUG-45460'))
mlog.warning('rcc dependencies will not work properly until this upstream issue is fixed:',
mlog.bold('https://bugreports.qt.io/browse/QTBUG-45460'))
return Qt4Module()

@ -97,7 +97,7 @@ class Qt5Module():
result = []
for child in root[0]:
if child.tag != 'file':
mlog.log("Warning, malformed rcc file: ", os.path.join(state.subdir, fname))
mlog.warning("malformed rcc file: ", os.path.join(state.subdir, fname))
break
else:
result.append(os.path.join(state.subdir, relative_part, child.text))
@ -160,6 +160,6 @@ class Qt5Module():
return sources
def initialize():
mlog.log('Warning, rcc dependencies will not work reliably until this upstream issue is fixed:',
mlog.bold('https://bugreports.qt.io/browse/QTBUG-45460'))
mlog.warning('rcc dependencies will not work reliably until this upstream issue is fixed:',
mlog.bold('https://bugreports.qt.io/browse/QTBUG-45460'))
return Qt5Module()

@ -63,8 +63,8 @@ class RPMModule:
so_installed = True
elif isinstance(target, build.StaticLibrary) and target.need_install:
to_delete.add('%%{buildroot}%%{_libdir}/%s' % target.get_filename())
mlog.log('Warning, removing', mlog.bold(target.get_filename()),
'from package because packaging static libs not recommended')
mlog.warning('removing', mlog.bold(target.get_filename()),
'from package because packaging static libs not recommended')
elif isinstance(target, gnome.GirTarget) and target.should_install():
files_devel.add('%%{_datadir}/gir-1.0/%s' % target.get_filename()[0])
elif isinstance(target, gnome.TypelibTarget) and target.should_install():
@ -97,11 +97,10 @@ class RPMModule:
fn.write('BuildRequires: pkgconfig(%s)\n' % dep)
for lib in state.environment.coredata.ext_libs.values():
fn.write('BuildRequires: %s # FIXME\n' % lib.fullpath)
mlog.log('Warning, replace', mlog.bold(lib.fullpath),
'with real package.',
'You can use following command to find package which '
'contains this lib:',
mlog.bold('dnf provides %s' % lib.fullpath))
mlog.warning('replace', mlog.bold(lib.fullpath), 'with real package.',
'You can use following command to find package which '
'contains this lib:',
mlog.bold('dnf provides %s' % lib.fullpath))
for prog in state.environment.coredata.ext_progs.values():
if not prog.found():
fn.write('BuildRequires: %{_bindir}/%s # FIXME\n' %

@ -75,7 +75,7 @@ def install_help(srcdir, blddir, sources, media, langs, install_dir, destdir, pr
outfile = os.path.join(indir, m)
if not os.path.exists(infile):
if lang == 'C':
mlog.log(mlog.bold('Warning:'), 'Media file "%s" did not exist in C directory' %m)
mlog.warning('Media file "%s" did not exist in C directory' %m)
elif symlinks:
srcfile = os.path.join(c_install_dir, m)
mlog.log('Symlinking %s to %s.' %(outfile, srcfile))

Loading…
Cancel
Save