aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-11-08 15:53:47 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2016-11-08 17:43:24 -0500
commita2262103fb749b570c4096b43ee107ad7143c04e (patch)
tree0f92a5ddca431d391d8918c9d84ec23c32d99389
parent841380acfe682023b0df9fa76debbe3030f31daa (diff)
downloadmeson-a2262103fb749b570c4096b43ee107ad7143c04e.zip
meson-a2262103fb749b570c4096b43ee107ad7143c04e.tar.gz
meson-a2262103fb749b570c4096b43ee107ad7143c04e.tar.bz2
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
-rw-r--r--mesonbuild/backend/backends.py4
-rw-r--r--mesonbuild/backend/ninjabackend.py4
-rw-r--r--mesonbuild/build.py10
-rw-r--r--mesonbuild/mesonmain.py4
-rw-r--r--mesonbuild/mlog.py6
-rw-r--r--mesonbuild/modules/gnome.py12
-rw-r--r--mesonbuild/modules/pkgconfig.py4
-rw-r--r--mesonbuild/modules/qt4.py6
-rw-r--r--mesonbuild/modules/qt5.py6
-rw-r--r--mesonbuild/modules/rpm.py13
-rw-r--r--mesonbuild/scripts/yelphelper.py2
11 files changed, 38 insertions, 33 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index a4f2b51..bd75fdb 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.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))
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 0f8dcae..63380bd 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -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')
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index c3867e0..d87d9a0 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -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}>"
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index 943c087..500e5af 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -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):
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py
index dab51bd..cded2b0 100644
--- a/mesonbuild/mlog.py
+++ b/mesonbuild/mlog.py
@@ -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)
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 27200ae..fa8aec4 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -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()
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py
index 7556375..3ecb40d 100644
--- a/mesonbuild/modules/pkgconfig.py
+++ b/mesonbuild/modules/pkgconfig.py
@@ -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))))
diff --git a/mesonbuild/modules/qt4.py b/mesonbuild/modules/qt4.py
index 81a70fc..b1d951b 100644
--- a/mesonbuild/modules/qt4.py
+++ b/mesonbuild/modules/qt4.py
@@ -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()
diff --git a/mesonbuild/modules/qt5.py b/mesonbuild/modules/qt5.py
index 4f19b78..9fffcff 100644
--- a/mesonbuild/modules/qt5.py
+++ b/mesonbuild/modules/qt5.py
@@ -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()
diff --git a/mesonbuild/modules/rpm.py b/mesonbuild/modules/rpm.py
index 13aa20b..e9f6396 100644
--- a/mesonbuild/modules/rpm.py
+++ b/mesonbuild/modules/rpm.py
@@ -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' %
diff --git a/mesonbuild/scripts/yelphelper.py b/mesonbuild/scripts/yelphelper.py
index 00d713a..f33454d 100644
--- a/mesonbuild/scripts/yelphelper.py
+++ b/mesonbuild/scripts/yelphelper.py
@@ -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))