本文整理汇总了Python中waflib.TaskGen类的典型用法代码示例。如果您正苦于以下问题:Python TaskGen类的具体用法?Python TaskGen怎么用?Python TaskGen使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TaskGen类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enable_support
def enable_support(cc, cxx):
if cxx or not cc:
make_cxx_batch = TaskGen.extension(".cpp", ".cc", ".cxx", ".C", ".c++")(make_batch_fun("cxx"))
if cc:
make_c_batch = TaskGen.extension(".c")(make_batch_fun("c"))
else:
TaskGen.task_gen.mappings[".c"] = TaskGen.task_gen.mappings[".cpp"]
示例2: _build_pdf
def _build_pdf(ctx):
from waflib import TaskGen
TaskGen.declare_chain(
name = 'rst2latex',
rule = '${RST2LATEX} ${RST2LATEX_FLAGS} ${SRC} ${TGT}',
ext_in = '.rst',
ext_out = '.tex' )
TaskGen.declare_chain(
name = 'pdflatex',
rule = '${PDFLATEX} ${PDFLATEX_FLAGS} ${SRC}; ' * 2,
ext_in = '.tex',
ext_out = '.pdf',
shell = True )
ctx.env.RST2LATEX_FLAGS = [
'--config=' + ctx.srcnode.abspath() + '/DOCS/man/docutils.conf'
]
ctx.env.PDFLATEX_FLAGS = [
'--interaction=batchmode',
'--output-directory=DOCS/man/en/',
'--jobname=mpv'
]
ctx(source = 'DOCS/man/en/mpv.rst')
_add_rst_manual_dependencies(ctx)
ctx.install_files(ctx.env.DOCDIR, ['DOCS/man/en/mpv.pdf'])
示例3: enhance_lib
def enhance_lib():
"""
modify existing classes and methods
"""
for m in meths_typos:
replace(m)
# catch '..' in ant_glob patterns
old_ant_glob = Node.Node.ant_glob
def ant_glob(self, *k, **kw):
for x in k[0].split('/'):
if x == '..':
Logs.error("In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'" % k[0])
return old_ant_glob(self, *k, **kw)
Node.Node.ant_glob = ant_glob
# catch conflicting ext_in/ext_out/before/after declarations
old = Task.is_before
def is_before(t1, t2):
ret = old(t1, t2)
if ret and old(t2, t1):
Logs.error('Contradictory order constraints in classes %r %r' % (t1, t2))
return ret
Task.is_before = is_before
# check for bld(feature='cshlib') where no 'c' is given - this can be either a mistake or on purpose
# so we only issue a warning
def check_err_features(self):
lst = self.to_list(self.features)
if 'shlib' in lst:
Logs.error('feature shlib -> cshlib, dshlib or cxxshlib')
for x in ('c', 'cxx', 'd', 'fc'):
if not x in lst and lst and lst[0] in [x+y for y in ('program', 'shlib', 'stlib')]:
Logs.error('%r features is probably missing %r' % (self, x))
TaskGen.feature('*')(check_err_features)
示例4: enhance_lib
def enhance_lib():
for m in meths_typos:
replace(m)
old_ant_glob=Node.Node.ant_glob
def ant_glob(self,*k,**kw):
for x in k[0].split('/'):
if x=='..':
Logs.error("In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'"%k[0])
return old_ant_glob(self,*k,**kw)
Node.Node.ant_glob=ant_glob
old=Task.is_before
def is_before(t1,t2):
ret=old(t1,t2)
if ret and old(t2,t1):
Logs.error('Contradictory order constraints in classes %r %r'%(t1,t2))
return ret
Task.is_before=is_before
def check_err_features(self):
lst=self.to_list(self.features)
if'shlib'in lst:
Logs.error('feature shlib -> cshlib, dshlib or cxxshlib')
for x in('c','cxx','d','fc'):
if not x in lst and lst and lst[0]in[x+y for y in('program','shlib','stlib')]:
Logs.error('%r features is probably missing %r'%(self,x))
TaskGen.feature('*')(check_err_features)
示例5: enable_support
def enable_support(cc, cxx):
if cxx or not cc:
TaskGen.extension('.cpp', '.cc', '.cxx', '.C', '.c++')(make_batch_fun('cxx'))
if cc:
TaskGen.extension('.c')(make_batch_fun('c'))
else:
TaskGen.task_gen.mappings['.c'] = TaskGen.task_gen.mappings['.cpp']
示例6: enhance_lib
def enhance_lib():
for m in meths_typos:
replace(m)
old_ant_glob=Node.Node.ant_glob
def ant_glob(self,*k,**kw):
if k:
lst=Utils.to_list(k[0])
for pat in lst:
if'..'in pat.split('/'):
Logs.error("In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'"%k[0])
return old_ant_glob(self,*k,**kw)
Node.Node.ant_glob=ant_glob
old=Task.is_before
def is_before(t1,t2):
ret=old(t1,t2)
if ret and old(t2,t1):
Logs.error('Contradictory order constraints in classes %r %r'%(t1,t2))
return ret
Task.is_before=is_before
def check_err_features(self):
lst=self.to_list(self.features)
if'shlib'in lst:
Logs.error('feature shlib -> cshlib, dshlib or cxxshlib')
for x in('c','cxx','d','fc'):
if not x in lst and lst and lst[0]in[x+y for y in('program','shlib','stlib')]:
Logs.error('%r features is probably missing %r'%(self,x))
TaskGen.feature('*')(check_err_features)
def check_err_order(self):
if not hasattr(self,'rule'):
for x in('before','after','ext_in','ext_out'):
if hasattr(self,x):
Logs.warn('Erroneous order constraint %r on non-rule based task generator %r'%(x,self))
else:
for x in('before','after'):
for y in self.to_list(getattr(self,x,[])):
if not Task.classes.get(y,None):
Logs.error('Erroneous order constraint %s=%r on %r'%(x,y,self))
TaskGen.feature('*')(check_err_order)
old_compile=Build.BuildContext.compile
def check_compile(self):
check_invalid_constraints(self)
try:
ret=old_compile(self)
finally:
check_same_targets(self)
return ret
Build.BuildContext.compile=check_compile
def getattri(self,name,default=None):
if name=='append'or name=='add':
raise Errors.WafError('env.append and env.add do not exist: use env.append_value/env.append_unique')
elif name=='prepend':
raise Errors.WafError('env.prepend does not exist: use env.prepend_value')
if name in self.__slots__:
return object.__getattr__(self,name,default)
else:
return self[name]
ConfigSet.ConfigSet.__getattr__=getattri
示例7: enhance_lib
def enhance_lib():
"""
modify existing classes and methods
"""
for m in meths_typos:
replace(m)
# catch '..' in ant_glob patterns
old_ant_glob = Node.Node.ant_glob
def ant_glob(self, *k, **kw):
for x in k[0].split('/'):
if x == '..':
Logs.error("In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'" % k[0])
return old_ant_glob(self, *k, **kw)
Node.Node.ant_glob = ant_glob
# catch conflicting ext_in/ext_out/before/after declarations
old = Task.is_before
def is_before(t1, t2):
ret = old(t1, t2)
if ret and old(t2, t1):
Logs.error('Contradictory order constraints in classes %r %r' % (t1, t2))
return ret
Task.is_before = is_before
# check for bld(feature='cshlib') where no 'c' is given - this can be either a mistake or on purpose
# so we only issue a warning
def check_err_features(self):
lst = self.to_list(self.features)
if 'shlib' in lst:
Logs.error('feature shlib -> cshlib, dshlib or cxxshlib')
for x in ('c', 'cxx', 'd', 'fc'):
if not x in lst and lst and lst[0] in [x+y for y in ('program', 'shlib', 'stlib')]:
Logs.error('%r features is probably missing %r' % (self, x))
TaskGen.feature('*')(check_err_features)
# check for @extension used with @feature/@before/@after
old_compile = Build.BuildContext.compile
def check_compile(self):
feat = set([])
for x in list(TaskGen.feats.values()):
feat.union(set(x))
for (x, y) in TaskGen.task_gen.prec.items():
feat.add(x)
feat.union(set(y))
ext = set([])
for x in TaskGen.task_gen.mappings.values():
ext.add(x.__name__)
invalid = ext & feat
if invalid:
Logs.error('The methods %r have invalid annotations: @extension <-> @feature/@before/@after' % list(invalid))
return old_compile(self)
Build.BuildContext.compile = check_compile
示例8: enhance_lib
def enhance_lib():
for m in meths_typos:
replace(m)
old_ant_glob=Node.Node.ant_glob
def ant_glob(self,*k,**kw):
if k:
for x in k[0].split('/'):
if x=='..':
Logs.error("In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'"%k[0])
return old_ant_glob(self,*k,**kw)
Node.Node.ant_glob=ant_glob
old=Task.is_before
def is_before(t1,t2):
ret=old(t1,t2)
if ret and old(t2,t1):
Logs.error('Contradictory order constraints in classes %r %r'%(t1,t2))
return ret
Task.is_before=is_before
def check_err_features(self):
lst=self.to_list(self.features)
if'shlib'in lst:
Logs.error('feature shlib -> cshlib, dshlib or cxxshlib')
for x in('c','cxx','d','fc'):
if not x in lst and lst and lst[0]in[x+y for y in('program','shlib','stlib')]:
Logs.error('%r features is probably missing %r'%(self,x))
TaskGen.feature('*')(check_err_features)
old_compile=Build.BuildContext.compile
def check_compile(self):
feat=set([])
for x in list(TaskGen.feats.values()):
feat.union(set(x))
for(x,y)in TaskGen.task_gen.prec.items():
feat.add(x)
feat.union(set(y))
ext=set([])
for x in TaskGen.task_gen.mappings.values():
ext.add(x.__name__)
invalid=ext&feat
if invalid:
Logs.error('The methods %r have invalid annotations: @extension <-> @feature/@before/@after'%list(invalid))
return old_compile(self)
Build.BuildContext.compile=check_compile
def getattr(self,name):
if name=='append'or name=='add':
raise Errors.WafError('env.append and env.add do not exist: use env.append_value/env.append_unique')
elif name=='prepend':
raise Errors.WafError('env.prepend does not exist: use env.prepend_value')
if name in self.__slots__:
return object.__getattr__(self,name)
else:
return self[name]
ConfigSet.ConfigSet.__getattr__=getattr
示例9: __call__
def __call__(self, *k, **kw):
"""Creates a task generator"""
kw['bld'] = self
ret = TaskGen.task_gen(*k, **kw)
self.task_gen_cache_names = {} # reset the cache, each time
self.add_to_group(ret, group=kw.get('group', None))
return ret
示例10: before
def before(*k):
for key, val in repl.items():
if key in k:
if Logs.verbose > 1:
Logs.info('before %s -> %s' % (key, val))
k.replace(key, val)
return TaskGen.before_method(*k)
示例11: after
def after(*k):
for key, val in repl.items():
if key in k:
if Logs.verbose > 1:
Logs.error('after %s -> %s' % (key, val))
k.replace(key, val)
return TaskGen.after_method(*k)
示例12: _build_pdf
def _build_pdf(ctx):
from waflib import TaskGen
TaskGen.declare_chain(
name="rst2latex", rule="${RST2LATEX} ${RST2LATEX_FLAGS} ${SRC} ${TGT}", ext_in=".rst", ext_out=".tex"
)
TaskGen.declare_chain(
name="pdflatex", rule="${PDFLATEX} ${PDFLATEX_FLAGS} ${SRC}; " * 2, ext_in=".tex", ext_out=".pdf", shell=True
)
ctx.env.RST2LATEX_FLAGS = ["--config=" + ctx.srcnode.abspath() + "/DOCS/man/docutils.conf"]
ctx.env.PDFLATEX_FLAGS = ["--interaction=batchmode", "--output-directory=DOCS/man/en/", "--jobname=mpv"]
ctx(source="DOCS/man/en/mpv.rst")
_add_rst_manual_dependencies(ctx)
ctx.install_files(ctx.env.DOCDIR, ["DOCS/man/en/mpv.pdf"])
示例13: __call__
def __call__(self, *k, **kw):
# this is one way of doing it, one could use a task generator method too
bld = kw['bld'] = bld_proxy(self)
ret = TaskGen.task_gen(*k, **kw)
self.task_gen_cache_names = {}
self.add_to_group(ret, group=kw.get('group'))
ret.bld = bld
bld.set_key(ret.path.abspath().replace(os.sep, '') + str(ret.idx))
return ret
示例14: __call__
def __call__(self, *k, **kw):
"""
Create a task generator, adding it to the current build group. The following forms are equivalent::
def build(bld):
tg = bld(a=1, b=2)
def build(bld):
tg = bld()
tg.a = 1
tg.b = 2
"""
kw['bld'] = self
ret = TaskGen.task_gen(*k, **kw)
self.task_gen_cache_names = {} # reset the cache, each time
self.add_to_group(ret, group=kw.get('group', None))
return ret
示例15: __call__
def __call__(self, *k, **kw):
"""
Create a task generator and add it to the current build group. The following forms are equivalent::
def build(bld):
tg = bld(a=1, b=2)
def build(bld):
tg = bld()
tg.a = 1
tg.b = 2
def build(bld):
tg = TaskGen.task_gen(a=1, b=2)
bld.add_to_group(tg, None)
:param group: group name to add the task generator to
:type group: string
"""
kw['bld'] = self
ret = TaskGen.task_gen(*k, **kw)
self.task_gen_cache_names = {} # reset the cache, each time
self.add_to_group(ret, group=kw.get('group'))
return ret