本文整理汇总了Python中waflib.Errors.WafError方法的典型用法代码示例。如果您正苦于以下问题:Python Errors.WafError方法的具体用法?Python Errors.WafError怎么用?Python Errors.WafError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waflib.Errors
的用法示例。
在下文中一共展示了Errors.WafError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_run_program
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def get_run_program(program_string, command_template=None):
"""
Return the program name and argv of the process that would be executed by
run_program(program_string, command_template).
"""
#print "get_run_program_argv(program_string=%r, command_template=%r)" % (program_string, command_template)
env = bld.env
if command_template in (None, '%s'):
argv = shlex.split(program_string)
#print "%r ==shlex.split==> %r" % (program_string, argv)
program_name = argv[0]
try:
program_obj = find_program(program_name, env)
except ValueError, ex:
raise WafError(str(ex))
program_node = program_obj.path.find_or_declare(program_obj.target)
#try:
# program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
#except AttributeError:
# raise Utils.WafError("%s does not appear to be a program" % (program_name,))
execvec = [program_node.abspath()] + argv[1:]
示例2: apply_copy
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def apply_copy(self):
Utils.def_attrs(self, fun=copy_func)
self.default_install_path = 0
lst = self.to_list(self.source)
self.meths.remove('process_source')
for filename in lst:
node = self.path.find_resource(filename)
if not node: raise Errors.WafError('cannot find input file %s for processing' % filename)
target = self.target
if not target or len(lst)>1: target = node.name
# TODO the file path may be incorrect
newnode = self.path.find_or_declare(target)
tsk = self.create_task('copy', node, newnode)
tsk.fun = self.fun
tsk.chmod = getattr(self, 'chmod', Utils.O644)
if not tsk.env:
tsk.debug()
raise Errors.WafError('task without an environment')
示例3: sig_explicit_deps
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def sig_explicit_deps(self):
bld=self.generator.bld
upd=self.m.update
for x in self.inputs+self.dep_nodes:
try:
upd(x.get_bld_sig())
except(AttributeError,TypeError):
raise Errors.WafError('Missing node signature for %r (required by %r)'%(x,self))
if bld.deps_man:
additional_deps=bld.deps_man
for x in self.inputs+self.outputs:
try:
d=additional_deps[id(x)]
except KeyError:
continue
for v in d:
if isinstance(v,bld.root.__class__):
try:
v=v.get_bld_sig()
except AttributeError:
raise Errors.WafError('Missing node signature for %r (required by %r)'%(v,self))
elif hasattr(v,'__call__'):
v=v()
upd(v)
return self.m.digest()
示例4: configure
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def configure(conf):
v=conf.env
v['PYTHON']=Options.options.python or os.environ.get('PYTHON',sys.executable)
if Options.options.pythondir:
v['PYTHONDIR']=Options.options.pythondir
if Options.options.pythonarchdir:
v['PYTHONARCHDIR']=Options.options.pythonarchdir
conf.find_program('python',var='PYTHON')
v['PYFLAGS']=''
v['PYFLAGS_OPT']='-O'
v['PYC']=getattr(Options.options,'pyc',1)
v['PYO']=getattr(Options.options,'pyo',1)
try:
v.PYTAG=conf.cmd_and_log(conf.env.PYTHON+['-c',"import imp;print(imp.get_tag())"]).strip()
except Errors.WafError:
pass
示例5: check_cfg
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def check_cfg(self,*k,**kw):
if k:
lst=k[0].split()
kw['package']=lst[0]
kw['args']=' '.join(lst[1:])
self.validate_cfg(kw)
if'msg'in kw:
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',**kw)
if Logs.verbose>1:
raise
else:
self.fatal('The configuration failed')
else:
if not ret:
ret=True
kw['success']=ret
if'okmsg'in kw:
self.end_msg(self.ret_msg(kw['okmsg'],kw),**kw)
return ret
示例6: process_lib
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def process_lib(self):
node=None
names=[x%self.name for x in lib_patterns[self.lib_type]]
for x in self.lib_paths+[self.path]+SYSTEM_LIB_PATHS:
if not isinstance(x,Node.Node):
x=self.bld.root.find_node(x)or self.path.find_node(x)
if not x:
continue
for y in names:
node=x.find_node(y)
if node:
node.sig=Utils.h_file(node.abspath())
break
else:
continue
break
else:
raise Errors.WafError('could not find library %r'%self.name)
self.link_task=self.create_task('fake_%s'%self.lib_type,[],[node])
self.target=self.name
示例7: makeglossaries
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def makeglossaries(self):
src_file=self.inputs[0].abspath()
base_file=os.path.basename(src_file)
base,_=os.path.splitext(base_file)
for aux_node in self.aux_nodes:
try:
ct=aux_node.read()
except EnvironmentError:
Logs.error('Error reading %s: %r'%aux_node.abspath())
continue
if g_glossaries_re.findall(ct):
if not self.env.MAKEGLOSSARIES:
raise Errors.WafError("The program 'makeglossaries' is missing!")
Logs.warn('calling makeglossaries')
self.env.SRCFILE=base
self.check_status('error when calling makeglossaries %s'%base,self.makeglossaries_fun())
return
示例8: check
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def check(self):
import tempfile,tarfile
t=None
try:
t=tarfile.open(self.get_arch_name())
for x in t:
t.extract(x)
finally:
if t:
t.close()
cfg=[]
if Options.options.distcheck_args:
cfg=shlex.split(Options.options.distcheck_args)
else:
cfg=[x for x in sys.argv if x.startswith('-')]
instdir=tempfile.mkdtemp('.inst',self.get_base_name())
ret=Utils.subprocess.Popen([sys.executable,sys.argv[0],'configure','install','uninstall','--destdir='+instdir]+cfg,cwd=self.get_base_name()).wait()
if ret:
raise Errors.WafError('distcheck failed with code %i'%ret)
if os.path.exists(instdir):
raise Errors.WafError('distcheck succeeded, but files were left in %s'%instdir)
shutil.rmtree(self.get_base_name())
示例9: mkdir
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def mkdir(self):
if getattr(self,'cache_isdir',None):
return
try:
self.parent.mkdir()
except OSError:
pass
if self.name:
try:
os.makedirs(self.abspath())
except OSError:
pass
if not os.path.isdir(self.abspath()):
raise Errors.WafError('Could not create the directory %s'%self.abspath())
try:
self.children
except AttributeError:
self.children=self.dict_class()
self.cache_isdir=True
示例10: exec_command
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def exec_command(self,cmd,**kw):
subprocess=Utils.subprocess
kw['shell']=isinstance(cmd,str)
Logs.debug('runner: %r'%(cmd,))
Logs.debug('runner_env: kw=%s'%kw)
if self.logger:
self.logger.info(cmd)
if'stdout'not in kw:
kw['stdout']=subprocess.PIPE
if'stderr'not in kw:
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])
try:
if kw['stdout']or kw['stderr']:
p=subprocess.Popen(cmd,**kw)
(out,err)=p.communicate()
ret=p.returncode
else:
out,err=(None,None)
ret=subprocess.Popen(cmd,**kw).wait()
except Exception ,e:
raise Errors.WafError('Execution failure: %s'%str(e),ex=e)
示例11: load_module
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def load_module(path,encoding=None):
try:
return cache_modules[path]
except KeyError:
pass
module=imp.new_module(WSCRIPT_FILE)
try:
code=Utils.readf(path,m='rU',encoding=encoding)
except EnvironmentError:
raise Errors.WafError('Could not read the file %r'%path)
module_dir=os.path.dirname(path)
sys.path.insert(0,module_dir)
exec(compile(code,path,'exec'),module.__dict__)
sys.path.remove(module_dir)
cache_modules[path]=module
return module
示例12: load_envs
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def load_envs(self):
node=self.root.find_node(self.cache_dir)
if not node:
raise Errors.WafError('The project was not configured: run "waf configure" first!')
lst=node.ant_glob('**/*%s'%CACHE_SUFFIX,quiet=True)
if not lst:
raise Errors.WafError('The cache directory is empty: reconfigure the project')
for x in lst:
name=x.path_from(node).replace(CACHE_SUFFIX,'').replace('\\','/')
env=ConfigSet.ConfigSet(x.abspath())
self.all_envs[name]=env
for f in env[CFG_FILES]:
newnode=self.root.find_resource(f)
try:
h=Utils.h_file(newnode.abspath())
except(IOError,AttributeError):
Logs.error('cannot find %r'%f)
h=Utils.SIG_NIL
newnode.sig=h
示例13: restore
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def restore(self):
try:
env=ConfigSet.ConfigSet(os.path.join(self.cache_dir,'build.config.py'))
except EnvironmentError:
pass
else:
if env['version']<Context.HEXVERSION:
raise Errors.WafError('Version mismatch! reconfigure the project')
for t in env['tools']:
self.setup(**t)
dbfn=os.path.join(self.variant_dir,Context.DBFILE)
try:
data=Utils.readf(dbfn,'rb')
except(IOError,EOFError):
Logs.debug('build: Could not load the build cache %s (missing)'%dbfn)
else:
try:
waflib.Node.pickle_lock.acquire()
waflib.Node.Nod3=self.node_class
try:
data=cPickle.loads(data)
except Exception ,e:
Logs.debug('build: Could not pickle the build cache %s: %r'%(dbfn,e))
else:
示例14: post
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def post(self):
buf=[]
for x in self.source:
if isinstance(x,waflib.Node.Node):
y=x
else:
y=self.path.find_resource(x)
if not y:
if Logs.verbose:
Logs.warn('Could not find %s immediately (may cause broken builds)'%x)
idx=self.generator.bld.get_group_idx(self)
for tg in self.generator.bld.groups[idx]:
if not isinstance(tg,inst)and id(tg)!=id(self):
tg.post()
y=self.path.find_resource(x)
if y:
break
else:
raise Errors.WafError('Could not find %r in %r'%(x,self.path))
buf.append(y)
self.inputs=buf
示例15: init_dirs
# 需要导入模块: from waflib import Errors [as 别名]
# 或者: from waflib.Errors import WafError [as 别名]
def init_dirs(self):
if not (os.path.isabs(self.top_dir) and os.path.isabs(self.out_dir)):
raise Errors.WafError('The project was not configured: run "waf configure" first!')
srcdir = None
db = os.path.join(self.variant_dir, EXTRA_LOCK)
env = ConfigSet.ConfigSet()
try:
env.load(db)
srcdir = env.SRCDIR
except:
pass
if srcdir:
d = self.root.find_node(srcdir)
if d and srcdir != self.top_dir and getattr(d, 'children', ''):
srcnode = self.root.make_node(self.top_dir)
print("relocating the source directory %r -> %r" % (srcdir, self.top_dir))
srcnode.children = {}
for (k, v) in d.children.items():
srcnode.children[k] = v
v.parent = srcnode
d.children = {}
old2(self)