More cleanup

This commit is contained in:
Thomas Nagy 2016-06-05 00:23:57 +02:00
parent 75b1423ce8
commit e8ef5a89eb
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
11 changed files with 40 additions and 42 deletions

View File

@ -291,7 +291,7 @@ class ConfigurationContext(Context.Context):
for x in self.rules:
f = getattr(self, x)
if not f:
self.fatal("No such configuration function %r" % x)
self.fatal('No such configuration function %r' % x)
f()
def conf(f):
@ -471,7 +471,7 @@ def find_program(self, filename, **kw):
else:
retmsg = False
self.msg("Checking for program %r" % msg, retmsg, **kw)
self.msg('Checking for program %r' % msg, retmsg, **kw)
if not kw.get('quiet'):
self.to_log('find program=%r paths=%r var=%r -> %r' % (filename, path_list, var, ret))

View File

@ -151,7 +151,7 @@ class Context(ctx):
rd = run_dir
# binds the context to the nodes in use to avoid a context singleton
self.node_class = type("Nod3", (waflib.Node.Node,), {})
self.node_class = type('Nod3', (waflib.Node.Node,), {})
self.node_class.__module__ = "waflib.Node"
self.node_class.ctx = self
@ -317,7 +317,7 @@ class Context(ctx):
kw['stderr'] = subprocess.PIPE
if Logs.verbose and not kw['shell'] and not Utils.check_exe(cmd[0]):
raise Errors.WafError("Program %s not found!" % cmd[0])
raise Errors.WafError('Program %s not found!' % cmd[0])
wargs = {}
if 'timeout' in kw:
@ -391,7 +391,7 @@ class Context(ctx):
to_ret = STDOUT
if Logs.verbose and not kw['shell'] and not Utils.check_exe(cmd[0]):
raise Errors.WafError("Program %r not found!" % cmd[0])
raise Errors.WafError('Program %r not found!' % cmd[0])
kw['stdout'] = kw['stderr'] = subprocess.PIPE
if quiet is None:
@ -584,12 +584,12 @@ class Context(ctx):
waflibs = PyZipFile(waf_dir)
lst = waflibs.namelist()
for x in lst:
if not re.match("waflib/extras/%s" % var.replace("*", ".*"), var):
if not re.match('waflib/extras/%s' % var.replace('*', '.*'), var):
continue
f = os.path.basename(x)
doban = False
for b in ban:
r = b.replace("*", ".*")
r = b.replace('*', '.*')
if re.match(r, f):
doban = True
if not doban:

View File

@ -243,7 +243,7 @@ def error(*k, **kw):
buf.append(' File "%s", line %d, in %s' % (filename, lineno, name))
if line:
buf.append(' %s' % line.strip())
if buf: log.error("\n".join(buf))
if buf: log.error('\n'.join(buf))
def warn(*k, **kw):
"""

View File

@ -579,7 +579,7 @@ class Node(object):
#print "pattern", k
accu.append(re.compile(k, flags=reflags))
except Exception as e:
raise Errors.WafError("Invalid pattern: %s" % k, e)
raise Errors.WafError('Invalid pattern: %s' % k, e)
ret.append(accu)
return ret

View File

@ -157,7 +157,7 @@ def waf_entry_point(current_directory, version, wafdir):
if '--profile' in sys.argv:
import cProfile, pstats
cProfile.runctx("from waflib import Scripting; Scripting.run_commands()", {}, {}, 'profi.txt')
cProfile.runctx('from waflib import Scripting; Scripting.run_commands()', {}, {}, 'profi.txt')
p = pstats.Stats('profi.txt')
p.sort_stats('time').print_stats(75) # or 'cumulative'
else:

View File

@ -578,24 +578,24 @@ class Task(TaskBase):
try:
prev_sig = bld.task_sigs[key]
except KeyError:
Logs.debug("task: task %r must run: it was never run before or the task code changed", self)
Logs.debug('task: task %r must run: it was never run before or the task code changed', self)
return RUN_ME
if new_sig != prev_sig:
Logs.debug("task: task %r must run: the task signature changed", self)
Logs.debug('task: task %r must run: the task signature changed', self)
return RUN_ME
# compare the signatures of the outputs
for node in self.outputs:
sig = bld.node_sigs.get(node)
if not sig:
Logs.debug("task: task %r must run: an output node has no signature", self)
Logs.debug('task: task %r must run: an output node has no signature', self)
return RUN_ME
if sig != key:
Logs.debug("task: task %r must run: an output node was produced by another task", self)
Logs.debug('task: task %r must run: an output node was produced by another task', self)
return RUN_ME
if not node.exists():
Logs.debug("task: task %r must run: an output node does not exist", self)
Logs.debug('task: task %r must run: an output node does not exist', self)
return RUN_ME
return (self.always_run and RUN_ME) or SKIP_ME
@ -883,9 +883,9 @@ def funex(c):
exec(c, dc)
return dc['f']
re_cond = re.compile("(?P<var>\w+)|(?P<or>\|)|(?P<and>&)")
re_novar = re.compile(r"^(SRC|TGT)\W+.*?$")
reg_act = re.compile(r"(?P<backslash>\\)|(?P<dollar>\$\$)|(?P<subst>\$\{(?P<var>\w+)(?P<code>.*?)\})", re.M)
re_cond = re.compile('(?P<var>\w+)|(?P<or>\|)|(?P<and>&)')
re_novar = re.compile(r'^(SRC|TGT)\W+.*?$')
reg_act = re.compile(r'(?P<backslash>\\)|(?P<dollar>\$\$)|(?P<subst>\$\{(?P<var>\w+)(?P<code>.*?)\})', re.M)
def compile_fun_shell(line):
"""
Create a compiled function to execute a process with the shell
@ -993,12 +993,12 @@ def compile_fun_noshell(line):
if code:
app('[tsk.inputs%s]' % code)
else:
app("[a.path_from(cwdx) for a in tsk.inputs]")
app('[a.path_from(cwdx) for a in tsk.inputs]')
elif var == 'TGT':
if code:
app('[tsk.outputs%s]' % code)
else:
app("[a.path_from(cwdx) for a in tsk.outputs]")
app('[a.path_from(cwdx) for a in tsk.outputs]')
elif code:
if code.startswith(':'):
# a composed variable ${FOO:OUT}

View File

@ -96,11 +96,10 @@ def configure(conf):
import os, sys, re, tempfile
from waflib import Task, Logs, Options, Errors
from waflib.Logs import debug, warn
from waflib.TaskGen import after_method, feature
from waflib.Configure import conf
from waflib.Tools import ccroot, ar, winres
from waflib.Tools import ccroot, ar
all_ifort_platforms = [ ('intel64', 'amd64'), ('em64t', 'amd64'), ('ia32', 'x86'), ('Itanium', 'ia64')]
@ -237,10 +236,10 @@ echo LIB=%%LIB%%;%%LIBPATH%%
conf.logger.error(st)
conf.fatal('ifort: Unicode error - check the code page?')
except Exception as e:
debug('ifort: get_ifort_version: %r %r %r -> failure %s', compiler, version, target, str(e))
Logs.debug('ifort: get_ifort_version: %r %r %r -> failure %s', compiler, version, target, str(e))
conf.fatal('ifort: cannot run the compiler in get_ifort_version (run with -v to display errors)')
else:
debug('ifort: get_ifort_version: %r %r %r -> OK', compiler, version, target)
Logs.debug('ifort: get_ifort_version: %r %r %r -> OK', compiler, version, target)
finally:
conf.env[compiler_name] = ''
@ -279,7 +278,7 @@ class target_compiler(object):
self.is_done = True
try:
vs = self.conf.get_msvc_version(self.compiler, self.version, self.bat_target, self.bat)
except self.conf.errors.ConfigurationError:
except Errors.ConfigurationError:
self.is_valid = False
return
if self.callback:
@ -359,7 +358,7 @@ def find_ifort_win32(conf):
try:
conf.load('winres')
except Errors.WafError:
warn('Resource compiler not found. Compiling resource file is disabled')
Logs.warn('Resource compiler not found. Compiling resource file is disabled')
#######################################################################################################
##### conf above, build below
@ -443,7 +442,7 @@ def exec_mf(self):
elif 'fcshlib' in self.generator.features:
mode = '2'
debug('ifort: embedding manifest in mode %r', mode)
Logs.debug('ifort: embedding manifest in mode %r', mode)
lst = [] + mtool
lst.extend(Utils.to_list(env['MTFLAGS']))

View File

@ -54,11 +54,10 @@ Setting PYTHONUNBUFFERED gives the unbuffered output.
import os, sys, re, tempfile
from waflib import Utils, Task, Logs, Options, Errors
from waflib.Logs import debug, warn
from waflib.TaskGen import after_method, feature
from waflib.Configure import conf
from waflib.Tools import ccroot, c, cxx, ar, winres
from waflib.Tools import ccroot, c, cxx, ar
g_msvc_systemlibs = '''
aclui activeds ad1 adptif adsiid advapi32 asycfilt authz bhsupp bits bufferoverflowu cabinet
@ -157,7 +156,7 @@ def get_msvc_version(conf, compiler, version, target, vcvars):
:return: the location of the compiler executable, the location of include dirs, and the library paths
:rtype: tuple of strings
"""
debug('msvc: get_msvc_version: %r %r %r', compiler, version, target)
Logs.debug('msvc: get_msvc_version: %r %r %r', compiler, version, target)
try:
conf.msvc_cnt += 1
@ -209,10 +208,10 @@ echo LIB=%%LIB%%;%%LIBPATH%%
conf.logger.error(st)
conf.fatal('msvc: Unicode error - check the code page?')
except Exception as e:
debug('msvc: get_msvc_version: %r %r %r -> failure %s', compiler, version, target, str(e))
Logs.debug('msvc: get_msvc_version: %r %r %r -> failure %s', compiler, version, target, str(e))
conf.fatal('msvc: cannot run the compiler in get_msvc_version (run with -v to display errors)')
else:
debug('msvc: get_msvc_version: %r %r %r -> OK', compiler, version, target)
Logs.debug('msvc: get_msvc_version: %r %r %r -> OK', compiler, version, target)
finally:
conf.env[compiler_name] = ''
@ -367,7 +366,7 @@ class target_compiler(object):
self.is_done = True
try:
vs = self.conf.get_msvc_version(self.compiler, self.version, self.bat_target, self.bat)
except self.conf.errors.ConfigurationError:
except Errors.ConfigurationError:
self.is_valid = False
return
if self.callback:
@ -684,11 +683,11 @@ def libname_msvc(self, libname, is_static=False):
for path in _libpaths:
for libn in libnames:
if os.path.exists(os.path.join(path, libn)):
debug('msvc: lib found: %s', os.path.join(path,libn))
Logs.debug('msvc: lib found: %s', os.path.join(path,libn))
return re.sub('\.lib$', '',libn)
#if no lib can be found, just return the libname as msvc expects it
self.fatal("The library %r could not be found" % libname)
self.fatal('The library %r could not be found' % libname)
return re.sub('\.lib$', '', libname)
@conf
@ -812,8 +811,8 @@ def find_msvc(conf):
try:
conf.load('winres')
except Errors.WafError:
warn('Resource compiler not found. Compiling resource file is disabled')
except Errors.ConfigurationError:
Logs.warn('Resource compiler not found. Compiling resource file is disabled')
@conf
def visual_studio_add_flags(self):
@ -974,7 +973,7 @@ def exec_mf(self):
elif 'cshlib' in self.generator.features or 'cxxshlib' in self.generator.features:
mode = '2'
debug('msvc: embedding manifest in mode %r', mode)
Logs.debug('msvc: embedding manifest in mode %r', mode)
lst = [] + mtool
lst.extend(Utils.to_list(env['MTFLAGS']))

View File

@ -4,7 +4,7 @@
"Process *.rc* files for C/C++: X{.rc -> [.res|.rc.o]}"
import re, traceback
import re
from waflib import Task, Logs, Utils
from waflib.TaskGen import extension
from waflib.Tools import c_preproc
@ -15,7 +15,7 @@ def rc_file(self, node):
Bind the .rc extension to a winrc task
"""
obj_ext = '.rc.o'
if self.env['WINRC_TGT_F'] == '/fo':
if self.env.WINRC_TGT_F == '/fo':
obj_ext = '.res'
rctask = self.create_task('winrc', node, node.change_ext(obj_ext))
try:

View File

@ -9,7 +9,7 @@ The portability fixes try to provide a consistent behavior of the Waf API
through Python versions 2.5 to 3.X and across different platforms (win32, linux, etc)
"""
import os, sys, errno, traceback, inspect, re, shutil, datetime, platform, base64
import os, sys, errno, traceback, inspect, re, datetime, platform, base64
try:
import cPickle
except ImportError:

View File

@ -69,6 +69,6 @@ def r4(code):
return code.replace('next(self.biter)', 'self.biter.next()')
@subst('Context.py')
def r4(code):
def r5(code):
return code.replace("('Execution failure: %s'%str(e),ex=e)", "('Execution failure: %s'%str(e),ex=e),None,sys.exc_info()[2]")