2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-23 02:16:01 +01:00

Issue 1276 - suppress configuration outputs

This commit is contained in:
Thomas Nagy 2014-02-02 04:04:21 +01:00
parent d15bf94934
commit 8faafeb913
3 changed files with 34 additions and 27 deletions

View File

@ -434,7 +434,7 @@ def cmd_to_list(self, cmd):
return cmd
@conf
def check_waf_version(self, mini='1.7.99', maxi='1.9.0'):
def check_waf_version(self, mini='1.7.99', maxi='1.9.0', **kw):
"""
Raise a Configuration error if the Waf version does not strictly match the given bounds::
@ -445,14 +445,13 @@ def check_waf_version(self, mini='1.7.99', maxi='1.9.0'):
:type maxi: number, tuple or string
:param maxi: Maximum allowed version
"""
self.start_msg('Checking for waf version in %s-%s' % (str(mini), str(maxi)))
self.start_msg('Checking for waf version in %s-%s' % (str(mini), str(maxi)), **kw)
ver = Context.HEXVERSION
if Utils.num2ver(mini) > ver:
self.fatal('waf version should be at least %r (%r found)' % (Utils.num2ver(mini), ver))
if Utils.num2ver(maxi) < ver:
self.fatal('waf version should be at most %r (%r found)' % (Utils.num2ver(maxi), ver))
self.end_msg('ok')
self.end_msg('ok', **kw)
@conf
def find_file(self, filename, path_list=[]):
@ -493,7 +492,7 @@ def find_program(self, filename, **kw):
exts = kw.get('exts', Utils.is_win32 and '.exe,.com,.bat,.cmd' or ',.sh,.pl,.py')
environ = kw.get('environ', self.environ)
environ = kw.get('environ', getattr(self, 'environ', os.environ))
ret = ''
filename = Utils.to_list(filename)
@ -524,8 +523,9 @@ def find_program(self, filename, **kw):
if not ret and Utils.winreg:
ret = Utils.get_registry_app_path(Utils.winreg.HKEY_LOCAL_MACHINE, filename)
self.msg("Checking for program '%s'" % msg, ret or False)
self.to_log('find program=%r paths=%r var=%r -> %r' % (filename, path_list, var, ret))
self.msg("Checking for program '%s'" % msg, ret or False, **kw)
if not kw.get('quiet', None):
self.to_log('find program=%r paths=%r var=%r -> %r' % (filename, path_list, var, ret))
if not ret:
self.fatal(kw.get('errmsg', '') or 'Could not find the program %s' % ','.join(filename))

View File

@ -6,7 +6,7 @@
Classes and functions required for waf commands
"""
import os, imp, sys
import os, re, imp, sys
from waflib import Utils, Errors, Logs
import waflib.Node
@ -465,7 +465,7 @@ class Context(ctx):
sys.stderr.flush()
def msg(self, msg, result, color=None):
def msg(self, msg, result, color=None, **kw):
"""
Print a configuration message of the form ``msg: result``.
The second part of the message will be in colors. The output
@ -483,17 +483,21 @@ class Context(ctx):
:param color: color to use, see :py:const:`waflib.Logs.colors_lst`
:type color: string
"""
self.start_msg(msg)
self.start_msg(msg, **kw)
if not isinstance(color, str):
color = result and 'GREEN' or 'YELLOW'
self.end_msg(result, color)
self.end_msg(result, color, **kw)
def start_msg(self, msg):
def start_msg(self, *k, **kw):
"""
Print the beginning of a 'Checking for xxx' message. See :py:meth:`waflib.Context.Context.msg`
"""
if kw.get('quiet', None):
return
msg = kw.get('msg', None) or k[0]
try:
if self.in_msg:
self.in_msg += 1
@ -510,12 +514,16 @@ class Context(ctx):
self.to_log(x)
Logs.pprint('NORMAL', "%s :" % msg.ljust(self.line_just), sep='')
def end_msg(self, result, color=None):
def end_msg(self, *k, **kw):
"""Print the end of a 'Checking for' message. See :py:meth:`waflib.Context.Context.msg`"""
if kw.get('quiet', None):
return
self.in_msg -= 1
if self.in_msg:
return
result = kw.get('result', None) or k[0]
defcolor = 'GREEN'
if result == True:
msg = 'ok'
@ -526,8 +534,7 @@ class Context(ctx):
msg = str(result)
self.to_log(msg)
Logs.pprint(color or defcolor, msg)
Logs.pprint(kw.get('color', defcolor), msg)
def load_special_tools(self, var, ban=[]):
global waf_dir
@ -538,7 +545,6 @@ class Context(ctx):
load_tool(x.name.replace('.py', ''))
else:
from zipfile import PyZipFile
import re
waflibs = PyZipFile(waf_dir)
lst = waflibs.namelist()
for x in lst:

View File

@ -380,13 +380,13 @@ def check_cfg(self, *k, **kw):
self.validate_cfg(kw)
if 'msg' in kw:
self.start_msg(kw['msg'])
self.start_msg(kw['msg'], **kw)
ret = None
try:
ret = self.exec_cfg(kw)
except self.errors.WafError:
if 'errmsg' in kw:
self.end_msg(kw['errmsg'], 'YELLOW')
self.end_msg(kw['errmsg'], 'YELLOW', **kw)
if Logs.verbose > 1:
raise
else:
@ -398,7 +398,7 @@ def check_cfg(self, *k, **kw):
if 'define_name' in kw:
self.define(kw['define_name'], 1)
if 'okmsg' in kw:
self.end_msg(self.ret_msg(kw['okmsg'], kw))
self.end_msg(self.ret_msg(kw['okmsg'], kw), **kw)
return ret
@ -637,12 +637,12 @@ def check(self, *k, **kw):
To force a specific compiler, prefer the methods :py:func:`waflib.Tools.c_config.check_cxx` or :py:func:`waflib.Tools.c_config.check_cc`
"""
self.validate_c(kw)
self.start_msg(kw['msg'])
self.start_msg(kw['msg'], **kw)
ret = None
try:
ret = self.run_c_code(*k, **kw)
except self.errors.ConfigurationError:
self.end_msg(kw['errmsg'], 'YELLOW')
self.end_msg(kw['errmsg'], 'YELLOW', **kw)
if Logs.verbose > 1:
raise
else:
@ -652,10 +652,10 @@ def check(self, *k, **kw):
ret = self.post_check(*k, **kw)
if not ret:
self.end_msg(kw['errmsg'], 'YELLOW')
self.end_msg(kw['errmsg'], 'YELLOW', **kw)
self.fatal('The configuration failed %r' % ret)
else:
self.end_msg(self.ret_msg(kw['okmsg'], kw))
self.end_msg(self.ret_msg(kw['okmsg'], kw), **kw)
return ret
class test_exec(Task.Task):
@ -776,7 +776,8 @@ def run_c_code(self, *k, **kw):
for k, v in kw.items():
setattr(o, k, v)
self.to_log("==>\n%s\n<==" % kw['code'])
if not kw.get('quiet', None):
self.to_log("==>\n%s\n<==" % kw['code'])
# compile the program
bld.targets = '*'
@ -1226,7 +1227,7 @@ def multicheck(self, *k, **kw):
"""
Use tuples to perform parallel configuration tests
"""
self.start_msg(kw.get('msg', 'Executing %d configuration tests' % len(k)))
self.start_msg(kw.get('msg', 'Executing %d configuration tests' % len(k)), **kw)
class par(object):
def __init__(self):
@ -1265,8 +1266,8 @@ def multicheck(self, *k, **kw):
for x in tasks:
if x.hasrun != Task.SUCCESS:
self.end_msg(kw.get('errmsg', 'no'), color='YELLOW')
self.end_msg(kw.get('errmsg', 'no'), color='YELLOW', **kw)
self.fatal(kw.get('fatalmsg', None) or 'One of the tests has failed, see the config.log for more information')
self.end_msg('ok')
self.end_msg('ok', **kw)