mirror of https://gitlab.com/ita1024/waf.git
Code cleanup
This commit is contained in:
parent
ed55a0c9ea
commit
4226d0cf7b
|
@ -564,9 +564,8 @@ class Node(object):
|
|||
if isdir:
|
||||
if dir:
|
||||
yield node
|
||||
else:
|
||||
if src:
|
||||
yield node
|
||||
elif src:
|
||||
yield node
|
||||
|
||||
if isdir:
|
||||
node.cache_isdir = True
|
||||
|
@ -612,24 +611,21 @@ class Node(object):
|
|||
:returns: The corresponding Nodes
|
||||
:rtype: list of :py:class:`waflib.Node.Node` instances
|
||||
"""
|
||||
|
||||
src = kw.get('src', True)
|
||||
dir = kw.get('dir', False)
|
||||
dir = kw.get('dir')
|
||||
|
||||
excl = kw.get('excl', exclude_regs)
|
||||
incl = k and k[0] or kw.get('incl', '**')
|
||||
reflags = kw.get('ignorecase', 0) and re.I
|
||||
reflags = kw.get('ignorecase', re.I)
|
||||
|
||||
def to_pat(s):
|
||||
lst = Utils.to_list(s)
|
||||
ret = []
|
||||
for x in lst:
|
||||
for x in Utils.to_list(s):
|
||||
x = x.replace('\\', '/').replace('//', '/')
|
||||
if x.endswith('/'):
|
||||
x += '**'
|
||||
lst2 = x.split('/')
|
||||
accu = []
|
||||
for k in lst2:
|
||||
for k in x.split('/'):
|
||||
if k == '**':
|
||||
accu.append(k)
|
||||
else:
|
||||
|
@ -637,9 +633,11 @@ class Node(object):
|
|||
k = '^%s$' % k
|
||||
try:
|
||||
#print "pattern", k
|
||||
accu.append(re.compile(k, flags=reflags))
|
||||
exp = re.compile(k, flags=reflags)
|
||||
except Exception as e:
|
||||
raise Errors.WafError('Invalid pattern: %s' % k, e)
|
||||
else:
|
||||
accu.append(exp)
|
||||
ret.append(accu)
|
||||
return ret
|
||||
|
||||
|
@ -667,15 +665,13 @@ class Node(object):
|
|||
return [nacc, nrej]
|
||||
|
||||
ret = [x for x in self.ant_iter(accept=accept, pats=[to_pat(incl), to_pat(excl)], maxdepth=kw.get('maxdepth', 25), dir=dir, src=src, remove=kw.get('remove', True))]
|
||||
if kw.get('flat', False):
|
||||
if kw.get('flat'):
|
||||
return ' '.join([x.path_from(self) for x in ret])
|
||||
|
||||
return ret
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# the following methods require the source/build folders (bld.srcnode/bld.bldnode)
|
||||
# using a subclass is a possibility, but is that really necessary?
|
||||
# --------------------------------------------------------------------------------
|
||||
# ----------------------------------------------------------------------------
|
||||
# the methods below require the source/build folders (bld.srcnode/bld.bldnode)
|
||||
|
||||
def is_src(self):
|
||||
"""
|
||||
|
|
|
@ -476,7 +476,7 @@ def validate_c(self, kw):
|
|||
|
||||
if not 'compile_mode' in kw:
|
||||
kw['compile_mode'] = 'c'
|
||||
if 'cxx' in Utils.to_list(kw.get('features',[])) or kw.get('compiler', '') == 'cxx':
|
||||
if 'cxx' in Utils.to_list(kw.get('features', [])) or kw.get('compiler') == 'cxx':
|
||||
kw['compile_mode'] = 'cxx'
|
||||
|
||||
if not 'type' in kw:
|
||||
|
@ -499,22 +499,19 @@ def validate_c(self, kw):
|
|||
return ''.join(['#include <%s>\n' % x for x in dct])
|
||||
return ''
|
||||
|
||||
#OSX
|
||||
if 'framework_name' in kw:
|
||||
# OSX, not sure this is used anywhere
|
||||
fwkname = kw['framework_name']
|
||||
if not 'uselib_store' in kw:
|
||||
kw['uselib_store'] = fwkname.upper()
|
||||
if not kw.get('no_header', False):
|
||||
if not 'header_name' in kw:
|
||||
kw['header_name'] = []
|
||||
if not kw.get('no_header'):
|
||||
fwk = '%s/%s.h' % (fwkname, fwkname)
|
||||
if kw.get('remove_dot_h'):
|
||||
fwk = fwk[:-2]
|
||||
kw['header_name'] = Utils.to_list(kw['header_name']) + [fwk]
|
||||
|
||||
val = kw.get('header_name', [])
|
||||
kw['header_name'] = Utils.to_list(val) + [fwk]
|
||||
kw['msg'] = 'Checking for framework %s' % fwkname
|
||||
kw['framework'] = fwkname
|
||||
#kw['frameworkpath'] = set it yourself
|
||||
|
||||
if 'function_name' in kw:
|
||||
fu = kw['function_name']
|
||||
|
@ -605,11 +602,12 @@ def validate_c(self, kw):
|
|||
kw['code'] = '\n'.join(['#include <%s>' % x for x in self.env[INCKEYS]]) + '\n' + kw['code']
|
||||
|
||||
# in case defines lead to very long command-lines
|
||||
if kw.get('merge_config_header', False) or env.merge_config_header:
|
||||
if kw.get('merge_config_header') or env.merge_config_header:
|
||||
kw['code'] = '%s\n\n%s' % (self.get_config_header(), kw['code'])
|
||||
env.DEFINES = [] # modify the copy
|
||||
|
||||
if not kw.get('success'): kw['success'] = None
|
||||
if not kw.get('success'):
|
||||
kw['success'] = None
|
||||
|
||||
if 'define_name' in kw:
|
||||
self.undefine(kw['define_name'])
|
||||
|
@ -625,7 +623,7 @@ def post_check(self, *k, **kw):
|
|||
is_success = 0
|
||||
if kw['execute']:
|
||||
if kw['success'] is not None:
|
||||
if kw.get('define_ret', False):
|
||||
if kw.get('define_ret'):
|
||||
is_success = kw['success']
|
||||
else:
|
||||
is_success = (kw['success'] == 0)
|
||||
|
@ -662,7 +660,7 @@ def post_check(self, *k, **kw):
|
|||
self.env[define_name] = int(is_success)
|
||||
|
||||
if 'header_name' in kw:
|
||||
if kw.get('auto_add_header_name', False):
|
||||
if kw.get('auto_add_header_name'):
|
||||
self.env.append_value(INCKEYS, Utils.to_list(kw['header_name']))
|
||||
|
||||
if is_success and 'uselib_store' in kw:
|
||||
|
|
|
@ -133,7 +133,7 @@ def enhance_lib():
|
|||
Logs.error("In ant_glob pattern %r: '.' means 'one dot', not 'current directory'", k[0])
|
||||
if kw.get('remove', True):
|
||||
try:
|
||||
if self.is_child_of(self.ctx.bldnode) and not kw.get('quiet', False):
|
||||
if self.is_child_of(self.ctx.bldnode) and not kw.get('quiet'):
|
||||
Logs.error('Using ant_glob on the build folder (%r) is dangerous (quiet=True to disable this warning)', self)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
@ -170,7 +170,7 @@ def enhance_lib():
|
|||
else:
|
||||
for x in ('before', 'after'):
|
||||
for y in self.to_list(getattr(self, x, [])):
|
||||
if not Task.classes.get(y, None):
|
||||
if not Task.classes.get(y):
|
||||
Logs.error('Erroneous order constraint %s=%r on %r (no such class)', x, y, self)
|
||||
TaskGen.feature('*')(check_err_order)
|
||||
|
||||
|
|
Loading…
Reference in New Issue