- Timestamp:
- Mar 14, 2015, 6:06:10 PM (10 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 6d7acc8
- Parents:
- 5525507
- Location:
- waflib
- Files:
-
- 3 added
- 57 edited
Legend:
- Unmodified
- Added
- Removed
-
waflib/Build.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os,sys,errno,re,shutil 5 import os,sys,errno,re,shutil,stat 6 6 try: 7 7 import cPickle … … 32 32 self.cache_dir=kw.get('cache_dir',None) 33 33 if not self.cache_dir: 34 self.cache_dir= self.out_dir+os.sep+CACHE_DIR34 self.cache_dir=os.path.join(self.out_dir,CACHE_DIR) 35 35 self.all_envs={} 36 36 self.task_sigs={} … … 43 43 self.targets=Options.options.targets 44 44 self.keep=Options.options.keep 45 self.cache_global=Options.cache_global46 self.nocache=Options.options.nocache47 45 self.progress_bar=Options.options.progress_bar 48 46 self.deps_man=Utils.defaultdict(list) … … 110 108 self.pre_build() 111 109 self.timer=Utils.Timer() 112 if self.progress_bar:113 sys.stderr.write(Logs.colors.cursor_off)114 110 try: 115 111 self.compile() 116 112 finally: 117 if self.progress_bar==1 :113 if self.progress_bar==1 and sys.stderr.isatty(): 118 114 c=len(self.returned_tasks)or 1 119 self.to_log(self.progress_line(c,c,Logs.colors.BLUE,Logs.colors.NORMAL)) 120 print('') 121 sys.stdout.flush() 122 sys.stderr.write(Logs.colors.cursor_on) 115 m=self.progress_line(c,c,Logs.colors.BLUE,Logs.colors.NORMAL) 116 Logs.info(m,extra={'stream':sys.stderr,'c1':Logs.colors.cursor_off,'c2':Logs.colors.cursor_on}) 123 117 Logs.info("Waf: Leaving directory `%s'"%self.variant_dir) 124 118 self.post_build() … … 126 120 try: 127 121 env=ConfigSet.ConfigSet(os.path.join(self.cache_dir,'build.config.py')) 128 except (IOError,OSError):122 except EnvironmentError: 129 123 pass 130 124 else: … … 254 248 raise Errors.WafError('Could not find a task generator for the name %r'%name) 255 249 def progress_line(self,state,total,col1,col2): 250 if not sys.stderr.isatty(): 251 return'' 256 252 n=len(str(total)) 257 253 Utils.rot_idx+=1 … … 266 262 ratio=((cols*state)//total)-1 267 263 bar=('='*ratio+'>').ljust(cols) 268 msg= Utils.indicator%(left,bar,right)264 msg=Logs.indicator%(left,bar,right) 269 265 return msg 270 266 def declare_chain(self,*k,**kw): … … 326 322 if id(g)==id(self.groups[i]): 327 323 self.current_group=i 324 break 328 325 else: 329 326 self.current_group=idx … … 474 471 else: 475 472 destfile=os.path.join(destpath,y.name) 476 self.generator.bld.do_install(y.abspath(),destfile, self.chmod)473 self.generator.bld.do_install(y.abspath(),destfile,chmod=self.chmod,tsk=self) 477 474 def exec_install_as(self): 478 475 destfile=self.get_install_path() 479 self.generator.bld.do_install(self.inputs[0].abspath(),destfile, self.chmod)476 self.generator.bld.do_install(self.inputs[0].abspath(),destfile,chmod=self.chmod,tsk=self) 480 477 def exec_symlink_as(self): 481 478 destfile=self.get_install_path() … … 483 480 if self.relative_trick: 484 481 src=os.path.relpath(src,os.path.dirname(destfile)) 485 self.generator.bld.do_link(src,destfile )482 self.generator.bld.do_link(src,destfile,tsk=self) 486 483 class InstallContext(BuildContext): 487 484 '''installs the targets on the system''' … … 491 488 self.uninstall=[] 492 489 self.is_install=INSTALL 493 def do_install(self,src,tgt,chmod=Utils.O644): 490 def copy_fun(self,src,tgt,**kw): 491 if Utils.is_win32 and len(tgt)>259 and not tgt.startswith('\\\\?\\'): 492 tgt='\\\\?\\'+tgt 493 shutil.copy2(src,tgt) 494 os.chmod(tgt,kw.get('chmod',Utils.O644)) 495 def do_install(self,src,tgt,**kw): 494 496 d,_=os.path.split(tgt) 495 497 if not d: … … 511 513 Logs.info('+ install %s (from %s)'%(tgt,srclbl)) 512 514 try: 515 os.chmod(tgt,Utils.O644|stat.S_IMODE(os.stat(tgt).st_mode)) 516 except EnvironmentError: 517 pass 518 try: 513 519 os.remove(tgt) 514 520 except OSError: 515 521 pass 516 522 try: 517 shutil.copy2(src,tgt) 518 os.chmod(tgt,chmod) 523 self.copy_fun(src,tgt,**kw) 519 524 except IOError: 520 525 try: 521 526 os.stat(src) 522 except (OSError,IOError):527 except EnvironmentError: 523 528 Logs.error('File %r does not exist'%src) 524 529 raise Errors.WafError('Could not install the file %r'%tgt) 525 def do_link(self,src,tgt ):530 def do_link(self,src,tgt,**kw): 526 531 d,_=os.path.split(tgt) 527 532 Utils.check_dir(d) … … 546 551 raise self.WafError('cannot post the task %r'%tsk) 547 552 tsk.run() 548 def install_files(self,dest,files,env=None,chmod=Utils.O644,relative_trick=False,cwd=None,add=True,postpone=True ):553 def install_files(self,dest,files,env=None,chmod=Utils.O644,relative_trick=False,cwd=None,add=True,postpone=True,task=None): 549 554 tsk=inst(env=env or self.env) 550 555 tsk.bld=self 551 556 tsk.path=cwd or self.path 552 557 tsk.chmod=chmod 558 tsk.task=task 553 559 if isinstance(files,waflib.Node.Node): 554 560 tsk.source=[files] … … 561 567 self.run_task_now(tsk,postpone) 562 568 return tsk 563 def install_as(self,dest,srcfile,env=None,chmod=Utils.O644,cwd=None,add=True,postpone=True ):569 def install_as(self,dest,srcfile,env=None,chmod=Utils.O644,cwd=None,add=True,postpone=True,task=None): 564 570 tsk=inst(env=env or self.env) 565 571 tsk.bld=self … … 567 573 tsk.chmod=chmod 568 574 tsk.source=[srcfile] 575 tsk.task=task 569 576 tsk.dest=dest 570 577 tsk.exec_task=tsk.exec_install_as … … 572 579 self.run_task_now(tsk,postpone) 573 580 return tsk 574 def symlink_as(self,dest,src,env=None,cwd=None,add=True,postpone=True,relative_trick=False ):581 def symlink_as(self,dest,src,env=None,cwd=None,add=True,postpone=True,relative_trick=False,task=None): 575 582 if Utils.is_win32: 576 583 return … … 580 587 tsk.path=cwd or self.path 581 588 tsk.source=[] 589 tsk.task=task 582 590 tsk.link=src 583 591 tsk.relative_trick=relative_trick … … 592 600 super(UninstallContext,self).__init__(**kw) 593 601 self.is_install=UNINSTALL 594 def do_install(self,src,tgt,chmod=Utils.O644): 602 def rm_empty_dirs(self,tgt): 603 while tgt: 604 tgt=os.path.dirname(tgt) 605 try: 606 os.rmdir(tgt) 607 except OSError: 608 break 609 def do_install(self,src,tgt,**kw): 595 610 if not self.progress_bar: 596 611 Logs.info('- remove %s'%tgt) … … 605 620 if Logs.verbose>1: 606 621 Logs.warn('Could not remove %s (error code %r)'%(e.filename,e.errno)) 607 while tgt: 608 tgt=os.path.dirname(tgt) 609 try: 610 os.rmdir(tgt) 611 except OSError: 612 break 613 def do_link(self,src,tgt): 622 self.rm_empty_dirs(tgt) 623 def do_link(self,src,tgt,**kw): 614 624 try: 615 625 if not self.progress_bar: … … 618 628 except OSError: 619 629 pass 620 while tgt: 621 tgt=os.path.dirname(tgt) 622 try: 623 os.rmdir(tgt) 624 except OSError: 625 break 630 self.rm_empty_dirs(tgt) 626 631 def execute(self): 627 632 try: … … 755 760 return pattern.match(node.abspath()) 756 761 return match 757 BuildContext.store=Utils.nogc(BuildContext.store)758 BuildContext.restore=Utils.nogc(BuildContext.restore) -
waflib/ConfigSet.py
r5525507 r904702d 90 90 return value 91 91 def append_value(self,var,val): 92 current_value=self._get_list_value_for_modification(var)93 92 if isinstance(val,str): 94 93 val=[val] 94 current_value=self._get_list_value_for_modification(var) 95 95 current_value.extend(val) 96 96 def prepend_value(self,var,val): -
waflib/Configure.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os,shlex,sys,time 5 import os,shlex,sys,time,re,shutil 6 6 from waflib import ConfigSet,Utils,Options,Logs,Context,Build,Errors 7 try:8 from urllib import request9 except ImportError:10 from urllib import urlopen11 else:12 urlopen=request.urlopen13 7 BREAK='break' 14 8 CONTINUE='continue' … … 19 13 # using %(args)s 20 14 #''' 21 def download_check(node):22 pass23 def download_tool(tool,force=False,ctx=None):24 for x in Utils.to_list(Context.remote_repo):25 for sub in Utils.to_list(Context.remote_locs):26 url='/'.join((x,sub,tool+'.py'))27 try:28 web=urlopen(url)29 try:30 if web.getcode()!=200:31 continue32 except AttributeError:33 pass34 except Exception:35 continue36 else:37 tmp=ctx.root.make_node(os.sep.join((Context.waf_dir,'waflib','extras',tool+'.py')))38 tmp.write(web.read(),'wb')39 Logs.warn('Downloaded %s from %s'%(tool,url))40 download_check(tmp)41 try:42 module=Context.load_tool(tool)43 except Exception:44 Logs.warn('The tool %s from %s is unusable'%(tool,url))45 try:46 tmp.delete()47 except Exception:48 pass49 continue50 return module51 raise Errors.WafError('Could not load the Waf tool')52 15 class ConfigurationContext(Context.Context): 53 16 '''configures the project''' … … 97 60 if not out: 98 61 out=Options.lockfile.replace('.lock-waf_%s_'%sys.platform,'').replace('.lock-waf','') 62 out=os.path.realpath(out) 99 63 self.bldnode=(os.path.isabs(out)and self.root or self.path).make_node(out) 100 64 self.bldnode.mkdir() … … 140 104 env['environ']=dict(self.environ) 141 105 if not self.env.NO_LOCK_IN_RUN: 142 env.store( Context.run_dir+os.sep+Options.lockfile)106 env.store(os.path.join(Context.run_dir,Options.lockfile)) 143 107 if not self.env.NO_LOCK_IN_TOP: 144 env.store( Context.top_dir+os.sep+Options.lockfile)108 env.store(os.path.join(Context.top_dir,Options.lockfile)) 145 109 if not self.env.NO_LOCK_IN_OUT: 146 env.store( Context.out_dir+os.sep+Options.lockfile)110 env.store(os.path.join(Context.out_dir,Options.lockfile)) 147 111 def prepare_env(self,env): 148 112 if not env.PREFIX: … … 152 116 env.PREFIX='' 153 117 if not env.BINDIR: 154 env.BINDIR=Utils.subst_vars('${PREFIX}/bin',env) 118 if Options.options.bindir: 119 env.BINDIR=os.path.abspath(os.path.expanduser(Options.options.bindir)) 120 else: 121 env.BINDIR=Utils.subst_vars('${PREFIX}/bin',env) 155 122 if not env.LIBDIR: 156 env.LIBDIR=Utils.subst_vars('${PREFIX}/lib',env) 123 if Options.options.libdir: 124 env.LIBDIR=os.path.abspath(os.path.expanduser(Options.options.libdir)) 125 else: 126 env.LIBDIR=Utils.subst_vars('${PREFIX}/lib%s'%Utils.lib64(),env) 157 127 def store(self): 158 128 n=self.cachedir.make_node('build.config.py') … … 163 133 tmpenv=self.all_envs[key] 164 134 tmpenv.store(os.path.join(self.cachedir.abspath(),key+Build.CACHE_SUFFIX)) 165 def load(self,input,tooldir=None,funs=None ,download=True):135 def load(self,input,tooldir=None,funs=None): 166 136 tools=Utils.to_list(input) 167 137 if tooldir:tooldir=Utils.to_list(tooldir) … … 174 144 module=None 175 145 try: 176 module=Context.load_tool(tool,tooldir )146 module=Context.load_tool(tool,tooldir,ctx=self) 177 147 except ImportError ,e: 178 if Options.options.download: 179 module=download_tool(tool,ctx=self) 180 if not module: 181 self.fatal('Could not load the Waf tool %r or download a suitable replacement from the repository (sys.path %r)\n%s'%(tool,sys.path,e)) 182 else: 183 self.fatal('Could not load the Waf tool %r from %r (try the --download option?):\n%s'%(tool,sys.path,e)) 148 self.fatal('Could not load the Waf tool %r from %r\n%s'%(tool,sys.path,e)) 184 149 except Exception ,e: 185 150 self.to_log('imp %r (%r & %r)'%(tool,tooldir,funs)) … … 244 209 return cmd 245 210 @conf 246 def check_waf_version(self,mini='1. 6.99',maxi='1.8.0'):247 self.start_msg('Checking for waf version in %s-%s'%(str(mini),str(maxi)) )211 def check_waf_version(self,mini='1.7.99',maxi='1.9.0',**kw): 212 self.start_msg('Checking for waf version in %s-%s'%(str(mini),str(maxi)),**kw) 248 213 ver=Context.HEXVERSION 249 214 if Utils.num2ver(mini)>ver: … … 251 216 if Utils.num2ver(maxi)<ver: 252 217 self.fatal('waf version should be at most %r (%r found)'%(Utils.num2ver(maxi),ver)) 253 self.end_msg('ok' )218 self.end_msg('ok',**kw) 254 219 @conf 255 220 def find_file(self,filename,path_list=[]): … … 263 228 def find_program(self,filename,**kw): 264 229 exts=kw.get('exts',Utils.is_win32 and'.exe,.com,.bat,.cmd'or',.sh,.pl,.py') 265 environ=kw.get('environ', os.environ)230 environ=kw.get('environ',getattr(self,'environ',os.environ)) 266 231 ret='' 267 232 filename=Utils.to_list(filename) 233 msg=kw.get('msg',', '.join(filename)) 268 234 var=kw.get('var','') 269 235 if not var: 270 var=filename[0].upper() 271 if self.env[var]: 236 var=re.sub(r'[-.]','_',filename[0].upper()) 237 path_list=kw.get('path_list','') 238 if path_list: 239 path_list=Utils.to_list(path_list) 240 else: 241 path_list=environ.get('PATH','').split(os.pathsep) 242 if var in environ: 243 filename=environ[var] 244 if os.path.isfile(filename): 245 ret=[filename] 246 else: 247 ret=self.cmd_to_list(filename) 248 elif self.env[var]: 272 249 ret=self.env[var] 273 elif var in environ: 274 ret=environ[var] 275 path_list=kw.get('path_list','') 250 ret=self.cmd_to_list(ret) 251 else: 252 if not ret: 253 ret=self.find_binary(filename,exts.split(','),path_list) 254 if not ret and Utils.winreg: 255 ret=Utils.get_registry_app_path(Utils.winreg.HKEY_CURRENT_USER,filename) 256 if not ret and Utils.winreg: 257 ret=Utils.get_registry_app_path(Utils.winreg.HKEY_LOCAL_MACHINE,filename) 258 ret=self.cmd_to_list(ret) 259 if ret: 260 if len(ret)==1: 261 retmsg=ret[0] 262 else: 263 retmsg=ret 264 else: 265 retmsg=False 266 self.msg("Checking for program '%s'"%msg,retmsg,**kw) 267 if not kw.get('quiet',None): 268 self.to_log('find program=%r paths=%r var=%r -> %r'%(filename,path_list,var,ret)) 276 269 if not ret: 277 if path_list: 278 path_list=Utils.to_list(path_list) 279 else: 280 path_list=environ.get('PATH','').split(os.pathsep) 281 if not isinstance(filename,list): 282 filename=[filename] 283 for a in exts.split(','): 284 if ret: 285 break 286 for b in filename: 287 if ret: 288 break 289 for c in path_list: 290 if ret: 291 break 292 x=os.path.expanduser(os.path.join(c,b+a)) 270 self.fatal(kw.get('errmsg','')or'Could not find the program %r'%filename) 271 interpreter=kw.get('interpreter',None) 272 if interpreter is None: 273 if not Utils.check_exe(ret[0],env=environ): 274 self.fatal('Program %r is not executable'%ret) 275 self.env[var]=ret 276 else: 277 self.env[var]=self.env[interpreter]+ret 278 return ret 279 @conf 280 def find_binary(self,filenames,exts,paths): 281 for f in filenames: 282 for ext in exts: 283 exe_name=f+ext 284 if os.path.isabs(exe_name): 285 if os.path.isfile(exe_name): 286 return exe_name 287 else: 288 for path in paths: 289 x=os.path.expanduser(os.path.join(path,exe_name)) 293 290 if os.path.isfile(x): 294 ret=x 295 if not ret and Utils.winreg: 296 ret=Utils.get_registry_app_path(Utils.winreg.HKEY_CURRENT_USER,filename) 297 if not ret and Utils.winreg: 298 ret=Utils.get_registry_app_path(Utils.winreg.HKEY_LOCAL_MACHINE,filename) 299 self.msg('Checking for program '+','.join(filename),ret or False) 300 self.to_log('find program=%r paths=%r var=%r -> %r'%(filename,path_list,var,ret)) 301 if not ret: 302 self.fatal(kw.get('errmsg','')or'Could not find the program %s'%','.join(filename)) 303 if var: 304 self.env[var]=ret 291 return x 292 return None 293 @conf 294 def run_build(self,*k,**kw): 295 lst=[str(v)for(p,v)in kw.items()if p!='env'] 296 h=Utils.h_list(lst) 297 dir=self.bldnode.abspath()+os.sep+(not Utils.is_win32 and'.'or'')+'conf_check_'+Utils.to_hex(h) 298 try: 299 os.makedirs(dir) 300 except OSError: 301 pass 302 try: 303 os.stat(dir) 304 except OSError: 305 self.fatal('cannot use the configuration test folder %r'%dir) 306 cachemode=getattr(Options.options,'confcache',None) 307 if cachemode==1: 308 try: 309 proj=ConfigSet.ConfigSet(os.path.join(dir,'cache_run_build')) 310 except OSError: 311 pass 312 except IOError: 313 pass 314 else: 315 ret=proj['cache_run_build'] 316 if isinstance(ret,str)and ret.startswith('Test does not build'): 317 self.fatal(ret) 318 return ret 319 bdir=os.path.join(dir,'testbuild') 320 if not os.path.exists(bdir): 321 os.makedirs(bdir) 322 self.test_bld=bld=Build.BuildContext(top_dir=dir,out_dir=bdir) 323 bld.init_dirs() 324 bld.progress_bar=0 325 bld.targets='*' 326 bld.logger=self.logger 327 bld.all_envs.update(self.all_envs) 328 bld.env=kw['env'] 329 bld.kw=kw 330 bld.conf=self 331 kw['build_fun'](bld) 332 ret=-1 333 try: 334 try: 335 bld.compile() 336 except Errors.WafError: 337 ret='Test does not build: %s'%Utils.ex_stack() 338 self.fatal(ret) 339 else: 340 ret=getattr(bld,'retval',0) 341 finally: 342 if cachemode==1: 343 proj=ConfigSet.ConfigSet() 344 proj['cache_run_build']=ret 345 proj.store(os.path.join(dir,'cache_run_build')) 346 else: 347 shutil.rmtree(dir) 305 348 return ret 306 349 @conf 307 def find_perl_program(self,filename,path_list=[],var=None,environ=None,exts=''): 350 def ret_msg(self,msg,args): 351 if isinstance(msg,str): 352 return msg 353 return msg(args) 354 @conf 355 def test(self,*k,**kw): 356 if not'env'in kw: 357 kw['env']=self.env.derive() 358 if kw.get('validate',None): 359 kw['validate'](kw) 360 self.start_msg(kw['msg'],**kw) 361 ret=None 308 362 try: 309 app=self.find_program(filename,path_list=path_list,var=var,environ=environ,exts=exts) 310 except Exception: 311 self.find_program('perl',var='PERL') 312 app=self.find_file(filename,os.environ['PATH'].split(os.pathsep)) 313 if not app: 363 ret=self.run_build(*k,**kw) 364 except self.errors.ConfigurationError: 365 self.end_msg(kw['errmsg'],'YELLOW',**kw) 366 if Logs.verbose>1: 314 367 raise 315 if var: 316 self.env[var]=Utils.to_list(self.env['PERL'])+[app] 317 self.msg('Checking for %r'%filename,app) 368 else: 369 self.fatal('The configuration failed') 370 else: 371 kw['success']=ret 372 if kw.get('post_check',None): 373 ret=kw['post_check'](kw) 374 if ret: 375 self.end_msg(kw['errmsg'],'YELLOW',**kw) 376 self.fatal('The configuration failed %r'%ret) 377 else: 378 self.end_msg(self.ret_msg(kw['okmsg'],kw),**kw) 379 return ret -
waflib/Context.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os, imp,sys5 import os,re,imp,sys 6 6 from waflib import Utils,Errors,Logs 7 7 import waflib.Node 8 HEXVERSION=0x10 70f009 WAFVERSION="1. 7.15"10 WAFREVISION=" f63ac9793de2d4eaae884e55d4ff70a761dcbab2"8 HEXVERSION=0x1080700 9 WAFVERSION="1.8.7" 10 WAFREVISION="e5056b9ade7bb224f53baab13a0ce136344ab602" 11 11 ABI=98 12 12 DBFILE='.wafpickle-%s-%d-%d'%(sys.platform,sys.hexversion,ABI) … … 72 72 def __hash__(self): 73 73 return id(self) 74 def finalize(self): 75 try: 76 logger=self.logger 77 except AttributeError: 78 pass 79 else: 80 Logs.free_logger(logger) 81 delattr(self,'logger') 74 82 def load(self,tool_list,*k,**kw): 75 83 tools=Utils.to_list(tool_list) … … 91 99 if self.cur_script: 92 100 self.path=self.cur_script.parent 93 def recurse(self,dirs,name=None,mandatory=True,once=True ):101 def recurse(self,dirs,name=None,mandatory=True,once=True,encoding=None): 94 102 try: 95 103 cache=self.recurse_cache … … 106 114 self.pre_recurse(node) 107 115 try: 108 function_code=node.read('rU' )116 function_code=node.read('rU',encoding) 109 117 exec(compile(function_code,node.abspath(),'exec'),self.exec_dict) 110 118 finally: … … 117 125 self.pre_recurse(node) 118 126 try: 119 wscript_module=load_module(node.abspath() )127 wscript_module=load_module(node.abspath(),encoding=encoding) 120 128 user_function=getattr(wscript_module,(name or self.fun),None) 121 129 if not user_function: … … 141 149 if'stderr'not in kw: 142 150 kw['stderr']=subprocess.PIPE 151 if Logs.verbose and not kw['shell']and not Utils.check_exe(cmd[0]): 152 raise Errors.WafError("Program %s not found!"%cmd[0]) 143 153 try: 144 154 if kw['stdout']or kw['stderr']: … … 157 167 self.logger.debug('out: %s'%out) 158 168 else: 159 sys.stdout.write(out)169 Logs.info(out,extra={'stream':sys.stdout,'c1':''}) 160 170 if err: 161 171 if not isinstance(err,str): … … 164 174 self.logger.error('err: %s'%err) 165 175 else: 166 sys.stderr.write(err)176 Logs.info(err,extra={'stream':sys.stderr,'c1':''}) 167 177 return ret 168 178 def cmd_and_log(self,cmd,**kw): … … 180 190 else: 181 191 to_ret=STDOUT 192 if Logs.verbose and not kw['shell']and not Utils.check_exe(cmd[0]): 193 raise Errors.WafError("Program %s not found!"%cmd[0]) 182 194 kw['stdout']=kw['stderr']=subprocess.PIPE 183 195 if quiet is None: … … 223 235 sys.stderr.write(str(msg)) 224 236 sys.stderr.flush() 225 def msg(self,msg,result,color=None): 226 self.start_msg(msg) 237 def msg(self,*k,**kw): 238 try: 239 msg=kw['msg'] 240 except KeyError: 241 msg=k[0] 242 self.start_msg(msg,**kw) 243 try: 244 result=kw['result'] 245 except KeyError: 246 result=k[1] 247 color=kw.get('color',None) 227 248 if not isinstance(color,str): 228 249 color=result and'GREEN'or'YELLOW' 229 self.end_msg(result,color) 230 def start_msg(self,msg): 250 self.end_msg(result,color,**kw) 251 def start_msg(self,*k,**kw): 252 if kw.get('quiet',None): 253 return 254 msg=kw.get('msg',None)or k[0] 231 255 try: 232 256 if self.in_msg: … … 243 267 self.to_log(x) 244 268 Logs.pprint('NORMAL',"%s :"%msg.ljust(self.line_just),sep='') 245 def end_msg(self,result,color=None): 269 def end_msg(self,*k,**kw): 270 if kw.get('quiet',None): 271 return 246 272 self.in_msg-=1 247 273 if self.in_msg: 248 274 return 275 result=kw.get('result',None)or k[0] 249 276 defcolor='GREEN' 250 277 if result==True: … … 256 283 msg=str(result) 257 284 self.to_log(msg) 258 Logs.pprint(color or defcolor,msg) 285 try: 286 color=kw['color'] 287 except KeyError: 288 if len(k)>1 and k[1]in Logs.colors_lst: 289 color=k[1] 290 else: 291 color=defcolor 292 Logs.pprint(color,msg) 259 293 def load_special_tools(self,var,ban=[]): 260 294 global waf_dir 261 lst=self.root.find_node(waf_dir).find_node('waflib/extras').ant_glob(var) 262 for x in lst: 263 if not x.name in ban: 264 load_tool(x.name.replace('.py','')) 295 if os.path.isdir(waf_dir): 296 lst=self.root.find_node(waf_dir).find_node('waflib/extras').ant_glob(var) 297 for x in lst: 298 if not x.name in ban: 299 load_tool(x.name.replace('.py','')) 300 else: 301 from zipfile import PyZipFile 302 waflibs=PyZipFile(waf_dir) 303 lst=waflibs.namelist() 304 for x in lst: 305 if not re.match("waflib/extras/%s"%var.replace("*",".*"),var): 306 continue 307 f=os.path.basename(x) 308 doban=False 309 for b in ban: 310 r=b.replace("*",".*") 311 if re.match(b,f): 312 doban=True 313 if not doban: 314 f=f.replace('.py','') 315 load_tool(f) 265 316 cache_modules={} 266 def load_module(path ):317 def load_module(path,encoding=None): 267 318 try: 268 319 return cache_modules[path] … … 271 322 module=imp.new_module(WSCRIPT_FILE) 272 323 try: 273 code=Utils.readf(path,m='rU' )274 except (IOError,OSError):324 code=Utils.readf(path,m='rU',encoding=encoding) 325 except EnvironmentError: 275 326 raise Errors.WafError('Could not read the file %r'%path) 276 327 module_dir=os.path.dirname(path) … … 280 331 cache_modules[path]=module 281 332 return module 282 def load_tool(tool,tooldir=None ):333 def load_tool(tool,tooldir=None,ctx=None): 283 334 if tool=='java': 284 335 tool='javaw' 285 elif tool=='compiler_cc':286 tool='compiler_c'287 336 else: 288 337 tool=tool.replace('++','xx') … … 299 348 sys.path.remove(d) 300 349 else: 301 global waf_dir 302 try: 303 os.stat(os.path.join(waf_dir,'waflib','extras',tool+'.py')) 304 except OSError: 350 for x in('waflib.Tools.%s','waflib.extras.%s','waflib.%s','%s'): 305 351 try: 306 os.stat(os.path.join(waf_dir,'waflib','Tools',tool+'.py')) 307 except OSError: 308 d=tool 309 else: 310 d='waflib.Tools.%s'%tool 311 else: 312 d='waflib.extras.%s'%tool 313 __import__(d) 314 ret=sys.modules[d] 352 __import__(x%tool) 353 break 354 except ImportError: 355 x=None 356 if x is None: 357 __import__(tool) 358 ret=sys.modules[x%tool] 315 359 Context.tools[tool]=ret 316 360 return ret -
waflib/Logs.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os,re,traceback,sys 6 _nocolor=os.environ.get('NOCOLOR','no')not in('no','0','false') 7 try: 8 if not _nocolor: 9 import waflib.ansiterm 10 except ImportError: 11 pass 12 try: 13 import threading 14 except ImportError: 15 if not'JOBS'in os.environ: 16 os.environ['JOBS']='1' 17 else: 18 wlock=threading.Lock() 19 class sync_stream(object): 20 def __init__(self,stream): 21 self.stream=stream 22 self.encoding=self.stream.encoding 23 def write(self,txt): 24 try: 25 wlock.acquire() 26 self.stream.write(txt) 27 self.stream.flush() 28 finally: 29 wlock.release() 30 def fileno(self): 31 return self.stream.fileno() 32 def flush(self): 33 self.stream.flush() 34 def isatty(self): 35 return self.stream.isatty() 36 if not os.environ.get('NOSYNC',False): 37 if id(sys.stdout)==id(sys.__stdout__): 38 sys.stdout=sync_stream(sys.stdout) 39 sys.stderr=sync_stream(sys.stderr) 5 import os,re,traceback,sys,types 6 from waflib import Utils,ansiterm 7 if not os.environ.get('NOSYNC',False): 8 if sys.stdout.isatty()and id(sys.stdout)==id(sys.__stdout__): 9 sys.stdout=ansiterm.AnsiTerm(sys.stdout) 10 if sys.stderr.isatty()and id(sys.stderr)==id(sys.__stderr__): 11 sys.stderr=ansiterm.AnsiTerm(sys.stderr) 40 12 import logging 41 13 LOG_FORMAT="%(asctime)s %(c1)s%(zone)s%(c2)s %(message)s" … … 44 16 verbose=0 45 17 colors_lst={'USE':True,'BOLD':'\x1b[01;1m','RED':'\x1b[01;31m','GREEN':'\x1b[32m','YELLOW':'\x1b[33m','PINK':'\x1b[35m','BLUE':'\x1b[01;34m','CYAN':'\x1b[36m','NORMAL':'\x1b[0m','cursor_on':'\x1b[?25h','cursor_off':'\x1b[?25l',} 46 got_tty=not os.environ.get('TERM','dumb')in['dumb','emacs'] 47 if got_tty: 48 try: 49 got_tty=sys.stderr.isatty()and sys.stdout.isatty() 50 except AttributeError: 51 got_tty=False 52 if(not got_tty and os.environ.get('TERM','dumb')!='msys')or _nocolor: 53 colors_lst['USE']=False 54 def get_term_cols(): 55 return 80 18 indicator='\r\x1b[K%s%s%s' 19 def enable_colors(use): 20 if use==1: 21 if not(sys.stderr.isatty()or sys.stdout.isatty()): 22 use=0 23 if Utils.is_win32: 24 term=os.environ.get('TERM','') 25 else: 26 term=os.environ.get('TERM','dumb') 27 if term in('dumb','emacs'): 28 use=0 29 if use>=1: 30 os.environ['TERM']='vt100' 31 colors_lst['USE']=use 56 32 try: 57 import struct,fcntl,termios 58 except ImportError: 59 pass 60 else: 61 if got_tty: 62 def get_term_cols_real(): 63 dummy_lines,cols=struct.unpack("HHHH",fcntl.ioctl(sys.stderr.fileno(),termios.TIOCGWINSZ,struct.pack("HHHH",0,0,0,0)))[:2] 64 return cols 65 try: 66 get_term_cols_real() 67 except Exception: 68 pass 69 else: 70 get_term_cols=get_term_cols_real 33 get_term_cols=ansiterm.get_term_cols 34 except AttributeError: 35 def get_term_cols(): 36 return 80 71 37 get_term_cols.__doc__=""" 72 38 Get the console width in characters. … … 89 55 pass 90 56 def filter(self,rec): 91 rec.c1=colors.PINK92 rec.c2=colors.NORMAL93 57 rec.zone=rec.module 94 58 if rec.levelno>=logging.INFO: 95 if rec.levelno>=logging.ERROR:96 rec.c1=colors.RED97 elif rec.levelno>=logging.WARNING:98 rec.c1=colors.YELLOW99 else:100 rec.c1=colors.GREEN101 59 return True 102 60 m=re_log.match(rec.msg) … … 109 67 return False 110 68 return True 69 class log_handler(logging.StreamHandler): 70 def emit(self,record): 71 try: 72 try: 73 self.stream=record.stream 74 except AttributeError: 75 if record.levelno>=logging.WARNING: 76 record.stream=self.stream=sys.stderr 77 else: 78 record.stream=self.stream=sys.stdout 79 self.emit_override(record) 80 self.flush() 81 except(KeyboardInterrupt,SystemExit): 82 raise 83 except: 84 self.handleError(record) 85 def emit_override(self,record,**kw): 86 self.terminator=getattr(record,'terminator','\n') 87 stream=self.stream 88 if hasattr(types,"UnicodeType"): 89 msg=self.formatter.format(record) 90 fs='%s'+self.terminator 91 try: 92 if(isinstance(msg,unicode)and getattr(stream,'encoding',None)): 93 fs=fs.decode(stream.encoding) 94 try: 95 stream.write(fs%msg) 96 except UnicodeEncodeError: 97 stream.write((fs%msg).encode(stream.encoding)) 98 else: 99 stream.write(fs%msg) 100 except UnicodeError: 101 stream.write((fs%msg).encode("UTF-8")) 102 else: 103 logging.StreamHandler.emit(self,record) 111 104 class formatter(logging.Formatter): 112 105 def __init__(self): 113 106 logging.Formatter.__init__(self,LOG_FORMAT,HOUR_FORMAT) 114 107 def format(self,rec): 115 if rec.levelno>=logging.WARNING or rec.levelno==logging.INFO: 116 try: 117 msg=rec.msg.decode('utf-8') 118 except Exception: 119 msg=rec.msg 120 return'%s%s%s'%(rec.c1,msg,rec.c2) 108 try: 109 msg=rec.msg.decode('utf-8') 110 except Exception: 111 msg=rec.msg 112 use=colors_lst['USE'] 113 if(use==1 and rec.stream.isatty())or use==2: 114 c1=getattr(rec,'c1',None) 115 if c1 is None: 116 c1='' 117 if rec.levelno>=logging.ERROR: 118 c1=colors.RED 119 elif rec.levelno>=logging.WARNING: 120 c1=colors.YELLOW 121 elif rec.levelno>=logging.INFO: 122 c1=colors.GREEN 123 c2=getattr(rec,'c2',colors.NORMAL) 124 msg='%s%s%s'%(c1,msg,c2) 125 else: 126 msg=msg.replace('\r','\n') 127 msg=re.sub(r'\x1B\[(K|.*?(m|h|l))','',msg) 128 if rec.levelno>=logging.INFO: 129 return msg 130 rec.msg=msg 131 rec.c1=colors.PINK 132 rec.c2=colors.NORMAL 121 133 return logging.Formatter.format(self,rec) 122 134 log=None … … 151 163 log.handlers=[] 152 164 log.filters=[] 153 hdlr=log ging.StreamHandler()165 hdlr=log_handler() 154 166 hdlr.setFormatter(formatter()) 155 167 log.addHandler(hdlr) … … 164 176 logger.setLevel(logging.DEBUG) 165 177 return logger 166 def make_mem_logger(name,to_log,size= 10000):178 def make_mem_logger(name,to_log,size=8192): 167 179 from logging.handlers import MemoryHandler 168 180 logger=logging.getLogger(name) … … 174 186 logger.setLevel(logging.DEBUG) 175 187 return logger 176 def pprint(col,str,label='',sep='\n'): 177 sys.stderr.write("%s%s%s %s%s"%(colors(col),str,colors.NORMAL,label,sep)) 188 def free_logger(logger): 189 try: 190 for x in logger.handlers: 191 x.close() 192 logger.removeHandler(x) 193 except Exception ,e: 194 pass 195 def pprint(col,msg,label='',sep='\n'): 196 info("%s%s%s %s"%(colors(col),msg,colors.NORMAL,label),extra={'terminator':sep}) -
waflib/Node.py
r5525507 r904702d 47 47 def split_path_win32(path): 48 48 if path.startswith('\\\\'): 49 ret=re.split(re_sp,path)[2:] 50 ret[0]='\\'+ret[0] 51 return ret 49 if path.startswith('\\\\?'): 50 path=path[4:] 51 else: 52 ret=re.split(re_sp,path)[2:] 53 ret[0]='\\\\'+ret[0] 54 return ret 52 55 return re.split(re_sp,path) 53 56 if sys.platform=='cygwin': … … 56 59 split_path=split_path_win32 57 60 class Node(object): 61 dict_class=dict 58 62 __slots__=('name','sig','children','parent','cache_abspath','cache_isdir','cache_sig') 59 63 def __init__(self,name,parent): … … 68 72 self.parent=data[1] 69 73 if data[2]is not None: 70 self.children= data[2]74 self.children=self.dict_class(data[2]) 71 75 if data[3]is not None: 72 76 self.sig=data[3] … … 91 95 def delete(self): 92 96 try: 93 if hasattr(self,'children'): 94 shutil.rmtree(self.abspath()) 95 else: 96 os.remove(self.abspath()) 97 except OSError: 98 pass 99 self.evict() 97 try: 98 if hasattr(self,'children'): 99 shutil.rmtree(self.abspath()) 100 else: 101 os.remove(self.abspath()) 102 except OSError ,e: 103 if os.path.exists(self.abspath()): 104 raise e 105 finally: 106 self.evict() 100 107 def evict(self): 101 108 del self.parent.children[self.name] … … 131 138 self.children 132 139 except AttributeError: 133 self.children= {}140 self.children=self.dict_class() 134 141 self.cache_isdir=True 135 142 def find_node(self,lst): … … 144 151 ch=cur.children 145 152 except AttributeError: 146 cur.children= {}153 cur.children=self.dict_class() 147 154 else: 148 155 try: … … 183 190 continue 184 191 else: 185 cur.children= {}192 cur.children=self.dict_class() 186 193 cur=self.__class__(x,cur) 187 194 return cur … … 219 226 c1=c1.parent 220 227 c2=c2.parent 221 for i in range(up): 222 lst.append('..') 228 if c1.parent: 229 for i in range(up): 230 lst.append('..') 231 else: 232 if os.sep=='/'and lst: 233 lst.append('') 223 234 lst.reverse() 224 235 return os.sep.join(lst)or'.' … … 257 268 lst=set(self.children.keys()) 258 269 except AttributeError: 259 self.children= {}270 self.children=self.dict_class() 260 271 else: 261 272 if remove: … … 434 445 name=name[:-len(ext_in)]+ext 435 446 return self.parent.find_or_declare([name]) 436 def nice_path(self,env=None):437 return self.path_from(self.ctx.launch_node())438 447 def bldpath(self): 439 448 return self.path_from(self.ctx.bldnode) … … 450 459 def bld_dir(self): 451 460 return self.parent.bldpath() 452 def bld_base(self):453 s=os.path.splitext(self.name)[0]454 return self.bld_dir()+os.sep+s455 461 def get_bld_sig(self): 456 462 try: … … 462 468 self.cache_sig=ret=self.sig 463 469 return ret 464 search=search_node465 470 pickle_lock=Utils.threading.Lock() 466 471 class Nod3(Node): -
waflib/Options.py
r5525507 r904702d 8 8 options={} 9 9 commands=[] 10 envvars=[] 10 11 lockfile=os.environ.get('WAFLOCK','.lock-waf_%s_build'%sys.platform) 11 try:cache_global=os.path.abspath(os.environ['WAFCACHE'])12 except KeyError:cache_global=''13 12 platform=Utils.unversioned_sys_platform() 14 13 class opt_parser(optparse.OptionParser): … … 16 15 optparse.OptionParser.__init__(self,conflict_handler="resolve",version='waf %s (%s)'%(Context.WAFVERSION,Context.WAFREVISION)) 17 16 self.formatter.width=Logs.get_term_cols() 18 p=self.add_option19 17 self.ctx=ctx 20 jobs=ctx.jobs() 21 p('-j','--jobs',dest='jobs',default=jobs,type='int',help='amount of parallel jobs (%r)'%jobs) 22 p('-k','--keep',dest='keep',default=0,action='count',help='keep running happily even if errors are found') 23 p('-v','--verbose',dest='verbose',default=0,action='count',help='verbosity level -v -vv or -vvv [default: 0]') 24 p('--nocache',dest='nocache',default=False,action='store_true',help='ignore the WAFCACHE (if set)') 25 p('--zones',dest='zones',default='',action='store',help='debugging zones (task_gen, deps, tasks, etc)') 26 gr=optparse.OptionGroup(self,'configure options') 27 self.add_option_group(gr) 28 gr.add_option('-o','--out',action='store',default='',help='build dir for the project',dest='out') 29 gr.add_option('-t','--top',action='store',default='',help='src dir for the project',dest='top') 30 default_prefix=os.environ.get('PREFIX') 31 if not default_prefix: 32 if platform=='win32': 33 d=tempfile.gettempdir() 34 default_prefix=d[0].upper()+d[1:] 35 else: 36 default_prefix='/usr/local/' 37 gr.add_option('--prefix',dest='prefix',default=default_prefix,help='installation prefix [default: %r]'%default_prefix) 38 gr.add_option('--download',dest='download',default=False,action='store_true',help='try to download the tools if missing') 39 gr=optparse.OptionGroup(self,'build and install options') 40 self.add_option_group(gr) 41 gr.add_option('-p','--progress',dest='progress_bar',default=0,action='count',help='-p: progress bar; -pp: ide output') 42 gr.add_option('--targets',dest='targets',default='',action='store',help='task generators, e.g. "target1,target2"') 43 gr=optparse.OptionGroup(self,'step options') 44 self.add_option_group(gr) 45 gr.add_option('--files',dest='files',default='',action='store',help='files to process, by regexp, e.g. "*/main.c,*/test/main.o"') 46 default_destdir=os.environ.get('DESTDIR','') 47 gr=optparse.OptionGroup(self,'install/uninstall options') 48 self.add_option_group(gr) 49 gr.add_option('--destdir',help='installation root [default: %r]'%default_destdir,default=default_destdir,dest='destdir') 50 gr.add_option('-f','--force',dest='force',default=False,action='store_true',help='force file installation') 51 gr.add_option('--distcheck-args',help='arguments to pass to distcheck',default=None,action='store') 18 def print_usage(self,file=None): 19 return self.print_help(file) 52 20 def get_usage(self): 53 21 cmds_str={} 54 22 for cls in Context.classes: 55 if not cls.cmd or cls.cmd=='options' :23 if not cls.cmd or cls.cmd=='options'or cls.cmd.startswith('_'): 56 24 continue 57 25 s=cls.__doc__ or'' … … 59 27 if Context.g_module: 60 28 for(k,v)in Context.g_module.__dict__.items(): 61 if k in ['options','init','shutdown']:29 if k in('options','init','shutdown'): 62 30 continue 63 31 if type(v)is type(Context.create_context): … … 82 50 self.parser=opt_parser(self) 83 51 self.option_groups={} 52 jobs=self.jobs() 53 p=self.add_option 54 color=os.environ.get('NOCOLOR','')and'no'or'auto' 55 p('-c','--color',dest='colors',default=color,action='store',help='whether to use colors (yes/no/auto) [default: auto]',choices=('yes','no','auto')) 56 p('-j','--jobs',dest='jobs',default=jobs,type='int',help='amount of parallel jobs (%r)'%jobs) 57 p('-k','--keep',dest='keep',default=0,action='count',help='continue despite errors (-kk to try harder)') 58 p('-v','--verbose',dest='verbose',default=0,action='count',help='verbosity level -v -vv or -vvv [default: 0]') 59 p('--zones',dest='zones',default='',action='store',help='debugging zones (task_gen, deps, tasks, etc)') 60 gr=self.add_option_group('Configuration options') 61 self.option_groups['configure options']=gr 62 gr.add_option('-o','--out',action='store',default='',help='build dir for the project',dest='out') 63 gr.add_option('-t','--top',action='store',default='',help='src dir for the project',dest='top') 64 default_prefix=getattr(Context.g_module,'default_prefix',os.environ.get('PREFIX')) 65 if not default_prefix: 66 if platform=='win32': 67 d=tempfile.gettempdir() 68 default_prefix=d[0].upper()+d[1:] 69 else: 70 default_prefix='/usr/local/' 71 gr.add_option('--prefix',dest='prefix',default=default_prefix,help='installation prefix [default: %r]'%default_prefix) 72 gr.add_option('--bindir',dest='bindir',help='bindir') 73 gr.add_option('--libdir',dest='libdir',help='libdir') 74 gr=self.add_option_group('Build and installation options') 75 self.option_groups['build and install options']=gr 76 gr.add_option('-p','--progress',dest='progress_bar',default=0,action='count',help='-p: progress bar; -pp: ide output') 77 gr.add_option('--targets',dest='targets',default='',action='store',help='task generators, e.g. "target1,target2"') 78 gr=self.add_option_group('Step options') 79 self.option_groups['step options']=gr 80 gr.add_option('--files',dest='files',default='',action='store',help='files to process, by regexp, e.g. "*/main.c,*/test/main.o"') 81 default_destdir=os.environ.get('DESTDIR','') 82 gr=self.add_option_group('Installation and uninstallation options') 83 self.option_groups['install/uninstall options']=gr 84 gr.add_option('--destdir',help='installation root [default: %r]'%default_destdir,default=default_destdir,dest='destdir') 85 gr.add_option('-f','--force',dest='force',default=False,action='store_true',help='force file installation') 86 gr.add_option('--distcheck-args',metavar='ARGS',help='arguments to pass to distcheck',default=None,action='store') 84 87 def jobs(self): 85 88 count=int(os.environ.get('JOBS',0)) … … 124 127 return None 125 128 def parse_args(self,_args=None): 126 global options,commands 129 global options,commands,envvars 127 130 (options,leftover_args)=self.parser.parse_args(args=_args) 128 commands=leftover_args 131 for arg in leftover_args: 132 if'='in arg: 133 envvars.append(arg) 134 else: 135 commands.append(arg) 129 136 if options.destdir: 130 137 options.destdir=os.path.abspath(os.path.expanduser(options.destdir)) 131 138 if options.verbose>=1: 132 139 self.load('errcheck') 140 colors={'yes':2,'auto':1,'no':0}[options.colors] 141 Logs.enable_colors(colors) 133 142 def execute(self): 134 143 super(OptionsContext,self).execute() -
waflib/Runner.py
r5525507 r904702d 110 110 self.dirty=True 111 111 return tsk 112 def error_handler(self,tsk):113 if not self.bld.keep:114 self.stop=True115 self.error.append(tsk)116 112 def add_task(self,tsk): 117 113 try: … … 144 140 put_pool(x) 145 141 self.pool=[] 142 def skip(self,tsk): 143 tsk.hasrun=Task.SKIPPED 144 def error_handler(self,tsk): 145 if not self.bld.keep: 146 self.stop=True 147 self.error.append(tsk) 148 def task_status(self,tsk): 149 try: 150 return tsk.runnable_status() 151 except Exception: 152 self.processed+=1 153 tsk.err_msg=Utils.ex_stack() 154 if not self.stop and self.bld.keep: 155 self.skip(tsk) 156 if self.bld.keep==1: 157 if Logs.verbose>1 or not self.error: 158 self.error.append(tsk) 159 self.stop=True 160 else: 161 if Logs.verbose>1: 162 self.error.append(tsk) 163 return Task.EXCEPTION 164 tsk.hasrun=Task.EXCEPTION 165 self.error_handler(tsk) 166 return Task.EXCEPTION 146 167 def start(self): 147 168 self.total=self.bld.total() … … 159 180 if self.stop: 160 181 break 161 try: 162 st=tsk.runnable_status() 163 except Exception: 164 self.processed+=1 165 tsk.err_msg=Utils.ex_stack() 166 if not self.stop and self.bld.keep: 167 tsk.hasrun=Task.SKIPPED 168 if self.bld.keep==1: 169 if Logs.verbose>1 or not self.error: 170 self.error.append(tsk) 171 self.stop=True 172 else: 173 if Logs.verbose>1: 174 self.error.append(tsk) 175 continue 176 tsk.hasrun=Task.EXCEPTION 177 self.error_handler(tsk) 178 continue 179 if st==Task.ASK_LATER: 180 self.postpone(tsk) 181 elif st==Task.SKIP_ME: 182 self.processed+=1 183 tsk.hasrun=Task.SKIPPED 184 self.add_more_tasks(tsk) 185 else: 182 st=self.task_status(tsk) 183 if st==Task.RUN_ME: 186 184 tsk.position=(self.processed,self.total) 187 185 self.count+=1 … … 192 190 else: 193 191 self.add_task(tsk) 192 if st==Task.ASK_LATER: 193 self.postpone(tsk) 194 elif st==Task.SKIP_ME: 195 self.processed+=1 196 self.skip(tsk) 197 self.add_more_tasks(tsk) 194 198 while self.error and self.count: 195 199 self.get_out() -
waflib/Scripting.py
r5525507 r904702d 19 19 ctx.parse_args() 20 20 sys.exit(0) 21 if len(sys.argv)>1: 22 potential_wscript=os.path.join(current_directory,sys.argv[1]) 23 if os.path.basename(potential_wscript)=='wscript'and os.path.isfile(potential_wscript): 24 current_directory=os.path.normpath(os.path.dirname(potential_wscript)) 25 sys.argv.pop(1) 21 26 Context.waf_dir=wafdir 22 27 Context.launch_dir=current_directory … … 24 29 if not no_climb: 25 30 for k in no_climb_commands: 26 if k in sys.argv: 27 no_climb=True 28 break 31 for y in sys.argv: 32 if y.startswith(k): 33 no_climb=True 34 break 29 35 cur=current_directory 30 36 while cur: … … 38 44 pass 39 45 else: 40 for x in [env.run_dir,env.top_dir,env.out_dir]:46 for x in(env.run_dir,env.top_dir,env.out_dir): 41 47 if Utils.is_win32: 42 48 if cur==x: … … 85 91 sys.exit(1) 86 92 try: 87 set_main_module( Context.run_dir+os.sep+Context.WSCRIPT_FILE)93 set_main_module(os.path.join(Context.run_dir,Context.WSCRIPT_FILE)) 88 94 except Errors.WafError ,e: 89 95 Logs.pprint('RED',e.verbose_msg) … … 116 122 if not name in Context.g_module.__dict__: 117 123 setattr(Context.g_module,name,obj) 118 for k in [update,dist,distclean,distcheck,update]:124 for k in(update,dist,distclean,distcheck,update): 119 125 set_def(k) 120 126 if not'init'in Context.g_module.__dict__: … … 126 132 def parse_options(): 127 133 Context.create_context('options').execute() 134 for var in Options.envvars: 135 (name,value)=var.split('=',1) 136 os.environ[name.strip()]=value 128 137 if not Options.commands: 129 138 Options.commands=[default_cmd] 130 139 Options.commands=[x for x in Options.commands if x!='options'] 131 140 Logs.verbose=Options.options.verbose 132 Logs.init_log()133 141 if Options.options.zones: 134 142 Logs.zones=Options.options.zones.split(',') … … 144 152 ctx.options=Options.options 145 153 ctx.cmd=cmd_name 146 ctx.execute() 154 try: 155 ctx.execute() 156 finally: 157 ctx.finalize() 147 158 return ctx 148 159 def run_commands(): … … 163 174 for f in files: 164 175 if _can_distclean(f): 165 fname= root+os.sep+f176 fname=os.path.join(root,f) 166 177 try: 167 178 os.remove(fname) 168 179 except OSError: 169 180 Logs.warn('Could not remove %r'%fname) 170 for x in [Context.DBFILE,'config.log']:181 for x in(Context.DBFILE,'config.log'): 171 182 try: 172 183 os.remove(x) … … 194 205 except OSError ,e: 195 206 if e.errno!=errno.ENOENT: 196 Logs.warn(' project %r cannot be removed'%proj[Context.OUT])207 Logs.warn('Could not remove %r'%proj['out_dir']) 197 208 else: 198 209 distclean_dir(proj['out_dir']) 199 210 for k in(proj['out_dir'],proj['top_dir'],proj['run_dir']): 211 p=os.path.join(k,Options.lockfile) 200 212 try: 201 os.remove( os.path.join(k,Options.lockfile))213 os.remove(p) 202 214 except OSError ,e: 203 215 if e.errno!=errno.ENOENT: 204 Logs.warn(' file %r cannot be removed'%f)216 Logs.warn('Could not remove %r'%p) 205 217 if not Options.commands: 206 218 for x in'.waf-1. waf-1. .waf3-1. waf3-1.'.split(): … … 226 238 try: 227 239 node.delete() 228 except Exception:240 except OSError: 229 241 pass 230 242 files=self.get_files() … … 242 254 zip.close() 243 255 else: 244 self.fatal('Valid algo types are tar.bz2, tar.gz or zip')256 self.fatal('Valid algo types are tar.bz2, tar.gz, tar.xz or zip') 245 257 try: 246 258 from hashlib import sha1 as sha … … 291 303 return self.excl 292 304 except AttributeError: 293 self.excl=Node.exclude_regs+' **/waf-1.7.* **/.waf-1.7* **/waf3-1.7.* **/.waf3-1.7* **/*~ **/*.rej **/*.orig **/*.pyc **/*.pyo **/*.bak **/*.swp **/.lock-w*' 294 nd=self.root.find_node(Context.out_dir) 295 if nd: 296 self.excl+=' '+nd.path_from(self.base_path) 305 self.excl=Node.exclude_regs+' **/waf-1.8.* **/.waf-1.8* **/waf3-1.8.* **/.waf3-1.8* **/*~ **/*.rej **/*.orig **/*.pyc **/*.pyo **/*.bak **/*.swp **/.lock-w*' 306 if Context.out_dir: 307 nd=self.root.find_node(Context.out_dir) 308 if nd: 309 self.excl+=' '+nd.path_from(self.base_path) 297 310 return self.excl 298 311 def get_files(self): … … 370 383 Options.commands.insert(0,self.cmd) 371 384 Options.commands.insert(0,'configure') 385 if Configure.autoconfig=='clobber': 386 Options.options.__dict__=env.options 372 387 return 373 388 return execute_method(self) -
waflib/Task.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os, shutil,re,tempfile5 import os,re,sys 6 6 from waflib import Utils,Logs,Errors 7 7 NOT_RUN=0 … … 38 38 return tsk.exec_command(lst, cwd=wd, env=env.env or None) 39 39 ''' 40 def cache_outputs(cls):41 m1=cls.run42 def run(self):43 bld=self.generator.bld44 if bld.cache_global and not bld.nocache:45 if self.can_retrieve_cache():46 return 047 return m1(self)48 cls.run=run49 m2=cls.post_run50 def post_run(self):51 bld=self.generator.bld52 ret=m2(self)53 if bld.cache_global and not bld.nocache:54 self.put_files_cache()55 return ret56 cls.post_run=post_run57 return cls58 40 classes={} 59 41 class store_task_type(type): … … 68 50 (f,dvars)=compile_fun(cls.run_str,cls.shell) 69 51 cls.hcode=cls.run_str 52 cls.orig_run_str=cls.run_str 70 53 cls.run_str=None 71 54 cls.run=f … … 74 57 elif getattr(cls,'run',None)and not'hcode'in cls.__dict__: 75 58 cls.hcode=Utils.h_fun(cls.run) 76 if not getattr(cls,'nocache',None):77 cls =cache_outputs(cls)59 if sys.hexversion>0x3000000: 60 cls.hcode=cls.hcode.encode('iso8859-1','xmlcharrefreplace') 78 61 getattr(cls,'register',classes)[name]=cls 79 62 evil=store_task_type('evil',(object,),{}) … … 95 78 def __str__(self): 96 79 if hasattr(self,'fun'): 97 return 'executing: %s\n'%self.fun.__name__98 return self.__class__.__name__ +'\n'80 return self.fun.__name__ 81 return self.__class__.__name__ 99 82 def __hash__(self): 100 83 return id(self) 84 def keyword(self): 85 if hasattr(self,'fun'): 86 return'Function' 87 return'Processing' 101 88 def exec_command(self,cmd,**kw): 102 89 bld=self.generator.bld … … 151 138 pass 152 139 def log_display(self,bld): 153 bld.to_log(self.display()) 140 if self.generator.bld.progress_bar==3: 141 return 142 s=self.display() 143 if s: 144 if bld.logger: 145 logger=bld.logger 146 else: 147 logger=Logs 148 if self.generator.bld.progress_bar==1: 149 c1=Logs.colors.cursor_off 150 c2=Logs.colors.cursor_on 151 logger.info(s,extra={'stream':sys.stderr,'terminator':'','c1':c1,'c2':c2}) 152 else: 153 logger.info(s,extra={'terminator':'','c1':'','c2':''}) 154 154 def display(self): 155 155 col1=Logs.colors(self.color) … … 179 179 total=master.total 180 180 n=len(str(total)) 181 fs='[%%%dd/%%%dd] %%s%%s%%s'%(n,n) 182 return fs%(cur(),total,col1,s,col2) 181 fs='[%%%dd/%%%dd] %%s%%s%%s%%s\n'%(n,n) 182 kw=self.keyword() 183 if kw: 184 kw+=' ' 185 return fs%(cur(),total,kw,col1,s,col2) 183 186 def attr(self,att,default=None): 184 187 ret=getattr(self,att,self) … … 208 211 def colon(self,var1,var2): 209 212 tmp=self.env[var1] 213 if not tmp: 214 return[] 210 215 if isinstance(var2,str): 211 216 it=self.env[var2] … … 215 220 return[tmp%x for x in it] 216 221 else: 217 if Logs.verbose and not tmp and it:218 Logs.warn('Missing env variable %r for task %r (generator %r)'%(var1,self,self.generator))219 222 lst=[] 220 223 for y in it: … … 233 236 self.run_after=set([]) 234 237 def __str__(self): 235 env=self.env 236 src_str=' '.join([a.nice_path()for a in self.inputs]) 237 tgt_str=' '.join([a.nice_path()for a in self.outputs]) 238 name=self.__class__.__name__ 239 if self.outputs: 240 if(name.endswith('lib')or name.endswith('program'))or not self.inputs: 241 node=self.outputs[0] 242 return node.path_from(node.ctx.launch_node()) 243 if not(self.inputs or self.outputs): 244 return self.__class__.__name__ 245 if len(self.inputs)==1: 246 node=self.inputs[0] 247 return node.path_from(node.ctx.launch_node()) 248 src_str=' '.join([a.path_from(a.ctx.launch_node())for a in self.inputs]) 249 tgt_str=' '.join([a.path_from(a.ctx.launch_node())for a in self.outputs]) 238 250 if self.outputs:sep=' -> ' 239 251 else:sep='' 240 return'%s: %s%s%s\n'%(self.__class__.__name__.replace('_task',''),src_str,sep,tgt_str) 252 return'%s: %s%s%s'%(self.__class__.__name__.replace('_task',''),src_str,sep,tgt_str) 253 def keyword(self): 254 name=self.__class__.__name__ 255 if name.endswith('lib')or name.endswith('program'): 256 return'Linking' 257 if len(self.inputs)==1 and len(self.outputs)==1: 258 return'Compiling' 259 if not self.inputs: 260 if self.outputs: 261 return'Creating' 262 else: 263 return'Running' 264 return'Processing' 241 265 def __repr__(self): 242 266 try: … … 362 386 if prev==self.compute_sig_implicit_deps(): 363 387 return prev 364 except Exception: 388 except Errors.TaskNotReady: 389 raise 390 except EnvironmentError: 365 391 for x in bld.node_deps.get(self.uid(),[]): 366 if x.is_child_of(bld.srcnode):392 if not x.is_bld(): 367 393 try: 368 394 os.stat(x.abspath()) … … 420 446 if not tsk.hasrun: 421 447 raise Errors.TaskNotReady('not ready') 422 def can_retrieve_cache(self): 423 if not getattr(self,'outputs',None): 424 return None 425 sig=self.signature() 426 ssig=Utils.to_hex(self.uid())+Utils.to_hex(sig) 427 dname=os.path.join(self.generator.bld.cache_global,ssig) 428 try: 429 t1=os.stat(dname).st_mtime 430 except OSError: 431 return None 432 for node in self.outputs: 433 orig=os.path.join(dname,node.name) 434 try: 435 shutil.copy2(orig,node.abspath()) 436 os.utime(orig,None) 437 except(OSError,IOError): 438 Logs.debug('task: failed retrieving file') 439 return None 440 try: 441 t2=os.stat(dname).st_mtime 442 except OSError: 443 return None 444 if t1!=t2: 445 return None 446 for node in self.outputs: 447 node.sig=sig 448 if self.generator.bld.progress_bar<1: 449 self.generator.bld.to_log('restoring from cache %r\n'%node.abspath()) 450 self.cached=True 451 return True 452 def put_files_cache(self): 453 if getattr(self,'cached',None): 454 return None 455 if not getattr(self,'outputs',None): 456 return None 457 sig=self.signature() 458 ssig=Utils.to_hex(self.uid())+Utils.to_hex(sig) 459 dname=os.path.join(self.generator.bld.cache_global,ssig) 460 tmpdir=tempfile.mkdtemp(prefix=self.generator.bld.cache_global+os.sep+'waf') 461 try: 462 shutil.rmtree(dname) 463 except Exception: 464 pass 465 try: 466 for node in self.outputs: 467 dest=os.path.join(tmpdir,node.name) 468 shutil.copy2(node.abspath(),dest) 469 except(OSError,IOError): 470 try: 471 shutil.rmtree(tmpdir) 472 except Exception: 473 pass 474 else: 475 try: 476 os.rename(tmpdir,dname) 477 except OSError: 478 try: 479 shutil.rmtree(tmpdir) 480 except Exception: 481 pass 482 else: 483 try: 484 os.chmod(dname,Utils.O755) 485 except Exception: 486 pass 448 if sys.hexversion>0x3000000: 449 def uid(self): 450 try: 451 return self.uid_ 452 except AttributeError: 453 m=Utils.md5() 454 up=m.update 455 up(self.__class__.__name__.encode('iso8859-1','xmlcharrefreplace')) 456 for x in self.inputs+self.outputs: 457 up(x.abspath().encode('iso8859-1','xmlcharrefreplace')) 458 self.uid_=m.digest() 459 return self.uid_ 460 uid.__doc__=Task.uid.__doc__ 461 Task.uid=uid 487 462 def is_before(t1,t2): 488 463 to_list=Utils.to_list … … 579 554 g=match.group 580 555 if g('dollar'):return"$" 556 elif g('backslash'):return'\\' 581 557 elif g('subst'):extr.append((g('var'),g('code')));return"<<|@|>>" 582 558 return None -
waflib/TaskGen.py
r5525507 r904702d 6 6 from waflib import Task,Utils,Logs,Errors,ConfigSet,Node 7 7 feats=Utils.defaultdict(set) 8 HEADER_EXTS=['.h','.hpp','.hxx','.hh'] 8 9 class task_gen(object): 9 mappings= {}10 mappings=Utils.ordered_iter_dict() 10 11 prec=Utils.defaultdict(list) 11 12 def __init__(self,*k,**kw): … … 37 38 lst=[] 38 39 for x in self.__dict__.keys(): 39 if x not in ['env','bld','compiled_tasks','tasks']:40 if x not in('env','bld','compiled_tasks','tasks'): 40 41 lst.append("%s=%s"%(x,repr(getattr(self,x)))) 41 42 return"bld(%s) in %s"%(", ".join(lst),self.path.abspath()) … … 112 113 def get_hook(self,node): 113 114 name=node.name 114 for k in self.mappings: 115 if name.endswith(k): 116 return self.mappings[k] 115 if self.mappings: 116 for k in self.mappings: 117 if name.endswith(k): 118 return self.mappings[k] 117 119 for k in task_gen.mappings: 118 120 if name.endswith(k): 119 121 return task_gen.mappings[k] 120 raise Errors.WafError("File %r has no mapping in %r ( did you forgetto load a waf tool?)"%(node,task_gen.mappings.keys()))121 def create_task(self,name,src=None,tgt=None ):122 raise Errors.WafError("File %r has no mapping in %r (have you forgotten to load a waf tool?)"%(node,task_gen.mappings.keys())) 123 def create_task(self,name,src=None,tgt=None,**kw): 122 124 task=Task.classes[name](env=self.env.derive(),generator=self) 123 125 if src: … … 125 127 if tgt: 126 128 task.set_outputs(tgt) 129 task.__dict__.update(kw) 127 130 self.tasks.append(task) 128 131 return task … … 130 133 newobj=self.bld() 131 134 for x in self.__dict__: 132 if x in ['env','bld']:135 if x in('env','bld'): 133 136 continue 134 elif x in ['path','features']:137 elif x in('path','features'): 135 138 setattr(newobj,x,getattr(self,x)) 136 139 else: … … 154 157 tsk=self.create_task(name,node) 155 158 cnt=0 156 keys= list(self.mappings.keys())+list(self.__class__.mappings.keys())159 keys=set(self.mappings.keys())|set(self.__class__.mappings.keys()) 157 160 for x in ext: 158 161 k=node.change_ext(x,ext_in=_ext_in) … … 213 216 path=path or self.path 214 217 find=path.find_resource 215 if isinstance(lst, self.path.__class__):218 if isinstance(lst,Node.Node): 216 219 lst=[lst] 217 220 for x in Utils.to_list(lst): … … 263 266 if getattr(self,'always',None): 264 267 Task.always_run(cls) 265 for x in ['after','before','ext_in','ext_out']:268 for x in('after','before','ext_in','ext_out'): 266 269 setattr(cls,x,getattr(self,x,[])) 267 270 if getattr(self,'cache_rule','True'): … … 308 311 return None 309 312 if getattr(self.generator,'fun',None): 310 self.generator.fun(self)313 return self.generator.fun(self) 311 314 code=self.inputs[0].read(encoding=getattr(self.generator,'encoding','ISO8859-1')) 312 315 if getattr(self.generator,'subst_fun',None): 313 316 code=self.generator.subst_fun(self,code) 314 if code :317 if code is not None: 315 318 self.outputs[0].write(code,encoding=getattr(self.generator,'encoding','ISO8859-1')) 316 319 return … … 330 333 d={} 331 334 for x in lst: 332 tmp=getattr(self.generator,x,'')or self.env.get_flat(x)or self.env.get_flat(x.upper()) 333 d[x]=str(tmp) 335 tmp=getattr(self.generator,x,'')or self.env[x]or self.env[x.upper()] 336 try: 337 tmp=''.join(tmp) 338 except TypeError: 339 tmp=str(tmp) 340 d[x]=tmp 334 341 code=code%d 335 342 self.outputs[0].write(code,encoding=getattr(self.generator,'encoding','ISO8859-1')) … … 398 405 has_constraints=True 399 406 setattr(tsk,k,val) 400 if not has_constraints and b.name.endswith('.h'): 401 tsk.before=[k for k in('c','cxx')if k in Task.classes] 407 if not has_constraints: 408 global HEADER_EXTS 409 for xt in HEADER_EXTS: 410 if b.name.endswith(xt): 411 tsk.before=[k for k in('c','cxx')if k in Task.classes] 412 break 402 413 inst_to=getattr(self,'install_path',None) 403 414 if inst_to: -
waflib/Tools/ar.py
r5525507 r904702d 9 9 def configure(conf): 10 10 conf.find_program('ar',var='AR') 11 conf.env.ARFLAGS='rcs' 11 conf.add_os_flags('ARFLAGS') 12 if not conf.env.ARFLAGS: 13 conf.env.ARFLAGS=['rcs'] -
waflib/Tools/asm.py
r5525507 r904702d 10 10 class asm(Task.Task): 11 11 color='BLUE' 12 run_str='${AS} ${ASFLAGS} ${ASMPATH_ST:INCPATHS} ${ AS_SRC_F}${SRC} ${AS_TGT_F}${TGT}'12 run_str='${AS} ${ASFLAGS} ${ASMPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${AS_SRC_F}${SRC} ${AS_TGT_F}${TGT}' 13 13 @extension('.s','.S','.asm','.ASM','.spp','.SPP') 14 14 def asm_hook(self,node): -
waflib/Tools/c.py
r5525507 r904702d 8 8 @TaskGen.extension('.c') 9 9 def c_hook(self,node): 10 if not self.env.CC and self.env.CXX: 11 return self.create_compiled_task('cxx',node) 10 12 return self.create_compiled_task('c',node) 11 13 class c(Task.Task): 12 run_str='${CC} ${ARCH_ST:ARCH} ${CFLAGS} ${CPPFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT }'14 run_str='${CC} ${ARCH_ST:ARCH} ${CFLAGS} ${CPPFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT[0].abspath()}' 13 15 vars=['CCDEPS'] 14 16 ext_in=['.h'] -
waflib/Tools/c_aliases.py
r5525507 r904702d 30 30 if'java'in exts: 31 31 return'java' 32 if type in ['program','shlib','stlib']:32 if type in('program','shlib','stlib'): 33 33 for x in feats: 34 if x in ['cxx','d','c']:34 if x in('cxx','d','c'): 35 35 feats.append(x+type) 36 36 return feats -
waflib/Tools/c_config.py
r5525507 r904702d 44 44 MACRO_TO_DEST_CPU={'__x86_64__':'x86_64','__amd64__':'x86_64','__i386__':'x86','__ia64__':'ia','__mips__':'mips','__sparc__':'sparc','__alpha__':'alpha','__aarch64__':'aarch64','__thumb__':'thumb','__arm__':'arm','__hppa__':'hppa','__powerpc__':'powerpc','__ppc__':'powerpc','__convex__':'convex','__m68k__':'m68k','__s390x__':'s390x','__s390__':'s390','__sh__':'sh',} 45 45 @conf 46 def parse_flags(self,line,uselib_store,env=None,force_static=False ):46 def parse_flags(self,line,uselib_store,env=None,force_static=False,posix=None): 47 47 assert(isinstance(line,str)) 48 48 env=env or self.env 49 app=env.append_value 50 appu=env.append_unique 51 lex=shlex.shlex(line,posix=False) 49 if posix is None: 50 posix=True 51 if'\\'in line: 52 posix=('\\ 'in line)or('\\\\'in line) 53 lex=shlex.shlex(line,posix=posix) 52 54 lex.whitespace_split=True 53 55 lex.commenters='' 54 56 lst=list(lex) 57 app=env.append_value 58 appu=env.append_unique 55 59 uselib=uselib_store 56 60 while lst: … … 61 65 if not ot:ot=lst.pop(0) 62 66 appu('INCLUDES_'+uselib,[ot]) 63 elif st=='-i nclude':67 elif st=='-i': 64 68 tmp=[x,lst.pop(0)] 65 69 app('CFLAGS',tmp) … … 85 89 elif x.startswith('-F'): 86 90 appu('FRAMEWORKPATH_'+uselib,[x[2:]]) 91 elif x=='-Wl,-rpath': 92 app('RPATH_'+uselib,lst.pop(0)) 93 elif x.startswith('-Wl,-R'): 94 app('RPATH_'+uselib,x[6:]) 95 elif x.startswith('-Wl,-rpath,'): 96 app('RPATH_'+uselib,x[11:]) 87 97 elif x.startswith('-Wl'): 88 98 app('LINKFLAGS_'+uselib,[x]) … … 92 102 elif x.startswith('-bundle'): 93 103 app('LINKFLAGS_'+uselib,[x]) 94 elif x.startswith('-undefined') :104 elif x.startswith('-undefined')or x.startswith('-Xlinker'): 95 105 arg=lst.pop(0) 96 106 app('LINKFLAGS_'+uselib,[x,arg]) … … 102 112 elif x.endswith('.a')or x.endswith('.so')or x.endswith('.dylib')or x.endswith('.lib'): 103 113 appu('LINKFLAGS_'+uselib,[x]) 104 @conf105 def ret_msg(self,f,kw):106 if isinstance(f,str):107 return f108 return f(kw)109 114 @conf 110 115 def validate_cfg(self,kw): … … 133 138 kw['msg']='Checking for %r %s %s'%(kw['package'],cfg_ver[x],kw[y]) 134 139 return 140 if not'define_name'in kw: 141 pkgname=kw.get('uselib_store',kw['package'].upper()) 142 kw['define_name']=self.have_define(pkgname) 143 if not'uselib_store'in kw: 144 self.undefine(kw['define_name']) 135 145 if not'msg'in kw: 136 146 kw['msg']='Checking for %r'%(kw['package']or kw['path']) 137 147 @conf 138 148 def exec_cfg(self,kw): 149 path=Utils.to_list(kw['path']) 139 150 def define_it(): 140 self.define(self.have_define(kw.get('uselib_store',kw['package'])),1,0) 151 pkgname=kw.get('uselib_store',kw['package'].upper()) 152 if kw.get('global_define'): 153 self.define(self.have_define(kw['package']),1,False) 154 else: 155 self.env.append_unique('DEFINES_%s'%pkgname,"%s=1"%self.have_define(pkgname)) 156 self.env[self.have_define(pkgname)]=1 141 157 if'atleast_pkgconfig_version'in kw: 142 cmd= [kw['path'],'--atleast-pkgconfig-version=%s'%kw['atleast_pkgconfig_version']]158 cmd=path+['--atleast-pkgconfig-version=%s'%kw['atleast_pkgconfig_version']] 143 159 self.cmd_and_log(cmd) 144 160 if not'okmsg'in kw: … … 148 164 y=x.replace('-','_') 149 165 if y in kw: 150 self.cmd_and_log( [kw['path'],'--%s=%s'%(x,kw[y]),kw['package']])166 self.cmd_and_log(path+['--%s=%s'%(x,kw[y]),kw['package']]) 151 167 if not'okmsg'in kw: 152 168 kw['okmsg']='yes' … … 154 170 break 155 171 if'modversion'in kw: 156 version=self.cmd_and_log( [kw['path'],'--modversion',kw['modversion']]).strip()172 version=self.cmd_and_log(path+['--modversion',kw['modversion']]).strip() 157 173 self.define('%s_VERSION'%Utils.quote_define_name(kw.get('uselib_store',kw['modversion'])),version) 158 174 return version 159 lst=[ kw['path']]175 lst=[]+path 160 176 defi=kw.get('define_variable',None) 161 177 if not defi: … … 163 179 for key,val in defi.items(): 164 180 lst.append('--define-variable=%s=%s'%(key,val)) 165 static= False181 static=kw.get('force_static',False) 166 182 if'args'in kw: 167 183 args=Utils.to_list(kw['args']) … … 185 201 kw['okmsg']='yes' 186 202 define_it() 187 self.parse_flags(ret,kw.get('uselib_store',kw['package'].upper()),kw.get('env',self.env),force_static=static )203 self.parse_flags(ret,kw.get('uselib_store',kw['package'].upper()),kw.get('env',self.env),force_static=static,posix=kw.get('posix',None)) 188 204 return ret 189 205 @conf … … 195 211 self.validate_cfg(kw) 196 212 if'msg'in kw: 197 self.start_msg(kw['msg'] )213 self.start_msg(kw['msg'],**kw) 198 214 ret=None 199 215 try: … … 201 217 except self.errors.WafError: 202 218 if'errmsg'in kw: 203 self.end_msg(kw['errmsg'],'YELLOW' )219 self.end_msg(kw['errmsg'],'YELLOW',**kw) 204 220 if Logs.verbose>1: 205 221 raise … … 207 223 self.fatal('The configuration failed') 208 224 else: 225 if not ret: 226 ret=True 209 227 kw['success']=ret 210 228 if'okmsg'in kw: 211 self.end_msg(self.ret_msg(kw['okmsg'],kw) )229 self.end_msg(self.ret_msg(kw['okmsg'],kw),**kw) 212 230 return ret 231 def build_fun(bld): 232 if bld.kw['compile_filename']: 233 node=bld.srcnode.make_node(bld.kw['compile_filename']) 234 node.write(bld.kw['code']) 235 o=bld(features=bld.kw['features'],source=bld.kw['compile_filename'],target='testprog') 236 for k,v in bld.kw.items(): 237 setattr(o,k,v) 238 if not bld.kw.get('quiet',None): 239 bld.conf.to_log("==>\n%s\n<=="%bld.kw['code']) 213 240 @conf 214 241 def validate_c(self,kw): 242 if not'build_fun'in kw: 243 kw['build_fun']=build_fun 215 244 if not'env'in kw: 216 245 kw['env']=self.env.derive() … … 307 336 if not'errmsg'in kw: 308 337 kw['errmsg']='no' 309 for(flagsname,flagstype)in [('cxxflags','compiler'),('cflags','compiler'),('linkflags','linker')]:338 for(flagsname,flagstype)in(('cxxflags','compiler'),('cflags','compiler'),('linkflags','linker')): 310 339 if flagsname in kw: 311 340 if not'msg'in kw: … … 369 398 def check(self,*k,**kw): 370 399 self.validate_c(kw) 371 self.start_msg(kw['msg'] )400 self.start_msg(kw['msg'],**kw) 372 401 ret=None 373 402 try: 374 ret=self.run_ c_code(*k,**kw)403 ret=self.run_build(*k,**kw) 375 404 except self.errors.ConfigurationError: 376 self.end_msg(kw['errmsg'],'YELLOW' )405 self.end_msg(kw['errmsg'],'YELLOW',**kw) 377 406 if Logs.verbose>1: 378 407 raise … … 383 412 ret=self.post_check(*k,**kw) 384 413 if not ret: 385 self.end_msg(kw['errmsg'],'YELLOW' )414 self.end_msg(kw['errmsg'],'YELLOW',**kw) 386 415 self.fatal('The configuration failed %r'%ret) 387 416 else: 388 self.end_msg(self.ret_msg(kw['okmsg'],kw) )417 self.end_msg(self.ret_msg(kw['okmsg'],kw),**kw) 389 418 return ret 390 419 class test_exec(Task.Task): … … 409 438 def test_exec_fun(self): 410 439 self.create_task('test_exec',self.link_task.outputs[0]) 411 CACHE_RESULTS=1412 COMPILE_ERRORS=2413 @conf414 def run_c_code(self,*k,**kw):415 lst=[str(v)for(p,v)in kw.items()if p!='env']416 h=Utils.h_list(lst)417 dir=self.bldnode.abspath()+os.sep+(not Utils.is_win32 and'.'or'')+'conf_check_'+Utils.to_hex(h)418 try:419 os.makedirs(dir)420 except OSError:421 pass422 try:423 os.stat(dir)424 except OSError:425 self.fatal('cannot use the configuration test folder %r'%dir)426 cachemode=getattr(Options.options,'confcache',None)427 if cachemode==CACHE_RESULTS:428 try:429 proj=ConfigSet.ConfigSet(os.path.join(dir,'cache_run_c_code'))430 except OSError:431 pass432 else:433 ret=proj['cache_run_c_code']434 if isinstance(ret,str)and ret.startswith('Test does not build'):435 self.fatal(ret)436 return ret437 bdir=os.path.join(dir,'testbuild')438 if not os.path.exists(bdir):439 os.makedirs(bdir)440 self.test_bld=bld=Build.BuildContext(top_dir=dir,out_dir=bdir)441 bld.init_dirs()442 bld.progress_bar=0443 bld.targets='*'444 if kw['compile_filename']:445 node=bld.srcnode.make_node(kw['compile_filename'])446 node.write(kw['code'])447 bld.logger=self.logger448 bld.all_envs.update(self.all_envs)449 bld.env=kw['env']450 o=bld(features=kw['features'],source=kw['compile_filename'],target='testprog')451 for k,v in kw.items():452 setattr(o,k,v)453 self.to_log("==>\n%s\n<=="%kw['code'])454 bld.targets='*'455 ret=-1456 try:457 try:458 bld.compile()459 except Errors.WafError:460 ret='Test does not build: %s'%Utils.ex_stack()461 self.fatal(ret)462 else:463 ret=getattr(bld,'retval',0)464 finally:465 proj=ConfigSet.ConfigSet()466 proj['cache_run_c_code']=ret467 proj.store(os.path.join(dir,'cache_run_c_code'))468 return ret469 440 @conf 470 441 def check_cxx(self,*k,**kw): … … 530 501 return(self.env.HAVE_PAT or'HAVE_%s')%Utils.quote_define_name(key) 531 502 @conf 532 def write_config_header(self,configfile='',guard='',top=False,env=None,defines=True,headers=False,remove=True,define_prefix=''): 533 if env: 534 Logs.warn('Cannot pass env to write_config_header') 503 def write_config_header(self,configfile='',guard='',top=False,defines=True,headers=False,remove=True,define_prefix=''): 535 504 if not configfile:configfile=WAF_CONFIG_H 536 505 waf_guard=guard or'W_%s_WAF'%Utils.quote_define_name(configfile) … … 555 524 lst.append('#include <%s>'%x) 556 525 if defines: 557 for x in self.env[DEFKEYS]: 558 if self.is_defined(x): 559 val=self.get_define(x) 560 lst.append('#define %s %s'%(define_prefix+x,val)) 561 else: 562 lst.append('/* #undef %s */'%(define_prefix+x)) 526 tbl={} 527 for k in self.env['DEFINES']: 528 a,_,b=k.partition('=') 529 tbl[a]=b 530 for k in self.env[DEFKEYS]: 531 try: 532 txt='#define %s%s %s'%(define_prefix,k,tbl[k]) 533 except KeyError: 534 txt='/* #undef %s%s */'%(define_prefix,k) 535 lst.append(txt) 563 536 return"\n".join(lst) 564 537 @conf … … 585 558 conf.load('cxx') 586 559 @conf 587 def get_cc_version(conf,cc,gcc=False,icc=False ):560 def get_cc_version(conf,cc,gcc=False,icc=False,clang=False): 588 561 cmd=cc+['-dM','-E','-'] 589 562 env=conf.env.env or None … … 603 576 if icc and out.find('__INTEL_COMPILER')<0: 604 577 conf.fatal('Not icc/icpc') 578 if clang and out.find('__clang__')<0: 579 conf.fatal('Not clang/clang++') 580 if not clang and out.find('__clang__')>=0: 581 conf.fatal('Could not find g++, if renamed try eg: CXX=g++48 waf configure') 605 582 k={} 606 if icc or gcc :583 if icc or gcc or clang: 607 584 out=out.splitlines() 608 585 for line in out: … … 646 623 else: 647 624 if isD('__clang__'): 648 conf.env['CC_VERSION']=(k['__clang_major__'],k['__clang_minor__'],k['__clang_patchlevel__']) 625 try: 626 conf.env['CC_VERSION']=(k['__clang_major__'],k['__clang_minor__'],k['__clang_patchlevel__']) 627 except KeyError: 628 conf.env['CC_VERSION']=(k['__GNUC__'],k['__GNUC_MINOR__'],k['__GNUC_PATCHLEVEL__']) 649 629 else: 650 conf.env['CC_VERSION']=(k['__GNUC__'],k['__GNUC_MINOR__'],k['__GNUC_PATCHLEVEL__']) 630 try: 631 conf.env['CC_VERSION']=(k['__GNUC__'],k['__GNUC_MINOR__'],k['__GNUC_PATCHLEVEL__']) 632 except KeyError: 633 conf.env['CC_VERSION']=(k['__GNUC__'],k['__GNUC_MINOR__'],0) 651 634 return k 652 635 @conf … … 688 671 def add_as_needed(self): 689 672 if self.env.DEST_BINFMT=='elf'and'gcc'in(self.env.CXX_NAME,self.env.CC_NAME): 690 self.env.append_unique('LINKFLAGS','- -as-needed')673 self.env.append_unique('LINKFLAGS','-Wl,--as-needed') 691 674 class cfgtask(Task.TaskBase): 692 675 def display(self): … … 709 692 @conf 710 693 def multicheck(self,*k,**kw): 711 self.start_msg(kw.get('msg','Executing %d configuration tests'%len(k)) )694 self.start_msg(kw.get('msg','Executing %d configuration tests'%len(k)),**kw) 712 695 class par(object): 713 696 def __init__(self): 714 697 self.keep=False 715 self.cache_global=Options.cache_global716 self.nocache=Options.options.nocache717 698 self.returned_tasks=[] 718 699 self.task_sigs={} … … 742 723 for x in tasks: 743 724 if x.hasrun!=Task.SUCCESS: 744 self.end_msg(kw.get('errmsg','no'),color='YELLOW' )725 self.end_msg(kw.get('errmsg','no'),color='YELLOW',**kw) 745 726 self.fatal(kw.get('fatalmsg',None)or'One of the tests has failed, see the config.log for more information') 746 self.end_msg('ok' )727 self.end_msg('ok',**kw) -
waflib/Tools/c_preproc.py
r5525507 r904702d 16 16 use_trigraphs=0 17 17 strict_quotes=0 18 g_optrans={'not':'!',' and':'&&','bitand':'&','and_eq':'&=','or':'||','bitor':'|','or_eq':'|=','xor':'^','xor_eq':'^=','compl':'~',}18 g_optrans={'not':'!','not_eq':'!','and':'&&','and_eq':'&=','or':'||','or_eq':'|=','xor':'^','xor_eq':'^=','bitand':'&','bitor':'|','compl':'~',} 19 19 re_lines=re.compile('^[ \t]*(#|%:)[ \t]*(ifdef|ifndef|if|else|elif|endif|include|import|define|undef|pragma)[ \t]*(.*)\r*$',re.IGNORECASE|re.MULTILINE) 20 20 re_mac=re.compile("^[a-zA-Z_]\w*") … … 72 72 elif d=='/':c=a/b 73 73 elif d=='^':c=a^b 74 elif d=='|':c=a|b75 elif d=='||':c=int(a or b)76 elif d=='&':c=a&b77 elif d=='&&':c=int(a and b)78 74 elif d=='==':c=int(a==b) 79 elif d=='!=':c=int(a!=b) 75 elif d=='|'or d=='bitor':c=a|b 76 elif d=='||'or d=='or':c=int(a or b) 77 elif d=='&'or d=='bitand':c=a&b 78 elif d=='&&'or d=='and':c=int(a and b) 79 elif d=='!='or d=='not_eq':c=int(a!=b) 80 elif d=='^'or d=='xor':c=int(a^b) 80 81 elif d=='<=':c=int(a<=b) 81 82 elif d=='<':c=int(a<b) 82 83 elif d=='>':c=int(a>b) 83 84 elif d=='>=':c=int(a>=b) 84 elif d=='^':c=int(a^b)85 85 elif d=='<<':c=a<<b 86 86 elif d=='>>':c=a>>b … … 382 382 else: 383 383 if toks[0][1]=='<'and toks[-1][1]=='>': 384 return stringize(toks).lstrip('<').rstrip('>') 384 ret='<',stringize(toks).lstrip('<').rstrip('>') 385 return ret 385 386 raise PreprocError("could not parse include %s."%txt) 386 387 def parse_char(txt): … … 411 412 if v: 412 413 if name==IDENT: 413 try:v=g_optrans[v];name=OP 414 try: 415 g_optrans[v]; 416 name=OP 414 417 except KeyError: 415 418 if v.lower()=="true": … … 473 476 return ret 474 477 def tryfind(self,filename): 478 if filename.endswith('.moc'): 479 self.names.append(filename) 480 return None 475 481 self.curfile=filename 476 482 found=self.cached_find_resource(self.currentnode_stack[-1],filename) … … 481 487 if found and not found in self.ban_includes: 482 488 self.nodes.append(found) 483 if filename[-4:]!='.moc': 484 self.addlines(found) 489 self.addlines(found) 485 490 else: 486 491 if not filename in self.names: … … 520 525 self.parse_cache=bld.parse_cache 521 526 except AttributeError: 522 bld.parse_cache={} 523 self.parse_cache=bld.parse_cache 527 self.parse_cache=bld.parse_cache={} 524 528 self.current_file=node 525 529 self.addlines(node) -
waflib/Tools/ccroot.py
r5525507 r904702d 76 76 name=name+'-'+nums[0] 77 77 elif self.env.DEST_OS=='openbsd': 78 pattern='%s.%s.%s'%(pattern,nums[0],nums[1]) 78 pattern='%s.%s'%(pattern,nums[0]) 79 if len(nums)>=2: 80 pattern+='.%s'%nums[1] 79 81 tmp=folder+os.sep+pattern%name 80 82 target=self.generator.path.find_or_declare(tmp) … … 82 84 class stlink_task(link_task): 83 85 run_str='${AR} ${ARFLAGS} ${AR_TGT_F}${TGT} ${AR_SRC_F}${SRC}' 86 chmod=Utils.O644 84 87 def rm_tgt(cls): 85 88 old=cls.run … … 112 115 inst_to=self.link_task.__class__.inst_to 113 116 if inst_to: 114 self.install_task=self.bld.install_files(inst_to,self.link_task.outputs[:],env=self.env,chmod=self.link_task.chmod )117 self.install_task=self.bld.install_files(inst_to,self.link_task.outputs[:],env=self.env,chmod=self.link_task.chmod,task=self.link_task) 115 118 @taskgen_method 116 119 def use_rec(self,name,**kw): … … 140 143 p=self.tmp_use_prec 141 144 for x in self.to_list(getattr(y,'use',[])): 145 if self.env["STLIB_"+x]: 146 continue 142 147 try: 143 148 p[x].append(name) … … 191 196 var=y.tmp_use_var 192 197 if var and link_task: 193 if var=='LIB'or y.tmp_use_stlib :198 if var=='LIB'or y.tmp_use_stlib or x in names: 194 199 self.env.append_value(var,[y.target[y.target.rfind(os.sep)+1:]]) 195 200 self.link_task.dep_nodes.extend(y.link_task.outputs) 196 201 tmp_path=y.link_task.outputs[0].parent.path_from(self.bld.bldnode) 197 self.env.append_ value(var+'PATH',[tmp_path])202 self.env.append_unique(var+'PATH',[tmp_path]) 198 203 else: 199 204 if y.tmp_use_objects: … … 206 211 try: 207 212 y=self.bld.get_tgen_by_name(x) 208 except E xception:213 except Errors.WafError: 209 214 if not self.env['STLIB_'+x]and not x in self.uselib: 210 215 self.uselib.append(x) 211 216 else: 212 for k in self.to_list(getattr(y,'use lib',[])):217 for k in self.to_list(getattr(y,'use',[])): 213 218 if not self.env['STLIB_'+k]and not k in self.uselib: 214 219 self.uselib.append(k) … … 239 244 _vars=self.get_uselib_vars() 240 245 env=self.env 241 for x in _vars: 242 y=x.lower() 243 env.append_unique(x,self.to_list(getattr(self,y,[]))) 244 for x in self.features: 245 for var in _vars: 246 compvar='%s_%s'%(var,x) 247 env.append_value(var,env[compvar]) 248 for x in self.to_list(getattr(self,'uselib',[])): 249 for v in _vars: 250 env.append_value(v,env[v+'_'+x]) 246 app=env.append_value 247 feature_uselib=self.features+self.to_list(getattr(self,'uselib',[])) 248 for var in _vars: 249 y=var.lower() 250 val=getattr(self,y,[]) 251 if val: 252 app(var,self.to_list(val)) 253 for x in feature_uselib: 254 val=env['%s_%s'%(var,x)] 255 if val: 256 app(var,val) 251 257 @feature('cshlib','cxxshlib','fcshlib') 252 258 @after_method('apply_link') … … 272 278 else: 273 279 self.link_task.inputs.append(node) 274 try: 275 inst_to=self.install_path 276 except AttributeError: 277 inst_to=self.link_task.__class__.inst_to 278 if not inst_to: 279 return 280 self.implib_install_task=self.bld.install_as('${LIBDIR}/%s'%implib.name,implib,self.env) 281 re_vnum=re.compile('^([1-9]\\d*|0)[.]([1-9]\\d*|0)[.]([1-9]\\d*|0)$') 280 if getattr(self,'install_task',None): 281 try: 282 inst_to=self.install_path_implib 283 except AttributeError: 284 try: 285 inst_to=self.install_path 286 except AttributeError: 287 inst_to='${IMPLIBDIR}' 288 self.install_task.dest='${BINDIR}' 289 if not self.env.IMPLIBDIR: 290 self.env.IMPLIBDIR=self.env.LIBDIR 291 self.implib_install_task=self.bld.install_files(inst_to,implib,env=self.env,chmod=self.link_task.chmod,task=self.link_task) 292 re_vnum=re.compile('^([1-9]\\d*|0)([.]([1-9]\\d*|0)[.]([1-9]\\d*|0))?$') 282 293 @feature('cshlib','cxxshlib','dshlib','fcshlib','vnum') 283 294 @after_method('apply_link','propagate_uselib_vars') … … 301 312 self.env.append_value('LINKFLAGS',v.split()) 302 313 if self.env.DEST_OS!='openbsd': 303 self.create_task('vnum',node,[node.parent.find_or_declare(name2),node.parent.find_or_declare(name3)]) 314 outs=[node.parent.find_or_declare(name3)] 315 if name2!=name3: 316 outs.append(node.parent.find_or_declare(name2)) 317 self.create_task('vnum',node,outs) 304 318 if getattr(self,'install_task',None): 305 319 self.install_task.hasrun=Task.SKIP_ME … … 312 326 else: 313 327 t1=bld.install_as(path+os.sep+name3,node,env=self.env,chmod=self.link_task.chmod) 314 t2=bld.symlink_as(path+os.sep+name2,name3)315 328 t3=bld.symlink_as(path+os.sep+libname,name3) 316 self.vnum_install_task=(t1,t2,t3) 329 if name2!=name3: 330 t2=bld.symlink_as(path+os.sep+name2,name3) 331 self.vnum_install_task=(t1,t2,t3) 332 else: 333 self.vnum_install_task=(t1,t3) 317 334 if'-dynamiclib'in self.env['LINKFLAGS']: 318 335 try: … … 328 345 quient=True 329 346 ext_in=['.bin'] 347 def keyword(self): 348 return'Symlinking' 330 349 def run(self): 331 350 for x in self.outputs: -
waflib/Tools/compiler_c.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os,sys,imp,types 5 import os,sys,imp,types,re 6 6 from waflib.Tools import ccroot 7 7 from waflib import Utils,Configure 8 8 from waflib.Logs import debug 9 c_compiler={'win32':['msvc','gcc'],'cygwin':['gcc'],'darwin':['gcc'],'aix':['xlc','gcc'],'linux':['gcc','icc'],'sunos':['suncc','gcc'],'irix':['gcc','irixcc'],'hpux':['gcc'],'gnu':['gcc'],'java':['gcc','msvc','icc'],'default':['gcc'],} 9 c_compiler={'win32':['msvc','gcc','clang'],'cygwin':['gcc'],'darwin':['clang','gcc'],'aix':['xlc','gcc','clang'],'linux':['gcc','clang','icc'],'sunos':['suncc','gcc'],'irix':['gcc','irixcc'],'hpux':['gcc'],'gnu':['gcc','clang'],'java':['gcc','msvc','clang','icc'],'default':['gcc','clang'],} 10 def default_compilers(): 11 build_platform=Utils.unversioned_sys_platform() 12 possible_compiler_list=c_compiler.get(build_platform,c_compiler['default']) 13 return' '.join(possible_compiler_list) 10 14 def configure(conf): 11 try:test_for_compiler=conf.options.check_c_compiler 15 try:test_for_compiler=conf.options.check_c_compiler or default_compilers() 12 16 except AttributeError:conf.fatal("Add options(opt): opt.load('compiler_c')") 13 for compiler in test_for_compiler.split():17 for compiler in re.split('[ ,]+',test_for_compiler): 14 18 conf.env.stash() 15 conf.start_msg('Checking for %r ( ccompiler)'%compiler)19 conf.start_msg('Checking for %r (C compiler)'%compiler) 16 20 try: 17 21 conf.load(compiler) … … 27 31 conf.end_msg(False) 28 32 else: 29 conf.fatal('could not configure a ccompiler!')33 conf.fatal('could not configure a C compiler!') 30 34 def options(opt): 35 test_for_compiler=default_compilers() 31 36 opt.load_special_tools('c_*.py',ban=['c_dumbpreproc.py']) 32 global c_compiler 33 build_platform=Utils.unversioned_sys_platform() 34 possible_compiler_list=c_compiler[build_platform in c_compiler and build_platform or'default'] 35 test_for_compiler=' '.join(possible_compiler_list) 36 cc_compiler_opts=opt.add_option_group("C Compiler Options") 37 cc_compiler_opts.add_option('--check-c-compiler',default="%s"%test_for_compiler,help='On this platform (%s) the following C-Compiler will be checked by default: "%s"'%(build_platform,test_for_compiler),dest="check_c_compiler") 37 cc_compiler_opts=opt.add_option_group('Configuration options') 38 cc_compiler_opts.add_option('--check-c-compiler',default=None,help='list of C compilers to try [%s]'%test_for_compiler,dest="check_c_compiler") 38 39 for x in test_for_compiler.split(): 39 40 opt.load('%s'%x) -
waflib/Tools/compiler_cxx.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os,sys,imp,types 5 import os,sys,imp,types,re 6 6 from waflib.Tools import ccroot 7 7 from waflib import Utils,Configure 8 8 from waflib.Logs import debug 9 cxx_compiler={'win32':['msvc','g++'],'cygwin':['g++'],'darwin':['g++'],'aix':['xlc++','g++'],'linux':['g++','icpc'],'sunos':['sunc++','g++'],'irix':['g++'],'hpux':['g++'],'gnu':['g++'],'java':['g++','msvc','icpc'],'default':['g++']} 9 cxx_compiler={'win32':['msvc','g++','clang++'],'cygwin':['g++'],'darwin':['clang++','g++'],'aix':['xlc++','g++','clang++'],'linux':['g++','clang++','icpc'],'sunos':['sunc++','g++'],'irix':['g++'],'hpux':['g++'],'gnu':['g++','clang++'],'java':['g++','msvc','clang++','icpc'],'default':['g++','clang++']} 10 def default_compilers(): 11 build_platform=Utils.unversioned_sys_platform() 12 possible_compiler_list=cxx_compiler.get(build_platform,cxx_compiler['default']) 13 return' '.join(possible_compiler_list) 10 14 def configure(conf): 11 try:test_for_compiler=conf.options.check_cxx_compiler 15 try:test_for_compiler=conf.options.check_cxx_compiler or default_compilers() 12 16 except AttributeError:conf.fatal("Add options(opt): opt.load('compiler_cxx')") 13 for compiler in test_for_compiler.split():17 for compiler in re.split('[ ,]+',test_for_compiler): 14 18 conf.env.stash() 15 conf.start_msg('Checking for %r ( c++ compiler)'%compiler)19 conf.start_msg('Checking for %r (C++ compiler)'%compiler) 16 20 try: 17 21 conf.load(compiler) … … 27 31 conf.end_msg(False) 28 32 else: 29 conf.fatal('could not configure a c++ compiler!')33 conf.fatal('could not configure a C++ compiler!') 30 34 def options(opt): 35 test_for_compiler=default_compilers() 31 36 opt.load_special_tools('cxx_*.py') 32 global cxx_compiler 33 build_platform=Utils.unversioned_sys_platform() 34 possible_compiler_list=cxx_compiler[build_platform in cxx_compiler and build_platform or'default'] 35 test_for_compiler=' '.join(possible_compiler_list) 36 cxx_compiler_opts=opt.add_option_group('C++ Compiler Options') 37 cxx_compiler_opts.add_option('--check-cxx-compiler',default="%s"%test_for_compiler,help='On this platform (%s) the following C++ Compiler will be checked by default: "%s"'%(build_platform,test_for_compiler),dest="check_cxx_compiler") 37 cxx_compiler_opts=opt.add_option_group('Configuration options') 38 cxx_compiler_opts.add_option('--check-cxx-compiler',default=None,help='list of C++ compilers to try [%s]'%test_for_compiler,dest="check_cxx_compiler") 38 39 for x in test_for_compiler.split(): 39 40 opt.load('%s'%x) -
waflib/Tools/compiler_d.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os,sys,imp,types 5 import os,sys,imp,types,re 6 6 from waflib import Utils,Configure,Options,Logs 7 d_compiler={'default':['gdc','dmd','ldc2']} 8 def default_compilers(): 9 build_platform=Utils.unversioned_sys_platform() 10 possible_compiler_list=d_compiler.get(build_platform,d_compiler['default']) 11 return' '.join(possible_compiler_list) 7 12 def configure(conf): 8 for compiler in conf.options.dcheck.split(','): 13 try:test_for_compiler=conf.options.check_d_compiler or default_compilers() 14 except AttributeError:conf.fatal("Add options(opt): opt.load('compiler_d')") 15 for compiler in re.split('[ ,]+',test_for_compiler): 9 16 conf.env.stash() 10 conf.start_msg('Checking for %r ( dcompiler)'%compiler)17 conf.start_msg('Checking for %r (D compiler)'%compiler) 11 18 try: 12 19 conf.load(compiler) … … 22 29 conf.end_msg(False) 23 30 else: 24 conf.fatal(' no suitable d compiler was found')31 conf.fatal('could not configure a D compiler!') 25 32 def options(opt): 26 d_compiler_opts=opt.add_option_group('D Compiler Options') 27 d_compiler_opts.add_option('--check-d-compiler',default='gdc,dmd,ldc2',action='store',help='check for the compiler [Default:gdc,dmd,ldc2]',dest='dcheck') 28 for d_compiler in['gdc','dmd','ldc2']: 29 opt.load('%s'%d_compiler) 33 test_for_compiler=default_compilers() 34 d_compiler_opts=opt.add_option_group('Configuration options') 35 d_compiler_opts.add_option('--check-d-compiler',default=None,help='list of D compilers to try [%s]'%test_for_compiler,dest='check_d_compiler') 36 for x in test_for_compiler.split(): 37 opt.load('%s'%x) -
waflib/Tools/compiler_fc.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os,sys,imp,types 5 import os,sys,imp,types,re 6 6 from waflib import Utils,Configure,Options,Logs,Errors 7 7 from waflib.Tools import fc 8 8 fc_compiler={'win32':['gfortran','ifort'],'darwin':['gfortran','g95','ifort'],'linux':['gfortran','g95','ifort'],'java':['gfortran','g95','ifort'],'default':['gfortran'],'aix':['gfortran']} 9 def __list_possible_compiler(platform): 10 try: 11 return fc_compiler[platform] 12 except KeyError: 13 return fc_compiler["default"] 9 def default_compilers(): 10 build_platform=Utils.unversioned_sys_platform() 11 possible_compiler_list=fc_compiler.get(build_platform,fc_compiler['default']) 12 return' '.join(possible_compiler_list) 14 13 def configure(conf): 15 try:test_for_compiler=conf.options.check_f c14 try:test_for_compiler=conf.options.check_fortran_compiler or default_compilers() 16 15 except AttributeError:conf.fatal("Add options(opt): opt.load('compiler_fc')") 17 for compiler in test_for_compiler.split():16 for compiler in re.split('[ ,]+',test_for_compiler): 18 17 conf.env.stash() 19 conf.start_msg('Checking for %r ( fortran compiler)'%compiler)18 conf.start_msg('Checking for %r (Fortran compiler)'%compiler) 20 19 try: 21 20 conf.load(compiler) … … 31 30 conf.end_msg(False) 32 31 else: 33 conf.fatal('could not configure a fortran compiler!')32 conf.fatal('could not configure a Fortran compiler!') 34 33 def options(opt): 34 test_for_compiler=default_compilers() 35 35 opt.load_special_tools('fc_*.py') 36 build_platform=Utils.unversioned_sys_platform() 37 detected_platform=Options.platform 38 possible_compiler_list=__list_possible_compiler(detected_platform) 39 test_for_compiler=' '.join(possible_compiler_list) 40 fortran_compiler_opts=opt.add_option_group("Fortran Compiler Options") 41 fortran_compiler_opts.add_option('--check-fortran-compiler',default="%s"%test_for_compiler,help='On this platform (%s) the following Fortran Compiler will be checked by default: "%s"'%(detected_platform,test_for_compiler),dest="check_fc") 42 for compiler in test_for_compiler.split(): 43 opt.load('%s'%compiler) 36 fortran_compiler_opts=opt.add_option_group('Configuration options') 37 fortran_compiler_opts.add_option('--check-fortran-compiler',default=None,help='list of Fortran compiler to try [%s]'%test_for_compiler,dest="check_fortran_compiler") 38 for x in test_for_compiler.split(): 39 opt.load('%s'%x) -
waflib/Tools/cxx.py
r5525507 r904702d 12 12 TaskGen.task_gen.mappings['.c']=TaskGen.task_gen.mappings['.cpp'] 13 13 class cxx(Task.Task): 14 run_str='${CXX} ${ARCH_ST:ARCH} ${CXXFLAGS} ${CPPFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT }'14 run_str='${CXX} ${ARCH_ST:ARCH} ${CXXFLAGS} ${CPPFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT[0].abspath()}' 15 15 vars=['CXXDEPS'] 16 16 ext_in=['.h'] -
waflib/Tools/dmd.py
r5525507 r904702d 9 9 def find_dmd(conf): 10 10 conf.find_program(['dmd','dmd2','ldc'],var='D') 11 out=conf.cmd_and_log( [conf.env.D,'--help'])11 out=conf.cmd_and_log(conf.env.D+['--help']) 12 12 if out.find("D Compiler v")==-1: 13 out=conf.cmd_and_log( [conf.env.D,'-version'])13 out=conf.cmd_and_log(conf.env.D+['-version']) 14 14 if out.find("based on DMD v1.")==-1: 15 15 conf.fatal("detected compiler is not dmd/ldc") … … 41 41 conf.find_dmd() 42 42 if sys.platform=='win32': 43 out=conf.cmd_and_log( [conf.env.D,'--help'])43 out=conf.cmd_and_log(conf.env.D+['--help']) 44 44 if out.find("D Compiler v2.")>-1: 45 45 conf.fatal('dmd2 on Windows is not supported, use gdc or ldc2 instead') -
waflib/Tools/fc.py
r5525507 r904702d 90 90 inst_to='${LIBDIR}' 91 91 class fcprogram_test(fcprogram): 92 def can_retrieve_cache(self):93 return False94 92 def runnable_status(self): 95 93 ret=super(fcprogram_test,self).runnable_status() -
waflib/Tools/fc_config.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import re, shutil,os,sys,string,shlex5 import re,os,sys,shlex 6 6 from waflib.Configure import conf 7 from waflib.TaskGen import feature, after_method,before_method8 from waflib import Build,Utils7 from waflib.TaskGen import feature,before_method 8 from waflib import Utils 9 9 FC_FRAGMENT=' program main\n end program main\n' 10 10 FC_FRAGMENT2=' PROGRAM MAIN\n END\n' … … 116 116 def check_fortran_verbose_flag(self,*k,**kw): 117 117 self.start_msg('fortran link verbose flag') 118 for x in ['-v','--verbose','-verbose','-V']:118 for x in('-v','--verbose','-verbose','-V'): 119 119 try: 120 120 self.check_cc(features='fc fcprogram_test',fragment=FC_FRAGMENT2,compile_filename='test.f',linkflags=[x],mandatory=True) … … 149 149 SPACE_OPTS=re.compile('^-[LRuYz]$') 150 150 NOSPACE_OPTS=re.compile('^-[RL]') 151 def _parse_flink_token(lexer,token,tmp_flags): 152 if _match_ignore(token): 153 pass 154 elif token.startswith('-lkernel32')and sys.platform=='cygwin': 155 tmp_flags.append(token) 156 elif SPACE_OPTS.match(token): 157 t=lexer.get_token() 158 if t.startswith('P,'): 159 t=t[2:] 160 for opt in t.split(os.pathsep): 161 tmp_flags.append('-L%s'%opt) 162 elif NOSPACE_OPTS.match(token): 163 tmp_flags.append(token) 164 elif POSIX_LIB_FLAGS.match(token): 165 tmp_flags.append(token) 166 else: 167 pass 168 t=lexer.get_token() 169 return t 151 170 def _parse_flink_line(line,final_flags): 152 171 lexer=shlex.shlex(line,posix=True) … … 155 174 tmp_flags=[] 156 175 while t: 157 def parse(token): 158 if _match_ignore(token): 159 pass 160 elif token.startswith('-lkernel32')and sys.platform=='cygwin': 161 tmp_flags.append(token) 162 elif SPACE_OPTS.match(token): 163 t=lexer.get_token() 164 if t.startswith('P,'): 165 t=t[2:] 166 for opt in t.split(os.pathsep): 167 tmp_flags.append('-L%s'%opt) 168 elif NOSPACE_OPTS.match(token): 169 tmp_flags.append(token) 170 elif POSIX_LIB_FLAGS.match(token): 171 tmp_flags.append(token) 172 else: 173 pass 174 t=lexer.get_token() 175 return t 176 t=parse(t) 176 t=_parse_flink_token(lexer,t,tmp_flags) 177 177 final_flags.extend(tmp_flags) 178 178 return final_flags … … 241 241 bld(features='c fcprogram',source='main.c',target='app',use='test') 242 242 def mangling_schemes(): 243 for u in ['_','']:244 for du in ['','_']:245 for c in ["lower","upper"]:243 for u in('_',''): 244 for du in('','_'): 245 for c in("lower","upper"): 246 246 yield(u,du,c) 247 247 def mangle_name(u,du,c,name): … … 275 275 @conf 276 276 def detect_openmp(self): 277 for x in ['-fopenmp','-openmp','-mp','-xopenmp','-omp','-qsmp=omp']:277 for x in('-fopenmp','-openmp','-mp','-xopenmp','-omp','-qsmp=omp'): 278 278 try: 279 279 self.check_fc(msg='Checking for OpenMP flag %s'%x,fragment='program main\n call omp_get_num_threads()\nend program main',fcflags=x,linkflags=x,uselib_store='OPENMP') -
waflib/Tools/flex.py
r5525507 r904702d 29 29 conf.find_program('flex',var='FLEX') 30 30 conf.env.FLEXFLAGS=['-t'] 31 if re.search(r"\\msys\\[0-9.]+\\bin\\flex.exe$",conf.env.FLEX ):31 if re.search(r"\\msys\\[0-9.]+\\bin\\flex.exe$",conf.env.FLEX[0]): 32 32 conf.env.FLEX_MSYS=True -
waflib/Tools/g95.py
r5525507 r904702d 10 10 def find_g95(conf): 11 11 fc=conf.find_program('g95',var='FC') 12 fc=conf.cmd_to_list(fc)13 12 conf.get_g95_version(fc) 14 13 conf.env.FC_NAME='G95' -
waflib/Tools/gcc.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os,sys 6 from waflib import Configure,Options,Utils 5 7 from waflib.Tools import ccroot,ar 6 8 from waflib.Configure import conf … … 8 10 def find_gcc(conf): 9 11 cc=conf.find_program(['gcc','cc'],var='CC') 10 cc=conf.cmd_to_list(cc)11 12 conf.get_cc_version(cc,gcc=True) 12 13 conf.env.CC_NAME='gcc' 13 conf.env.CC=cc14 14 @conf 15 15 def gcc_common_flags(conf): -
waflib/Tools/gdc.py
r5525507 r904702d 9 9 def find_gdc(conf): 10 10 conf.find_program('gdc',var='D') 11 out=conf.cmd_and_log( [conf.env.D,'--version'])12 if out.find("gdc 11 out=conf.cmd_and_log(conf.env.D+['--version']) 12 if out.find("gdc")==-1: 13 13 conf.fatal("detected compiler is not gdc") 14 14 @conf -
waflib/Tools/gfortran.py
r5525507 r904702d 10 10 def find_gfortran(conf): 11 11 fc=conf.find_program(['gfortran','g77'],var='FC') 12 fc=conf.cmd_to_list(fc)13 12 conf.get_gfortran_version(fc) 14 13 conf.env.FC_NAME='GFORTRAN' -
waflib/Tools/glib2.py
r5525507 r904702d 4 4 5 5 import os 6 from waflib import Task,Utils,Options,Errors,Logs 7 from waflib.TaskGen import taskgen_method,before_method,after_method,feature 6 from waflib import Context,Task,Utils,Options,Errors,Logs 7 from waflib.TaskGen import taskgen_method,before_method,after_method,feature,extension 8 from waflib.Configure import conf 8 9 @taskgen_method 9 10 def add_marshal_file(self,filename,prefix): … … 99 100 filename_list=[filename_list] 100 101 self.settings_enum_files=filename_list 101 def r_change_ext(self,ext):102 name=self.name103 k=name.rfind('.')104 if k>=0:105 name=name[:k]+ext106 else:107 name=name+ext108 return self.parent.find_or_declare([name])109 102 @feature('glib2') 110 103 def process_settings(self): … … 137 130 schema_task.set_inputs(source_list) 138 131 schema_task.env['GLIB_COMPILE_SCHEMAS_OPTIONS']=[("--schema-file="+k.abspath())for k in source_list] 139 target_node= r_change_ext(schema_node,'.xml.valid')132 target_node=schema_node.change_ext('.xml.valid') 140 133 schema_task.set_outputs(target_node) 141 134 schema_task.env['GLIB_VALIDATE_SCHEMA_OUTPUT']=target_node.abspath() … … 156 149 run_str='rm -f ${GLIB_VALIDATE_SCHEMA_OUTPUT} && ${GLIB_COMPILE_SCHEMAS} --dry-run ${GLIB_COMPILE_SCHEMAS_OPTIONS} && touch ${GLIB_VALIDATE_SCHEMA_OUTPUT}' 157 150 color='PINK' 158 def configure(conf): 151 @extension('.gresource.xml') 152 def process_gresource_source(self,node): 153 if not self.env['GLIB_COMPILE_RESOURCES']: 154 raise Errors.WafError("Unable to process GResource file - glib-compile-resources was not found during configure") 155 if'gresource'in self.features: 156 return 157 h_node=node.change_ext('_xml.h') 158 c_node=node.change_ext('_xml.c') 159 self.create_task('glib_gresource_source',node,[h_node,c_node]) 160 self.source.append(c_node) 161 @feature('gresource') 162 def process_gresource_bundle(self): 163 for i in self.to_list(self.source): 164 node=self.path.find_resource(i) 165 task=self.create_task('glib_gresource_bundle',node,node.change_ext('')) 166 inst_to=getattr(self,'install_path',None) 167 if inst_to: 168 self.bld.install_files(inst_to,task.outputs) 169 class glib_gresource_base(Task.Task): 170 color='BLUE' 171 base_cmd='${GLIB_COMPILE_RESOURCES} --sourcedir=${SRC[0].parent.srcpath()} --sourcedir=${SRC[0].bld_dir()}' 172 def scan(self): 173 bld=self.generator.bld 174 kw={} 175 try: 176 if not kw.get('cwd',None): 177 kw['cwd']=bld.cwd 178 except AttributeError: 179 bld.cwd=kw['cwd']=bld.variant_dir 180 kw['quiet']=Context.BOTH 181 cmd=Utils.subst_vars('${GLIB_COMPILE_RESOURCES} --sourcedir=%s --sourcedir=%s --generate-dependencies %s'%(self.inputs[0].parent.srcpath(),self.inputs[0].bld_dir(),self.inputs[0].bldpath()),self.env) 182 output=bld.cmd_and_log(cmd,**kw) 183 nodes=[] 184 names=[] 185 for dep in output.splitlines(): 186 if dep: 187 node=bld.bldnode.find_node(dep) 188 if node: 189 nodes.append(node) 190 else: 191 names.append(dep) 192 return(nodes,names) 193 class glib_gresource_source(glib_gresource_base): 194 vars=['GLIB_COMPILE_RESOURCES'] 195 fun_h=Task.compile_fun_shell(glib_gresource_base.base_cmd+' --target=${TGT[0].abspath()} --generate-header ${SRC}') 196 fun_c=Task.compile_fun_shell(glib_gresource_base.base_cmd+' --target=${TGT[1].abspath()} --generate-source ${SRC}') 197 ext_out=['.h'] 198 def run(self): 199 return self.fun_h[0](self)or self.fun_c[0](self) 200 class glib_gresource_bundle(glib_gresource_base): 201 run_str=glib_gresource_base.base_cmd+' --target=${TGT} ${SRC}' 202 shell=True 203 @conf 204 def find_glib_genmarshal(conf): 159 205 conf.find_program('glib-genmarshal',var='GLIB_GENMARSHAL') 160 conf.find_perl_program('glib-mkenums',var='GLIB_MKENUMS') 161 conf.find_program('glib-compile-schemas',var='GLIB_COMPILE_SCHEMAS',mandatory=False) 206 @conf 207 def find_glib_mkenums(conf): 208 if not conf.env.PERL: 209 conf.find_program('perl',var='PERL') 210 conf.find_program('glib-mkenums',interpreter='PERL',var='GLIB_MKENUMS') 211 @conf 212 def find_glib_compile_schemas(conf): 213 conf.find_program('glib-compile-schemas',var='GLIB_COMPILE_SCHEMAS') 162 214 def getstr(varname): 163 215 return getattr(Options.options,varname,getattr(conf.env,varname,'')) … … 170 222 gsettingsschemadir=os.path.join(datadir,'glib-2.0','schemas') 171 223 conf.env['GSETTINGSSCHEMADIR']=gsettingsschemadir 224 @conf 225 def find_glib_compile_resources(conf): 226 conf.find_program('glib-compile-resources',var='GLIB_COMPILE_RESOURCES') 227 def configure(conf): 228 conf.find_glib_genmarshal() 229 conf.find_glib_mkenums() 230 conf.find_glib_compile_schemas(mandatory=False) 231 conf.find_glib_compile_resources(mandatory=False) 172 232 def options(opt): 173 opt.add_option('--gsettingsschemadir',help='GSettings schema location [Default: ${datadir}/glib-2.0/schemas]',default='',dest='GSETTINGSSCHEMADIR') 233 gr=opt.add_option_group('Installation directories') 234 gr.add_option('--gsettingsschemadir',help='GSettings schema location [DATADIR/glib-2.0/schemas]',default='',dest='GSETTINGSSCHEMADIR') -
waflib/Tools/gnu_dirs.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os 5 import os,re 6 6 from waflib import Utils,Options,Context 7 _options=[x.split(', ')for x in'''8 bindir, user executables, ${EXEC_PREFIX}/bin9 sbindir, system admin executables, ${EXEC_PREFIX}/sbin10 libexecdir, program executables, ${EXEC_PREFIX}/libexec11 sysconfdir, read-only single-machine data, ${PREFIX}/etc12 sharedstatedir, modifiable architecture-independentdata, ${PREFIX}/com13 localstatedir, modifiable single-machine data, ${PREFIX}/var14 libdir, object code libraries, ${EXEC_PREFIX}/lib 15 includedir, Cheader files, ${PREFIX}/include16 oldincludedir, C header files for non-gcc, /usr/include17 datarootdir, read-only arch.-independent data root, ${PREFIX}/share18 datadir, read-onlyarchitecture-independent data, ${DATAROOTDIR}19 infodir, infodocumentation, ${DATAROOTDIR}/info7 gnuopts=''' 8 bindir, user commands, ${EXEC_PREFIX}/bin 9 sbindir, system binaries, ${EXEC_PREFIX}/sbin 10 libexecdir, program-specific binaries, ${EXEC_PREFIX}/libexec 11 sysconfdir, host-specific configuration, ${PREFIX}/etc 12 sharedstatedir, architecture-independent variable data, ${PREFIX}/com 13 localstatedir, variable data, ${PREFIX}/var 14 libdir, object code libraries, ${EXEC_PREFIX}/lib%s 15 includedir, header files, ${PREFIX}/include 16 oldincludedir, header files for non-GCC compilers, /usr/include 17 datarootdir, architecture-independent data root, ${PREFIX}/share 18 datadir, architecture-independent data, ${DATAROOTDIR} 19 infodir, GNU "info" documentation, ${DATAROOTDIR}/info 20 20 localedir, locale-dependent data, ${DATAROOTDIR}/locale 21 mandir, man documentation, ${DATAROOTDIR}/man21 mandir, manual pages, ${DATAROOTDIR}/man 22 22 docdir, documentation root, ${DATAROOTDIR}/doc/${PACKAGE} 23 htmldir, html documentation, ${DOCDIR} 24 dvidir, dvi documentation, ${DOCDIR} 25 pdfdir, pdf documentation, ${DOCDIR} 26 psdir, ps documentation, ${DOCDIR} 27 '''.split('\n')if x] 23 htmldir, HTML documentation, ${DOCDIR} 24 dvidir, DVI documentation, ${DOCDIR} 25 pdfdir, PDF documentation, ${DOCDIR} 26 psdir, PostScript documentation, ${DOCDIR} 27 '''%Utils.lib64() 28 _options=[x.split(', ')for x in gnuopts.splitlines()if x] 28 29 def configure(conf): 29 30 def get_param(varname,default): … … 46 47 complete=False 47 48 if not complete: 48 lst=[ name for name,_,_ in _options if not env[name.upper()]]49 lst=[x for x,_,_ in _options if not env[x.upper()]] 49 50 raise conf.errors.WafError('Variable substitution failure %r'%lst) 50 51 def options(opt): 51 inst_dir=opt.add_option_group('Installation directories','By default, "waf install" will put the files in\52 inst_dir=opt.add_option_group('Installation prefix','By default, "waf install" will put the files in\ 52 53 "/usr/local/bin", "/usr/local/lib" etc. An installation prefix other\ 53 54 than "/usr/local" can be given using "--prefix", for example "--prefix=$HOME"') … … 57 58 opt.parser.remove_option(k) 58 59 inst_dir.add_option(option) 59 inst_dir.add_option('--exec-prefix',help='installation prefix [Default: ${PREFIX}]',default='',dest='EXEC_PREFIX')60 dirs_options=opt.add_option_group(' Pre-defined installation directories','')60 inst_dir.add_option('--exec-prefix',help='installation prefix for binaries [PREFIX]',default='',dest='EXEC_PREFIX') 61 dirs_options=opt.add_option_group('Installation directories') 61 62 for name,help,default in _options: 62 63 option_name='--'+name 63 64 str_default=default 64 str_help='%s [ Default: %s]'%(help,str_default)65 str_help='%s [%s]'%(help,re.sub(r'\$\{([^}]+)\}',r'\1',str_default)) 65 66 dirs_options.add_option(option_name,help=str_help,default='',dest=name.upper()) -
waflib/Tools/gxx.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os,sys 6 from waflib import Configure,Options,Utils 5 7 from waflib.Tools import ccroot,ar 6 8 from waflib.Configure import conf … … 8 10 def find_gxx(conf): 9 11 cxx=conf.find_program(['g++','c++'],var='CXX') 10 cxx=conf.cmd_to_list(cxx)11 12 conf.get_cc_version(cxx,gcc=True) 12 13 conf.env.CXX_NAME='gcc' 13 conf.env.CXX=cxx14 14 @conf 15 15 def gxx_common_flags(conf): -
waflib/Tools/icc.py
r5525507 r904702d 10 10 if sys.platform=='cygwin': 11 11 conf.fatal('The Intel compiler does not work on Cygwin') 12 v=conf.env 13 cc=None 14 if v['CC']:cc=v['CC'] 15 elif'CC'in conf.environ:cc=conf.environ['CC'] 16 if not cc:cc=conf.find_program('icc',var='CC') 17 if not cc:cc=conf.find_program('ICL',var='CC') 18 if not cc:conf.fatal('Intel C Compiler (icc) was not found') 19 cc=conf.cmd_to_list(cc) 12 cc=conf.find_program(['icc','ICL'],var='CC') 20 13 conf.get_cc_version(cc,icc=True) 21 v['CC']=cc 22 v['CC_NAME']='icc' 14 conf.env.CC_NAME='icc' 23 15 def configure(conf): 24 16 conf.find_icc() -
waflib/Tools/icpc.py
r5525507 r904702d 10 10 if sys.platform=='cygwin': 11 11 conf.fatal('The Intel compiler does not work on Cygwin') 12 v=conf.env 13 cxx=None 14 if v['CXX']:cxx=v['CXX'] 15 elif'CXX'in conf.environ:cxx=conf.environ['CXX'] 16 if not cxx:cxx=conf.find_program('icpc',var='CXX') 17 if not cxx:conf.fatal('Intel C++ Compiler (icpc) was not found') 18 cxx=conf.cmd_to_list(cxx) 12 cxx=conf.find_program('icpc',var='CXX') 19 13 conf.get_cc_version(cxx,icc=True) 20 v['CXX']=cxx 21 v['CXX_NAME']='icc' 14 conf.env.CXX_NAME='icc' 22 15 def configure(conf): 23 16 conf.find_icpc() -
waflib/Tools/ifort.py
r5525507 r904702d 10 10 def find_ifort(conf): 11 11 fc=conf.find_program('ifort',var='FC') 12 fc=conf.cmd_to_list(fc)13 12 conf.get_ifort_version(fc) 14 13 conf.env.FC_NAME='IFORT' … … 30 29 @conf 31 30 def get_ifort_version(conf,fc): 32 version_re=re.compile(r"ifort\s*\(IFORT\)\s*(?P<major>\d*)\.(?P<minor>\d*)",re.I).search 33 cmd=fc+['--version'] 31 version_re=re.compile(r"Intel[\sa-zA-Z()0-9,-]*Version\s*(?P<major>\d*)\.(?P<minor>\d*)",re.I).search 32 if Utils.is_win32: 33 cmd=fc 34 else: 35 cmd=fc+['-logo'] 34 36 out,err=fc_config.getoutput(conf,cmd,stdin=False) 35 37 if out: -
waflib/Tools/intltool.py
r5525507 r904702d 4 4 5 5 import os,re 6 from waflib import Configure, TaskGen,Task,Utils,Runner,Options,Build,Logs6 from waflib import Configure,Context,TaskGen,Task,Utils,Runner,Options,Build,Logs 7 7 import waflib.Tools.ccroot 8 from waflib.TaskGen import feature,before_method 8 from waflib.TaskGen import feature,before_method,taskgen_method 9 9 from waflib.Logs import error 10 from waflib.Configure import conf 11 _style_flags={'ba':'-b','desktop':'-d','keys':'-k','quoted':'--quoted-style','quotedxml':'--quotedxml-style','rfc822deb':'-r','schemas':'-s','xml':'-x',} 12 @taskgen_method 13 def ensure_localedir(self): 14 if not self.env.LOCALEDIR: 15 if self.env.DATAROOTDIR: 16 self.env.LOCALEDIR=os.path.join(self.env.DATAROOTDIR,'locale') 17 else: 18 self.env.LOCALEDIR=os.path.join(self.env.PREFIX,'share','locale') 10 19 @before_method('process_source') 11 20 @feature('intltool_in') … … 13 22 try:self.meths.remove('process_source') 14 23 except ValueError:pass 15 if not self.env.LOCALEDIR: 16 self.env.LOCALEDIR=self.env.PREFIX+'/share/locale' 24 self.ensure_localedir() 25 podir=getattr(self,'podir','.') 26 podirnode=self.path.find_dir(podir) 27 if not podirnode: 28 error("could not find the podir %r"%podir) 29 return 30 cache=getattr(self,'intlcache','.intlcache') 31 self.env.INTLCACHE=[os.path.join(str(self.path.get_bld()),podir,cache)] 32 self.env.INTLPODIR=podirnode.bldpath() 33 self.env.append_value('INTLFLAGS',getattr(self,'flags',self.env.INTLFLAGS_DEFAULT)) 34 if'-c'in self.env.INTLFLAGS: 35 self.bld.fatal('Redundant -c flag in intltool task %r'%self) 36 style=getattr(self,'style',None) 37 if style: 38 try: 39 style_flag=_style_flags[style] 40 except KeyError: 41 self.bld.fatal('intltool_in style "%s" is not valid'%style) 42 self.env.append_unique('INTLFLAGS',[style_flag]) 17 43 for i in self.to_list(self.source): 18 44 node=self.path.find_resource(i) 19 podir=getattr(self,'podir','po')20 podirnode=self.path.find_dir(podir)21 if not podirnode:22 error("could not find the podir %r"%podir)23 continue24 cache=getattr(self,'intlcache','.intlcache')25 self.env['INTLCACHE']=os.path.join(self.path.bldpath(),podir,cache)26 self.env['INTLPODIR']=podirnode.bldpath()27 self.env['INTLFLAGS']=getattr(self,'flags',['-q','-u','-c'])28 45 task=self.create_task('intltool',node,node.change_ext('')) 29 inst=getattr(self,'install_path', '${LOCALEDIR}')46 inst=getattr(self,'install_path',None) 30 47 if inst: 31 48 self.bld.install_files(inst,task.outputs) … … 34 51 try:self.meths.remove('process_source') 35 52 except ValueError:pass 36 if not self.env.LOCALEDIR: 37 self.env.LOCALEDIR=self.env.PREFIX+'/share/locale' 38 appname=getattr(self,'appname','set_your_app_name') 39 podir=getattr(self,'podir','') 53 self.ensure_localedir() 54 appname=getattr(self,'appname',getattr(Context.g_module,Context.APPNAME,'set_your_app_name')) 55 podir=getattr(self,'podir','.') 40 56 inst=getattr(self,'install_path','${LOCALEDIR}') 41 57 linguas=self.path.find_node(os.path.join(podir,'LINGUAS')) … … 63 79 color='BLUE' 64 80 class intltool(Task.Task): 65 run_str='${INTLTOOL} ${INTLFLAGS} ${INTLCACHE } ${INTLPODIR} ${SRC} ${TGT}'81 run_str='${INTLTOOL} ${INTLFLAGS} ${INTLCACHE_ST:INTLCACHE} ${INTLPODIR} ${SRC} ${TGT}' 66 82 color='BLUE' 83 @conf 84 def find_msgfmt(conf): 85 conf.find_program('msgfmt',var='MSGFMT') 86 @conf 87 def find_intltool_merge(conf): 88 if not conf.env.PERL: 89 conf.find_program('perl',var='PERL') 90 conf.env.INTLCACHE_ST='--cache=%s' 91 conf.env.INTLFLAGS_DEFAULT=['-q','-u'] 92 conf.find_program('intltool-merge',interpreter='PERL',var='INTLTOOL') 67 93 def configure(conf): 68 conf.find_program('msgfmt',var='MSGFMT') 69 conf.find_perl_program('intltool-merge',var='INTLTOOL') 70 prefix=conf.env.PREFIX 71 datadir=conf.env.DATADIR 72 if not datadir: 73 datadir=os.path.join(prefix,'share') 74 conf.define('LOCALEDIR',os.path.join(datadir,'locale').replace('\\','\\\\')) 75 conf.define('DATADIR',datadir.replace('\\','\\\\')) 94 conf.find_msgfmt() 95 conf.find_intltool_merge() 76 96 if conf.env.CC or conf.env.CXX: 77 97 conf.check(header_name='locale.h') -
waflib/Tools/irixcc.py
r5525507 r904702d 15 15 if not cc:cc=conf.find_program('cc',var='CC') 16 16 if not cc:conf.fatal('irixcc was not found') 17 cc=conf.cmd_to_list(cc)18 17 try: 19 18 conf.cmd_and_log(cc+['-version']) -
waflib/Tools/javaw.py
r5525507 r904702d 158 158 class javac(Task.Task): 159 159 color='BLUE' 160 nocache=True161 160 vars=['CLASSPATH','JAVACFLAGS','JAVAC','OUTDIR'] 162 161 def runnable_status(self): … … 254 253 for x in'javac java jar javadoc'.split(): 255 254 self.find_program(x,var=x.upper(),path_list=java_path) 256 self.env[x.upper()]=self.cmd_to_list(self.env[x.upper()])257 255 if'CLASSPATH'in self.environ: 258 256 v['CLASSPATH']=self.environ['CLASSPATH'] -
waflib/Tools/kde4.py
r5525507 r904702d 20 20 def configure(self): 21 21 kdeconfig=self.find_program('kde4-config') 22 prefix=self.cmd_and_log( '%s --prefix'%kdeconfig).strip()22 prefix=self.cmd_and_log(kdeconfig+['--prefix']).strip() 23 23 fname='%s/share/apps/cmake/modules/KDELibsDependencies.cmake'%prefix 24 24 try:os.stat(fname) … … 29 29 try: 30 30 txt=Utils.readf(fname) 31 except (OSError,IOError):31 except EnvironmentError: 32 32 self.fatal('could not read %s'%fname) 33 33 txt=txt.replace('\\\n','\n') -
waflib/Tools/ldc2.py
r5525507 r904702d 9 9 def find_ldc2(conf): 10 10 conf.find_program(['ldc2'],var='D') 11 out=conf.cmd_and_log( [conf.env.D,'-version'])11 out=conf.cmd_and_log(conf.env.D+['-version']) 12 12 if out.find("based on DMD v2.")==-1: 13 13 conf.fatal("detected compiler is not ldc2") -
waflib/Tools/msvc.py
r5525507 r904702d 60 60 def get_msvc_version(conf,compiler,version,target,vcvars): 61 61 debug('msvc: get_msvc_version: %r %r %r',compiler,version,target) 62 batfile=conf.bldnode.make_node('waf-print-msvc.bat') 62 try: 63 conf.msvc_cnt+=1 64 except AttributeError: 65 conf.msvc_cnt=1 66 batfile=conf.bldnode.make_node('waf-print-msvc-%d.bat'%conf.msvc_cnt) 63 67 batfile.write("""@echo off 64 68 set INCLUDE= … … 69 73 echo LIB=%%LIB%%;%%LIBPATH%% 70 74 """%(vcvars,target)) 71 sout=conf.cmd_and_log(['cmd ','/E:on','/V:on','/C',batfile.abspath()])75 sout=conf.cmd_and_log(['cmd.exe','/E:on','/V:on','/C',batfile.abspath()]) 72 76 lines=sout.splitlines() 73 77 if not lines[0]: … … 88 92 compiler_name,linker_name,lib_name=_get_prog_names(conf,compiler) 89 93 cxx=conf.find_program(compiler_name,path_list=MSVC_PATH) 90 cxx=conf.cmd_to_list(cxx)91 94 if'CL'in env: 92 95 del(env['CL']) … … 176 179 version_pattern=re.compile('^(\d\d?\.\d\d?)(Exp)?$') 177 180 detected_versions=[] 178 for vcver,vcvar in [('VCExpress','Exp'),('VisualStudio','')]:181 for vcver,vcvar in(('VCExpress','Exp'),('VisualStudio','')): 179 182 try: 180 183 prefix='SOFTWARE\\Wow6432node\\Microsoft\\'+vcver … … 373 376 patch_url='http://software.intel.com/en-us/forums/topic/328487' 374 377 compilervars_arch=os.path.join(path,'bin','compilervars_arch.bat') 375 for vscomntool in ['VS110COMNTOOLS','VS100COMNTOOLS']:378 for vscomntool in('VS110COMNTOOLS','VS100COMNTOOLS'): 376 379 if vscomntool in os.environ: 377 380 vs_express_path=os.environ[vscomntool]+r'..\IDE\VSWinExpress.exe' … … 529 532 elif'CXX'in conf.environ:cxx=conf.environ['CXX'] 530 533 cxx=conf.find_program(compiler_name,var='CXX',path_list=path) 531 cxx=conf.cmd_to_list(cxx)532 534 env=dict(conf.environ) 533 535 if path:env.update(PATH=';'.join(path)) … … 619 621 pdbnode=self.link_task.outputs[0].change_ext('.pdb') 620 622 self.link_task.outputs.append(pdbnode) 621 try: 622 self.install_task.source.append(pdbnode) 623 except AttributeError: 624 pass 623 if getattr(self,'install_task',None): 624 self.pdb_install_task=self.bld.install_files(self.install_task.dest,pdbnode,env=self.env) 625 625 break 626 626 @feature('cprogram','cshlib','cxxprogram','cxxshlib') … … 652 652 mode='2' 653 653 debug('msvc: embedding manifest in mode %r'%mode) 654 lst=[] 655 lst.append(env['MT']) 654 lst=[]+mtool 656 655 lst.extend(Utils.to_list(env['MTFLAGS'])) 657 656 lst.extend(['-manifest',manifest]) 658 657 lst.append('-outputresource:%s;%s'%(outfile,mode)) 659 lst=[lst] 660 return self.exec_command(*lst) 658 return self.exec_command(lst) 661 659 def quote_response_command(self,flag): 662 660 if flag.find(' ')>-1: … … 726 724 derived_class.exec_command_msvc=exec_command_msvc 727 725 derived_class.exec_mf=exec_mf 726 if hasattr(cls,'hcode'): 727 derived_class.hcode=cls.hcode 728 728 return derived_class 729 729 for k in'c cxx cprogram cxxprogram cshlib cxxshlib cstlib cxxstlib'.split(): -
waflib/Tools/perl.py
r5525507 r904702d 37 37 return False 38 38 self.env['PERL']=perl 39 version=self.cmd_and_log( [perl,"-e",'printf \"%vd\", $^V'])39 version=self.cmd_and_log(self.env.PERL+["-e",'printf \"%vd\", $^V']) 40 40 if not version: 41 41 res=False … … 49 49 @conf 50 50 def check_perl_module(self,module): 51 cmd= [self.env['PERL'],'-e','use %s'%module]51 cmd=self.env.PERL+['-e','use %s'%module] 52 52 self.start_msg('perl module %s'%module) 53 53 try: … … 64 64 if not perl: 65 65 self.fatal('find perl first') 66 def read_out(cmd): 67 return Utils.to_list(self.cmd_and_log(perl+cmd)) 68 env['LINKFLAGS_PERLEXT']=read_out(" -MConfig -e'print $Config{lddlflags}'") 69 env['INCLUDES_PERLEXT']=read_out(" -MConfig -e'print \"$Config{archlib}/CORE\"'") 70 env['CFLAGS_PERLEXT']=read_out(" -MConfig -e'print \"$Config{ccflags} $Config{cccdlflags}\"'") 71 env['XSUBPP']=read_out(" -MConfig -e'print \"$Config{privlib}/ExtUtils/xsubpp$Config{exe_ext}\"'") 72 env['EXTUTILS_TYPEMAP']=read_out(" -MConfig -e'print \"$Config{privlib}/ExtUtils/typemap\"'") 66 def cmd_perl_config(s): 67 return perl+['-MConfig','-e','print \"%s\"'%s] 68 def cfg_str(cfg): 69 return self.cmd_and_log(cmd_perl_config(cfg)) 70 def cfg_lst(cfg): 71 return Utils.to_list(cfg_str(cfg)) 72 env['LINKFLAGS_PERLEXT']=cfg_lst('$Config{lddlflags}') 73 env['INCLUDES_PERLEXT']=cfg_lst('$Config{archlib}/CORE') 74 env['CFLAGS_PERLEXT']=cfg_lst('$Config{ccflags} $Config{cccdlflags}') 75 env['XSUBPP']=cfg_lst('$Config{privlib}/ExtUtils/xsubpp$Config{exe_ext}') 76 env['EXTUTILS_TYPEMAP']=cfg_lst('$Config{privlib}/ExtUtils/typemap') 73 77 if not getattr(Options.options,'perlarchdir',None): 74 env['ARCHDIR_PERL']= self.cmd_and_log(perl+" -MConfig -e'print $Config{sitearch}'")78 env['ARCHDIR_PERL']=cfg_str('$Config{sitearch}') 75 79 else: 76 80 env['ARCHDIR_PERL']=getattr(Options.options,'perlarchdir') 77 env['perlext_PATTERN']='%s.'+ self.cmd_and_log(perl+" -MConfig -e'print $Config{dlext}'")81 env['perlext_PATTERN']='%s.'+cfg_str('$Config{dlext}') 78 82 def options(opt): 79 83 opt.add_option('--with-perl-binary',type='string',dest='perlbinary',help='Specify alternate perl binary',default=None) -
waflib/Tools/python.py
r5525507 r904702d 4 4 5 5 import os,sys 6 from waflib import Utils,Options,Errors,Logs 6 from waflib import Utils,Options,Errors,Logs,Task,Node 7 7 from waflib.TaskGen import extension,before_method,after_method,feature 8 8 from waflib.Configure import conf … … 27 27 INST=''' 28 28 import sys, py_compile 29 py_compile.compile(sys.argv[1], sys.argv[2], sys.argv[3] )29 py_compile.compile(sys.argv[1], sys.argv[2], sys.argv[3], True) 30 30 ''' 31 31 DISTUTILS_IMP=['from distutils.sysconfig import get_config_var, get_python_lib'] 32 @before_method('process_source') 33 @feature('py') 34 def feature_py(self): 35 self.install_path=getattr(self,'install_path','${PYTHONDIR}') 36 install_from=getattr(self,'install_from',None) 37 if install_from and not isinstance(install_from,Node.Node): 38 install_from=self.path.find_dir(install_from) 39 self.install_from=install_from 40 ver=self.env.PYTHON_VERSION 41 if not ver: 42 self.bld.fatal('Installing python files requires PYTHON_VERSION, try conf.check_python_version') 43 if int(ver.replace('.',''))>31: 44 self.install_32=True 32 45 @extension('.py') 33 46 def process_py(self,node): 34 try: 35 if not self.bld.is_install: 36 return 37 except AttributeError: 38 return 39 try: 40 if not self.install_path: 41 return 42 except AttributeError: 43 self.install_path='${PYTHONDIR}' 44 def inst_py(ctx): 45 install_from=getattr(self,'install_from',None) 46 if install_from: 47 install_from=self.path.find_dir(install_from) 48 install_pyfile(self,node,install_from) 49 self.bld.add_post_fun(inst_py) 50 def install_pyfile(self,node,install_from=None): 51 from_node=install_from or node.parent 52 tsk=self.bld.install_as(self.install_path+'/'+node.path_from(from_node),node,postpone=False) 53 path=tsk.get_install_path() 54 if self.bld.is_install<0: 55 Logs.info("+ removing byte compiled python files") 56 for x in'co': 57 try: 58 os.remove(path+x) 59 except OSError: 60 pass 61 if self.bld.is_install>0: 62 try: 63 st1=os.stat(path) 64 except OSError: 65 Logs.error('The python file is missing, this should not happen') 66 for x in['c','o']: 67 do_inst=self.env['PY'+x.upper()] 68 try: 69 st2=os.stat(path+x) 70 except OSError: 71 pass 72 else: 73 if st1.st_mtime<=st2.st_mtime: 74 do_inst=False 75 if do_inst: 76 lst=(x=='o')and[self.env['PYFLAGS_OPT']]or[] 77 (a,b,c)=(path,path+x,tsk.get_install_path(destdir=False)+x) 78 argv=self.env['PYTHON']+lst+['-c',INST,a,b,c] 79 Logs.info('+ byte compiling %r'%(path+x)) 80 env=self.env.env or None 81 ret=Utils.subprocess.Popen(argv,env=env).wait() 82 if ret: 83 raise Errors.WafError('py%s compilation failed %r'%(x,path)) 84 @feature('py') 85 def feature_py(self): 86 pass 47 assert(node.get_bld_sig()) 48 assert(getattr(self,'install_path')),'add features="py"' 49 if self.install_path: 50 if self.install_from: 51 self.bld.install_files(self.install_path,[node],cwd=self.install_from,relative_trick=True) 52 else: 53 self.bld.install_files(self.install_path,[node],relative_trick=True) 54 lst=[] 55 if self.env.PYC: 56 lst.append('pyc') 57 if self.env.PYO: 58 lst.append('pyo') 59 if self.install_path: 60 if self.install_from: 61 pyd=Utils.subst_vars("%s/%s"%(self.install_path,node.path_from(self.install_from)),self.env) 62 else: 63 pyd=Utils.subst_vars("%s/%s"%(self.install_path,node.path_from(self.path)),self.env) 64 else: 65 pyd=node.abspath() 66 for ext in lst: 67 if self.env.PYTAG: 68 name=node.name[:-3] 69 pyobj=node.parent.get_bld().make_node('__pycache__').make_node("%s.%s.%s"%(name,self.env.PYTAG,ext)) 70 pyobj.parent.mkdir() 71 else: 72 pyobj=node.change_ext(".%s"%ext) 73 tsk=self.create_task(ext,node,pyobj) 74 tsk.pyd=pyd 75 if self.install_path: 76 self.bld.install_files(os.path.dirname(pyd),pyobj,cwd=node.parent.get_bld(),relative_trick=True) 77 class pyc(Task.Task): 78 color='PINK' 79 def run(self): 80 cmd=[Utils.subst_vars('${PYTHON}',self.env),'-c',INST,self.inputs[0].abspath(),self.outputs[0].abspath(),self.pyd] 81 ret=self.generator.bld.exec_command(cmd) 82 return ret 83 class pyo(Task.Task): 84 color='PINK' 85 def run(self): 86 cmd=[Utils.subst_vars('${PYTHON}',self.env),Utils.subst_vars('${PYFLAGS_OPT}',self.env),'-c',INST,self.inputs[0].abspath(),self.outputs[0].abspath(),self.pyd] 87 ret=self.generator.bld.exec_command(cmd) 88 return ret 87 89 @feature('pyext') 88 90 @before_method('propagate_uselib_vars','apply_link') … … 132 134 self.to_log(out) 133 135 return_values=[] 134 for s in out.split ('\n'):136 for s in out.splitlines(): 135 137 s=s.strip() 136 138 if not s: … … 145 147 return return_values 146 148 @conf 147 def check_python_headers(conf): 149 def python_cross_compile(self,features='pyembed pyext'): 150 features=Utils.to_list(features) 151 if not('PYTHON_LDFLAGS'in self.environ or'PYTHON_PYEXT_LDFLAGS'in self.environ or'PYTHON_PYEMBED_LDFLAGS'in self.environ): 152 return False 153 for x in'PYTHON_VERSION PYTAG pyext_PATTERN'.split(): 154 if not x in self.environ: 155 self.fatal('Please set %s in the os environment'%x) 156 else: 157 self.env[x]=self.environ[x] 158 xx=self.env.CXX_NAME and'cxx'or'c' 159 if'pyext'in features: 160 flags=self.environ.get('PYTHON_PYEXT_LDFLAGS',self.environ.get('PYTHON_LDFLAGS',None)) 161 if flags is None: 162 self.fatal('No flags provided through PYTHON_PYEXT_LDFLAGS as required') 163 else: 164 self.parse_flags(flags,'PYEXT') 165 self.check(header_name='Python.h',define_name='HAVE_PYEXT',msg='Testing pyext configuration',features='%s %sshlib pyext'%(xx,xx),fragment=FRAG,errmsg='Could not build python extensions') 166 if'pyembed'in features: 167 flags=self.environ.get('PYTHON_PYEMBED_LDFLAGS',self.environ.get('PYTHON_LDFLAGS',None)) 168 if flags is None: 169 self.fatal('No flags provided through PYTHON_PYEMBED_LDFLAGS as required') 170 else: 171 self.parse_flags(flags,'PYEMBED') 172 self.check(header_name='Python.h',define_name='HAVE_PYEMBED',msg='Testing pyembed configuration',fragment=FRAG,errmsg='Could not build a python embedded interpreter',features='%s %sprogram pyembed'%(xx,xx)) 173 return True 174 @conf 175 def check_python_headers(conf,features='pyembed pyext'): 176 features=Utils.to_list(features) 177 assert('pyembed'in features)or('pyext'in features),"check_python_headers features must include 'pyembed' and/or 'pyext'" 148 178 env=conf.env 149 179 if not env['CC_NAME']and not env['CXX_NAME']: 150 180 conf.fatal('load a compiler first (gcc, g++, ..)') 181 if conf.python_cross_compile(features): 182 return 151 183 if not env['PYTHON_VERSION']: 152 184 conf.check_python_version() 153 pybin= conf.env.PYTHON185 pybin=env.PYTHON 154 186 if not pybin: 155 187 conf.fatal('Could not find the python executable') 156 v='prefix SO LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS '.split()188 v='prefix SO LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS LDVERSION'.split() 157 189 try: 158 190 lst=conf.get_python_variables(["get_config_var('%s') or ''"%x for x in v]) … … 160 192 conf.fatal("Python development headers not found (-v for details).") 161 193 vals=['%s = %r'%(x,y)for(x,y)in zip(v,lst)] 162 conf.to_log("Configuration returned from %r:\n% r\n"%(pybin,'\n'.join(vals)))194 conf.to_log("Configuration returned from %r:\n%s\n"%(pybin,'\n'.join(vals))) 163 195 dct=dict(zip(v,lst)) 164 196 x='MACOSX_DEPLOYMENT_TARGET' 165 197 if dct[x]: 166 conf.env[x]=conf.environ[x]=dct[x]198 env[x]=conf.environ[x]=dct[x] 167 199 env['pyext_PATTERN']='%s'+dct['SO'] 200 num='.'.join(env['PYTHON_VERSION'].split('.')[:2]) 201 conf.find_program([''.join(pybin)+'-config','python%s-config'%num,'python-config-%s'%num,'python%sm-config'%num],var='PYTHON_CONFIG',msg="python-config",mandatory=False) 202 if env.PYTHON_CONFIG: 203 all_flags=[['--cflags','--libs','--ldflags']] 204 if sys.hexversion<0x2070000: 205 all_flags=[[k]for k in all_flags[0]] 206 xx=env.CXX_NAME and'cxx'or'c' 207 if'pyembed'in features: 208 for flags in all_flags: 209 conf.check_cfg(msg='Asking python-config for pyembed %r flags'%' '.join(flags),path=env.PYTHON_CONFIG,package='',uselib_store='PYEMBED',args=flags) 210 conf.check(header_name='Python.h',define_name='HAVE_PYEMBED',msg='Getting pyembed flags from python-config',fragment=FRAG,errmsg='Could not build a python embedded interpreter',features='%s %sprogram pyembed'%(xx,xx)) 211 if'pyext'in features: 212 for flags in all_flags: 213 conf.check_cfg(msg='Asking python-config for pyext %r flags'%' '.join(flags),path=env.PYTHON_CONFIG,package='',uselib_store='PYEXT',args=flags) 214 conf.check(header_name='Python.h',define_name='HAVE_PYEXT',msg='Getting pyext flags from python-config',features='%s %sshlib pyext'%(xx,xx),fragment=FRAG,errmsg='Could not build python extensions') 215 conf.define('HAVE_PYTHON_H',1) 216 return 168 217 all_flags=dct['LDFLAGS']+' '+dct['CFLAGS'] 169 218 conf.parse_flags(all_flags,'PYEMBED') … … 171 220 conf.parse_flags(all_flags,'PYEXT') 172 221 result=None 173 for name in('python'+env['PYTHON_VERSION'],'python'+env['PYTHON_VERSION']+'m','python'+env['PYTHON_VERSION'].replace('.','')): 222 if not dct["LDVERSION"]: 223 dct["LDVERSION"]=env['PYTHON_VERSION'] 224 for name in('python'+dct['LDVERSION'],'python'+env['PYTHON_VERSION']+'m','python'+env['PYTHON_VERSION'].replace('.','')): 174 225 if not result and env['LIBPATH_PYEMBED']: 175 226 path=env['LIBPATH_PYEMBED'] … … 195 246 else: 196 247 conf.to_log("\n\n### LIB NOT FOUND\n") 197 if (Utils.is_win32 or sys.platform.startswith('os2')or dct['Py_ENABLE_SHARED']):248 if Utils.is_win32 or dct['Py_ENABLE_SHARED']: 198 249 env['LIBPATH_PYEXT']=env['LIBPATH_PYEMBED'] 199 250 env['LIB_PYEXT']=env['LIB_PYEMBED'] 200 num='.'.join(env['PYTHON_VERSION'].split('.')[:2]) 201 conf.find_program([''.join(pybin)+'-config','python%s-config'%num,'python-config-%s'%num,'python%sm-config'%num],var='PYTHON_CONFIG',mandatory=False) 202 includes=[] 203 if conf.env.PYTHON_CONFIG: 204 for incstr in conf.cmd_and_log([conf.env.PYTHON_CONFIG,'--includes']).strip().split(): 205 if(incstr.startswith('-I')or incstr.startswith('/I')): 206 incstr=incstr[2:] 207 if incstr not in includes: 208 includes.append(incstr) 209 conf.to_log("Include path for Python extensions (found via python-config --includes): %r\n"%(includes,)) 210 env['INCLUDES_PYEXT']=includes 211 env['INCLUDES_PYEMBED']=includes 212 else: 213 conf.to_log("Include path for Python extensions ""(found via distutils module): %r\n"%(dct['INCLUDEPY'],)) 214 env['INCLUDES_PYEXT']=[dct['INCLUDEPY']] 215 env['INCLUDES_PYEMBED']=[dct['INCLUDEPY']] 251 conf.to_log("Include path for Python extensions (found via distutils module): %r\n"%(dct['INCLUDEPY'],)) 252 env['INCLUDES_PYEXT']=[dct['INCLUDEPY']] 253 env['INCLUDES_PYEMBED']=[dct['INCLUDEPY']] 216 254 if env['CC_NAME']=='gcc': 217 255 env.append_value('CFLAGS_PYEMBED',['-fno-strict-aliasing']) … … 227 265 env.append_value('CXXFLAGS_PYEXT',dist_compiler.compile_options) 228 266 env.append_value('LINKFLAGS_PYEXT',dist_compiler.ldflags_shared) 229 try: 230 conf.check(header_name='Python.h',define_name='HAVE_PYTHON_H',uselib='PYEMBED',fragment=FRAG,errmsg=':-(') 231 except conf.errors.ConfigurationError: 232 xx=conf.env.CXX_NAME and'cxx'or'c' 233 flags=['--cflags','--libs','--ldflags'] 234 for f in flags: 235 conf.check_cfg(msg='Asking python-config for pyembed %s flags'%f,path=conf.env.PYTHON_CONFIG,package='',uselib_store='PYEMBED',args=[f]) 236 conf.check(header_name='Python.h',define_name='HAVE_PYTHON_H',msg='Getting pyembed flags from python-config',fragment=FRAG,errmsg='Could not build a python embedded interpreter',features='%s %sprogram pyembed'%(xx,xx)) 237 for f in flags: 238 conf.check_cfg(msg='Asking python-config for pyext %s flags'%f,path=conf.env.PYTHON_CONFIG,package='',uselib_store='PYEXT',args=[f]) 239 conf.check(header_name='Python.h',define_name='HAVE_PYTHON_H',msg='Getting pyext flags from python-config',features='%s %sshlib pyext'%(xx,xx),fragment=FRAG,errmsg='Could not build python extensions') 267 conf.check(header_name='Python.h',define_name='HAVE_PYTHON_H',uselib='PYEMBED',fragment=FRAG,errmsg='Distutils not installed? Broken python installation? Get python-config now!') 240 268 @conf 241 269 def check_python_version(conf,minver=None): … … 253 281 pyver='.'.join([str(x)for x in pyver_tuple[:2]]) 254 282 conf.env['PYTHON_VERSION']=pyver 255 if'PYTHONDIR'in conf.environ: 283 if'PYTHONDIR'in conf.env: 284 pydir=conf.env['PYTHONDIR'] 285 elif'PYTHONDIR'in conf.environ: 256 286 pydir=conf.environ['PYTHONDIR'] 257 287 else: 258 288 if Utils.is_win32: 259 (python_LIBDEST,pydir)=conf.get_python_variables(["get_config_var('LIBDEST') or ''","get_python_lib(standard_lib=0 , prefix=%r) or ''"%conf.env['PREFIX']])289 (python_LIBDEST,pydir)=conf.get_python_variables(["get_config_var('LIBDEST') or ''","get_python_lib(standard_lib=0) or ''"]) 260 290 else: 261 291 python_LIBDEST=None 262 (pydir,)=conf.get_python_variables(["get_python_lib(standard_lib=0 , prefix=%r) or ''"%conf.env['PREFIX']])292 (pydir,)=conf.get_python_variables(["get_python_lib(standard_lib=0) or ''"]) 263 293 if python_LIBDEST is None: 264 294 if conf.env['LIBDIR']: … … 266 296 else: 267 297 python_LIBDEST=os.path.join(conf.env['PREFIX'],"lib","python"+pyver) 268 if'PYTHONARCHDIR'in conf.environ: 298 if'PYTHONARCHDIR'in conf.env: 299 pyarchdir=conf.env['PYTHONARCHDIR'] 300 elif'PYTHONARCHDIR'in conf.environ: 269 301 pyarchdir=conf.environ['PYTHONARCHDIR'] 270 302 else: 271 (pyarchdir,)=conf.get_python_variables(["get_python_lib(plat_specific=1, standard_lib=0 , prefix=%r) or ''"%conf.env['PREFIX']])303 (pyarchdir,)=conf.get_python_variables(["get_python_lib(plat_specific=1, standard_lib=0) or ''"]) 272 304 if not pyarchdir: 273 305 pyarchdir=pydir … … 289 321 version = getattr(current_module, '__version__', None) 290 322 if version is not None: 291 323 print(str(version)) 292 324 else: 293 325 print('unknown version') 294 326 ''' 295 327 @conf 296 328 def check_python_module(conf,module_name,condition=''): 297 msg= 'Python module %s'%module_name329 msg="Checking for python module '%s'"%module_name 298 330 if condition: 299 331 msg='%s (%s)'%(msg,condition) … … 325 357 conf.end_msg(ret) 326 358 def configure(conf): 327 try:328 conf.find_program('python',var='PYTHON')329 except conf.errors.ConfigurationError:330 Logs.warn("could not find a python executable, setting to sys.executable '%s'"%sys.executable)331 conf.env.PYTHON=sys.executable332 if conf.env.PYTHON!=sys.executable:333 Logs.warn("python executable %r differs from system %r"%(conf.env.PYTHON,sys.executable))334 conf.env.PYTHON=conf.cmd_to_list(conf.env.PYTHON)335 359 v=conf.env 336 v['PYCMD']='"import sys, py_compile;py_compile.compile(sys.argv[1], sys.argv[2])"' 360 v['PYTHON']=Options.options.python or os.environ.get('PYTHON',sys.executable) 361 if Options.options.pythondir: 362 v['PYTHONDIR']=Options.options.pythondir 363 if Options.options.pythonarchdir: 364 v['PYTHONARCHDIR']=Options.options.pythonarchdir 365 conf.find_program('python',var='PYTHON') 337 366 v['PYFLAGS']='' 338 367 v['PYFLAGS_OPT']='-O' 339 368 v['PYC']=getattr(Options.options,'pyc',1) 340 369 v['PYO']=getattr(Options.options,'pyo',1) 370 try: 371 v.PYTAG=conf.cmd_and_log(conf.env.PYTHON+['-c',"import imp;print(imp.get_tag())"]).strip() 372 except Errors.WafError: 373 pass 341 374 def options(opt): 342 opt.add_option('--nopyc',action='store_false',default=1,help='Do not install bytecode compiled .pyc files (configuration) [Default:install]',dest='pyc') 343 opt.add_option('--nopyo',action='store_false',default=1,help='Do not install optimised compiled .pyo files (configuration) [Default:install]',dest='pyo') 375 pyopt=opt.add_option_group("Python Options") 376 pyopt.add_option('--nopyc',dest='pyc',action='store_false',default=1,help='Do not install bytecode compiled .pyc files (configuration) [Default:install]') 377 pyopt.add_option('--nopyo',dest='pyo',action='store_false',default=1,help='Do not install optimised compiled .pyo files (configuration) [Default:install]') 378 pyopt.add_option('--python',dest="python",help='python binary to be used [Default: %s]'%sys.executable) 379 pyopt.add_option('--pythondir',dest='pythondir',help='Installation path for python modules (py, platform-independent .py and .pyc files)') 380 pyopt.add_option('--pythonarchdir',dest='pythonarchdir',help='Installation path for python extension (pyext, platform-dependent .so or .dylib files)') -
waflib/Tools/qt4.py
r5525507 r904702d 12 12 has_xml=True 13 13 import os,sys 14 from waflib.Tools import c _preproc,cxx15 from waflib import Task,Utils,Options,Errors 14 from waflib.Tools import cxx 15 from waflib import Task,Utils,Options,Errors,Context 16 16 from waflib.TaskGen import feature,after_method,extension 17 17 from waflib.Configure import conf … … 26 26 Task.Task.__init__(self,*k,**kw) 27 27 self.moc_done=0 28 def scan(self):29 (nodes,names)=c_preproc.scan(self)30 lst=[]31 for x in nodes:32 if x.name.endswith('.moc'):33 s=x.path_from(self.inputs[0].parent.get_bld())34 if s not in names:35 names.append(s)36 else:37 lst.append(x)38 return(lst,names)39 28 def runnable_status(self): 40 29 if self.moc_done: … … 57 46 tsk.set_inputs(h_node) 58 47 tsk.set_outputs(m_node) 48 if self.generator: 49 self.generator.tasks.append(tsk) 59 50 gen=self.generator.bld.producer 60 51 gen.outstanding.insert(0,tsk) 61 52 gen.total+=1 62 53 return tsk 54 def moc_h_ext(self): 55 try: 56 ext=Options.options.qt_header_ext.split() 57 except AttributeError: 58 pass 59 if not ext: 60 ext=MOC_H 61 return ext 63 62 def add_moc_tasks(self): 64 63 node=self.inputs[0] … … 70 69 else: 71 70 delattr(self,'cache_sig') 71 include_nodes=[node.parent]+self.generator.includes_nodes 72 72 moctasks=[] 73 mocfiles=[] 74 try: 75 tmp_lst=bld.raw_deps[self.uid()] 76 bld.raw_deps[self.uid()]=[] 77 except KeyError: 78 tmp_lst=[] 79 for d in tmp_lst: 73 mocfiles=set([]) 74 for d in bld.raw_deps.get(self.uid(),[]): 80 75 if not d.endswith('.moc'): 81 76 continue 82 77 if d in mocfiles: 83 Logs.error("paranoia owns")84 78 continue 85 mocfiles.a ppend(d)79 mocfiles.add(d) 86 80 h_node=None 87 try:ext=Options.options.qt_header_ext.split()88 except AttributeError:pass89 if not ext:ext=MOC_H90 81 base2=d[:-4] 91 for x in [node.parent]+self.generator.includes_nodes:92 for e in ext:82 for x in include_nodes: 83 for e in self.moc_h_ext(): 93 84 h_node=x.find_node(base2+e) 94 85 if h_node: … … 100 91 for k in EXT_QT4: 101 92 if base2.endswith(k): 102 for x in [node.parent]+self.generator.includes_nodes:93 for x in include_nodes: 103 94 h_node=x.find_node(base2) 104 95 if h_node: 105 96 break 106 if h_node:107 m_node=h_node.change_ext(k+'.moc')108 break97 if h_node: 98 m_node=h_node.change_ext(k+'.moc') 99 break 109 100 if not h_node: 110 raise Errors.WafError('no header found for %r which is a moc file'%d) 111 bld.node_deps[(self.inputs[0].parent.abspath(),m_node.name)]=h_node 101 raise Errors.WafError('No source found for %r which is a moc file'%d) 112 102 task=self.create_moc_task(h_node,m_node) 113 103 moctasks.append(task) 114 tmp_lst=bld.raw_deps[self.uid()]=mocfiles115 lst=bld.node_deps.get(self.uid(),())116 for d in lst:117 name=d.name118 if name.endswith('.moc'):119 task=self.create_moc_task(bld.node_deps[(self.inputs[0].parent.abspath(),name)],d)120 moctasks.append(task)121 104 self.run_after.update(set(moctasks)) 122 105 self.moc_done=1 123 run=Task.classes['cxx'].__dict__['run']124 106 class trans_update(Task.Task): 125 107 run_str='${QT_LUPDATE} ${SRC} -ts ${TGT}' … … 141 123 def create_rcc_task(self,node): 142 124 rcnode=node.change_ext('_rc.cpp') 143 rcctask=self.create_task('rcc',node,rcnode)125 self.create_task('rcc',node,rcnode) 144 126 cpptask=self.create_task('cxx',rcnode,rcnode.change_ext('.o')) 145 127 try: … … 180 162 if len(flag)<2:continue 181 163 f=flag[0:2] 182 if f in ['-D','-I','/D','/I']:164 if f in('-D','-I','/D','/I'): 183 165 if(f[0]=='/'): 184 166 lst.append('-'+flag[1:]) … … 191 173 class rcc(Task.Task): 192 174 color='BLUE' 193 run_str='${QT_RCC} -name ${ SRC[0].name} ${SRC[0].abspath()} ${RCC_ST} -o ${TGT}'175 run_str='${QT_RCC} -name ${tsk.rcname()} ${SRC[0].abspath()} ${RCC_ST} -o ${TGT}' 194 176 ext_out=['.h'] 177 def rcname(self): 178 return os.path.splitext(self.inputs[0].name)[0] 195 179 def scan(self): 196 node=self.inputs[0]197 180 if not has_xml: 198 181 Logs.error('no xml support was found, the rcc dependencies will be incomplete!') … … 217 200 color='BLUE' 218 201 run_str='${QT_MOC} ${MOC_FLAGS} ${MOCCPPPATH_ST:INCPATHS} ${MOCDEFINES_ST:DEFINES} ${SRC} ${MOC_ST} ${TGT}' 202 def keyword(self): 203 return"Creating" 204 def __str__(self): 205 return self.outputs[0].path_from(self.generator.bld.launch_node()) 219 206 class ui4(Task.Task): 220 207 color='BLUE' … … 268 255 cand=None 269 256 prev_ver=['4','0','0'] 270 for qmk in ['qmake-qt4','qmake4','qmake']:257 for qmk in('qmake-qt4','qmake4','qmake'): 271 258 try: 272 259 qmake=self.find_program(qmk,path_list=paths) … … 275 262 else: 276 263 try: 277 version=self.cmd_and_log( [qmake,'-query','QT_VERSION']).strip()264 version=self.cmd_and_log(qmake+['-query','QT_VERSION']).strip() 278 265 except self.errors.WafError: 279 266 pass … … 288 275 else: 289 276 self.fatal('Could not find qmake for qt4') 290 qtbin=self.cmd_and_log( [self.env.QMAKE,'-query','QT_INSTALL_BINS']).strip()+os.sep277 qtbin=self.cmd_and_log(self.env.QMAKE+['-query','QT_INSTALL_BINS']).strip()+os.sep 291 278 def find_bin(lst,var): 292 279 if var in env: … … 302 289 find_bin(['uic-qt3','uic3'],'QT_UIC3') 303 290 find_bin(['uic-qt4','uic'],'QT_UIC') 304 if not env ['QT_UIC']:291 if not env.QT_UIC: 305 292 self.fatal('cannot find the uic compiler for qt4') 306 try: 307 uicver=self.cmd_and_log(env['QT_UIC']+" -version 2>&1").strip() 308 except self.errors.ConfigurationError: 309 self.fatal('this uic compiler is for qt3, add uic for qt4 to your path') 293 self.start_msg('Checking for uic version') 294 uicver=self.cmd_and_log(env.QT_UIC+["-version"],output=Context.BOTH) 295 uicver=''.join(uicver).strip() 310 296 uicver=uicver.replace('Qt User Interface Compiler ','').replace('User Interface Compiler for Qt','') 311 self. msg('Checking for uic version','%s'%uicver)297 self.end_msg(uicver) 312 298 if uicver.find(' 3.')!=-1: 313 299 self.fatal('this uic compiler is for qt3, add uic for qt4 to your path') 314 300 find_bin(['moc-qt4','moc'],'QT_MOC') 315 find_bin(['rcc '],'QT_RCC')301 find_bin(['rcc-qt4','rcc'],'QT_RCC') 316 302 find_bin(['lrelease-qt4','lrelease'],'QT_LRELEASE') 317 303 find_bin(['lupdate-qt4','lupdate'],'QT_LUPDATE') … … 328 314 if not qtlibs: 329 315 try: 330 qtlibs=self.cmd_and_log( [self.env.QMAKE,'-query','QT_INSTALL_LIBS']).strip()316 qtlibs=self.cmd_and_log(self.env.QMAKE+['-query','QT_INSTALL_LIBS']).strip() 331 317 except Errors.WafError: 332 qtdir=self.cmd_and_log( [self.env.QMAKE,'-query','QT_INSTALL_PREFIX']).strip()+os.sep318 qtdir=self.cmd_and_log(self.env.QMAKE+['-query','QT_INSTALL_PREFIX']).strip()+os.sep 333 319 qtlibs=os.path.join(qtdir,'lib') 334 320 self.msg('Found the Qt4 libraries in',qtlibs) 335 qtincludes=os.environ.get("QT4_INCLUDES",None)or self.cmd_and_log( [self.env.QMAKE,'-query','QT_INSTALL_HEADERS']).strip()321 qtincludes=os.environ.get("QT4_INCLUDES",None)or self.cmd_and_log(self.env.QMAKE+['-query','QT_INSTALL_HEADERS']).strip() 336 322 env=self.env 337 323 if not'PKG_CONFIG_PATH'in os.environ: -
waflib/Tools/ruby.py
r5525507 r904702d 28 28 ruby=self.env.RUBY 29 29 try: 30 version=self.cmd_and_log( [ruby,'-e','puts defined?(VERSION) ? VERSION : RUBY_VERSION']).strip()30 version=self.cmd_and_log(ruby+['-e','puts defined?(VERSION) ? VERSION : RUBY_VERSION']).strip() 31 31 except Exception: 32 32 self.fatal('could not determine ruby version') … … 52 52 version=tuple(map(int,self.env.RUBY_VERSION.split("."))) 53 53 def read_out(cmd): 54 return Utils.to_list(self.cmd_and_log( [self.env.RUBY,'-rrbconfig','-e',cmd]))54 return Utils.to_list(self.cmd_and_log(self.env.RUBY+['-rrbconfig','-e',cmd])) 55 55 def read_config(key): 56 return read_out('puts Config::CONFIG[%r]'%key)56 return read_out('puts RbConfig::CONFIG[%r]'%key) 57 57 ruby=self.env['RUBY'] 58 58 archdir=read_config('archdir') … … 88 88 self.start_msg('Ruby module %s'%module_name) 89 89 try: 90 self.cmd_and_log( [self.env['RUBY'],'-e','require \'%s\';puts 1'%module_name])90 self.cmd_and_log(self.env.RUBY+['-e','require \'%s\';puts 1'%module_name]) 91 91 except Exception: 92 92 self.end_msg(False) -
waflib/Tools/suncc.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os6 5 from waflib import Utils 7 6 from waflib.Tools import ccroot,ar … … 10 9 def find_scc(conf): 11 10 v=conf.env 12 cc=None 13 if v['CC']:cc=v['CC'] 14 elif'CC'in conf.environ:cc=conf.environ['CC'] 15 if not cc:cc=conf.find_program('cc',var='CC') 16 if not cc:conf.fatal('Could not find a Sun C compiler') 17 cc=conf.cmd_to_list(cc) 11 cc=conf.find_program('cc',var='CC') 18 12 try: 19 13 conf.cmd_and_log(cc+['-flags']) 20 14 except Exception: 21 15 conf.fatal('%r is not a Sun compiler'%cc) 22 v['CC']=cc 23 v['CC_NAME']='sun' 16 v.CC_NAME='sun' 24 17 conf.get_suncc_version(cc) 25 18 @conf -
waflib/Tools/suncxx.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os6 5 from waflib import Utils 7 6 from waflib.Tools import ccroot,ar … … 10 9 def find_sxx(conf): 11 10 v=conf.env 12 cc=None 13 if v['CXX']:cc=v['CXX'] 14 elif'CXX'in conf.environ:cc=conf.environ['CXX'] 15 if not cc:cc=conf.find_program('CC',var='CXX') 16 if not cc:cc=conf.find_program('c++',var='CXX') 17 if not cc:conf.fatal('Could not find a Sun C++ compiler') 18 cc=conf.cmd_to_list(cc) 11 cc=conf.find_program(['CC','c++'],var='CXX') 19 12 try: 20 13 conf.cmd_and_log(cc+['-flags']) 21 14 except Exception: 22 15 conf.fatal('%r is not a Sun compiler'%cc) 23 v['CXX']=cc 24 v['CXX_NAME']='sun' 16 v.CXX_NAME='sun' 25 17 conf.get_suncc_version(cc) 26 18 @conf -
waflib/Tools/tex.py
r5525507 r904702d 4 4 5 5 import os,re 6 from waflib import Utils,Task,Errors,Logs 6 from waflib import Utils,Task,Errors,Logs,Node 7 7 from waflib.TaskGen import feature,before_method 8 8 re_bibunit=re.compile(r'\\(?P<type>putbib)\[(?P<file>[^\[\]]*)\]',re.M) … … 15 15 path=match.group('file') 16 16 if path: 17 for k in ['','.bib']:17 for k in('','.bib'): 18 18 Logs.debug('tex: trying %s%s'%(path,k)) 19 19 fi=node.parent.find_resource(path+k) … … 24 24 Logs.debug("tex: found the following bibunit files: %s"%nodes) 25 25 return nodes 26 exts_deps_tex=['','.ltx','.tex','.bib','.pdf','.png','.eps','.ps' ]26 exts_deps_tex=['','.ltx','.tex','.bib','.pdf','.png','.eps','.ps','.sty'] 27 27 exts_tex=['.ltx','.tex'] 28 re_tex=re.compile(r'\\(?P<type> include|bibliography|putbib|includegraphics|input|import|bringin|lstinputlisting)(\[[^\[\]]*\])?{(?P<file>[^{}]*)}',re.M)28 re_tex=re.compile(r'\\(?P<type>usepackage|RequirePackage|include|bibliography([^\[\]{}]*)|putbib|includegraphics|input|import|bringin|lstinputlisting)(\[[^\[\]]*\])?{(?P<file>[^{}]*)}',re.M) 29 29 g_bibtex_re=re.compile('bibdata',re.M) 30 g_glossaries_re=re.compile('\\@newglossary',re.M) 30 31 class tex(Task.Task): 31 32 bibtex_fun,_=Task.compile_fun('${BIBTEX} ${BIBTEXFLAGS} ${SRCFILE}',shell=False) … … 37 38 Execute the program **makeindex** 38 39 """ 40 makeglossaries_fun,_=Task.compile_fun('${MAKEGLOSSARIES} ${SRCFILE}',shell=False) 41 makeglossaries_fun.__doc__=""" 42 Execute the program **makeglossaries** 43 """ 39 44 def exec_command(self,cmd,**kw): 40 45 bld=self.generator.bld 46 Logs.info('runner: %r'%cmd) 41 47 try: 42 48 if not kw.get('cwd',None): … … 72 78 global re_tex 73 79 for match in re_tex.finditer(code): 80 multibib=match.group('type') 81 if multibib and multibib.startswith('bibliography'): 82 multibib=multibib[len('bibliography'):] 83 if multibib.startswith('style'): 84 continue 85 else: 86 multibib=None 74 87 for path in match.group('file').split(','): 75 88 if path: … … 77 90 found=None 78 91 for k in exts_deps_tex: 79 Logs.debug('tex: trying %s%s'%(path,k)) 80 found=node.parent.find_resource(path+k) 92 for up in self.texinputs_nodes: 93 Logs.debug('tex: trying %s%s'%(path,k)) 94 found=up.find_resource(path+k) 95 if found: 96 break 81 97 for tsk in self.generator.tasks: 82 98 if not found or found in tsk.outputs: … … 89 105 parse_node(found) 90 106 break 107 if found and multibib and found.name.endswith('.bib'): 108 try: 109 self.multibibs.append(found) 110 except AttributeError: 111 self.multibibs=[found] 91 112 if add_name: 92 113 names.append(path) … … 103 124 try: 104 125 ct=aux_node.read() 105 except (OSError,IOError):126 except EnvironmentError: 106 127 Logs.error('Error reading %s: %r'%aux_node.abspath()) 107 128 continue 108 129 if g_bibtex_re.findall(ct): 109 Logs. warn('calling bibtex')130 Logs.info('calling bibtex') 110 131 self.env.env={} 111 132 self.env.env.update(os.environ) 112 self.env.env.update({'BIBINPUTS':self. TEXINPUTS,'BSTINPUTS':self.TEXINPUTS})133 self.env.env.update({'BIBINPUTS':self.texinputs(),'BSTINPUTS':self.texinputs()}) 113 134 self.env.SRCFILE=aux_node.name[:-4] 114 135 self.check_status('error when calling bibtex',self.bibtex_fun()) 136 for node in getattr(self,'multibibs',[]): 137 self.env.env={} 138 self.env.env.update(os.environ) 139 self.env.env.update({'BIBINPUTS':self.texinputs(),'BSTINPUTS':self.texinputs()}) 140 self.env.SRCFILE=node.name[:-4] 141 self.check_status('error when calling bibtex',self.bibtex_fun()) 115 142 def bibunits(self): 116 143 try: … … 120 147 else: 121 148 if bibunits: 122 fn=['bu'+str(i)for i in xrange(1,len(bibunits)+1)]149 fn=['bu'+str(i)for i in range(1,len(bibunits)+1)] 123 150 if fn: 124 Logs. warn('calling bibtex on bibunits')151 Logs.info('calling bibtex on bibunits') 125 152 for f in fn: 126 self.env.env={'BIBINPUTS':self. TEXINPUTS,'BSTINPUTS':self.TEXINPUTS}153 self.env.env={'BIBINPUTS':self.texinputs(),'BSTINPUTS':self.texinputs()} 127 154 self.env.SRCFILE=f 128 155 self.check_status('error when calling bibtex',self.bibtex_fun()) 129 156 def makeindex(self): 157 self.idx_node=self.inputs[0].change_ext('.idx') 130 158 try: 131 159 idx_path=self.idx_node.abspath() 132 160 os.stat(idx_path) 133 161 except OSError: 134 Logs. warn('index file %s absent, not calling makeindex'%idx_path)162 Logs.info('index file %s absent, not calling makeindex'%idx_path) 135 163 else: 136 Logs. warn('calling makeindex')164 Logs.info('calling makeindex') 137 165 self.env.SRCFILE=self.idx_node.name 138 166 self.env.env={} … … 142 170 if os.path.exists(os.path.join(p.abspath(),'btaux.aux')): 143 171 self.aux_nodes+=p.ant_glob('*[0-9].aux') 172 def makeglossaries(self): 173 src_file=self.inputs[0].abspath() 174 base_file=os.path.basename(src_file) 175 base,_=os.path.splitext(base_file) 176 for aux_node in self.aux_nodes: 177 try: 178 ct=aux_node.read() 179 except EnvironmentError: 180 Logs.error('Error reading %s: %r'%aux_node.abspath()) 181 continue 182 if g_glossaries_re.findall(ct): 183 if not self.env.MAKEGLOSSARIES: 184 raise Errors.WafError("The program 'makeglossaries' is missing!") 185 Logs.warn('calling makeglossaries') 186 self.env.SRCFILE=base 187 self.check_status('error when calling makeglossaries %s'%base,self.makeglossaries_fun()) 188 return 189 def texinputs(self): 190 return os.pathsep.join([k.abspath()for k in self.texinputs_nodes])+os.pathsep 144 191 def run(self): 145 192 env=self.env … … 148 195 env.append_value('PDFLATEXFLAGS','-interaction=batchmode') 149 196 env.append_value('XELATEXFLAGS','-interaction=batchmode') 150 fun=self.texfun151 node=self.inputs[0]152 srcfile=node.abspath()153 texinputs=self.env.TEXINPUTS or''154 self.TEXINPUTS=node.parent.get_bld().abspath()+os.pathsep+node.parent.get_src().abspath()+os.pathsep+texinputs+os.pathsep155 197 self.cwd=self.inputs[0].parent.get_bld().abspath() 156 Logs.warn('first pass on %s'%self.__class__.__name__) 157 self.env.env={} 158 self.env.env.update(os.environ) 159 self.env.env.update({'TEXINPUTS':self.TEXINPUTS}) 160 self.env.SRCFILE=srcfile 161 self.check_status('error when calling latex',fun()) 162 self.aux_nodes=self.scan_aux(node.change_ext('.aux')) 163 self.idx_node=node.change_ext('.idx') 198 Logs.info('first pass on %s'%self.__class__.__name__) 199 cur_hash=self.hash_aux_nodes() 200 self.call_latex() 201 self.hash_aux_nodes() 164 202 self.bibtopic() 165 203 self.bibfile() 166 204 self.bibunits() 167 205 self.makeindex() 168 hash=''206 self.makeglossaries() 169 207 for i in range(10): 170 prev_hash=hash 208 prev_hash=cur_hash 209 cur_hash=self.hash_aux_nodes() 210 if not cur_hash: 211 Logs.error('No aux.h to process') 212 if cur_hash and cur_hash==prev_hash: 213 break 214 Logs.info('calling %s'%self.__class__.__name__) 215 self.call_latex() 216 def hash_aux_nodes(self): 217 try: 218 nodes=self.aux_nodes 219 except AttributeError: 171 220 try: 172 hashes=[Utils.h_file(x.abspath())for x in self.aux_nodes] 173 hash=Utils.h_list(hashes) 174 except(OSError,IOError): 175 Logs.error('could not read aux.h') 176 pass 177 if hash and hash==prev_hash: 178 break 179 Logs.warn('calling %s'%self.__class__.__name__) 180 self.env.env={} 181 self.env.env.update(os.environ) 182 self.env.env.update({'TEXINPUTS':self.TEXINPUTS}) 183 self.env.SRCFILE=srcfile 184 self.check_status('error when calling %s'%self.__class__.__name__,fun()) 221 self.aux_nodes=self.scan_aux(self.inputs[0].change_ext('.aux')) 222 except IOError: 223 return None 224 return Utils.h_list([Utils.h_file(x.abspath())for x in self.aux_nodes]) 225 def call_latex(self): 226 self.env.env={} 227 self.env.env.update(os.environ) 228 self.env.env.update({'TEXINPUTS':self.texinputs()}) 229 self.env.SRCFILE=self.inputs[0].abspath() 230 self.check_status('error when calling latex',self.texfun()) 185 231 class latex(tex): 186 232 texfun,vars=Task.compile_fun('${LATEX} ${LATEXFLAGS} ${SRCFILE}',shell=False) … … 204 250 @before_method('process_source') 205 251 def apply_tex(self): 206 if not getattr(self,'type',None)in ['latex','pdflatex','xelatex']:252 if not getattr(self,'type',None)in('latex','pdflatex','xelatex'): 207 253 self.type='pdflatex' 208 254 tree=self.bld … … 212 258 if getattr(self,'deps',None): 213 259 deps=self.to_list(self.deps) 214 for filename in deps: 215 n=self.path.find_resource(filename) 216 if not n: 217 self.bld.fatal('Could not find %r for %r'%(filename,self)) 218 if not n in deps_lst: 219 deps_lst.append(n) 260 for dep in deps: 261 if isinstance(dep,str): 262 n=self.path.find_resource(dep) 263 if not n: 264 self.bld.fatal('Could not find %r for %r'%(dep,self)) 265 if not n in deps_lst: 266 deps_lst.append(n) 267 elif isinstance(dep,Node.Node): 268 deps_lst.append(dep) 220 269 for node in self.to_nodes(self.source): 221 270 if self.type=='latex': … … 227 276 task.env=self.env 228 277 if deps_lst: 229 try: 230 lst=tree.node_deps[task.uid()] 231 for n in deps_lst: 232 if not n in lst: 233 lst.append(n) 234 except KeyError: 235 tree.node_deps[task.uid()]=deps_lst 236 v=dict(os.environ) 237 p=node.parent.abspath()+os.pathsep+self.path.abspath()+os.pathsep+self.path.get_bld().abspath()+os.pathsep+v.get('TEXINPUTS','')+os.pathsep 238 v['TEXINPUTS']=p 278 for n in deps_lst: 279 if not n in task.dep_nodes: 280 task.dep_nodes.append(n) 281 if hasattr(self,'texinputs_nodes'): 282 task.texinputs_nodes=self.texinputs_nodes 283 else: 284 task.texinputs_nodes=[node.parent,node.parent.get_bld(),self.path,self.path.get_bld()] 285 lst=os.environ.get('TEXINPUTS','') 286 if self.env.TEXINPUTS: 287 lst+=os.pathsep+self.env.TEXINPUTS 288 if lst: 289 lst=lst.split(os.pathsep) 290 for x in lst: 291 if x: 292 if os.path.isabs(x): 293 p=self.bld.root.find_node(x) 294 if p: 295 task.texinputs_nodes.append(p) 296 else: 297 Logs.error('Invalid TEXINPUTS folder %s'%x) 298 else: 299 Logs.error('Cannot resolve relative paths in TEXINPUTS %s'%x) 239 300 if self.type=='latex': 240 301 if'ps'in outs: 241 302 tsk=self.create_task('dvips',task.outputs,node.change_ext('.ps')) 242 tsk.env.env=dict( v)303 tsk.env.env=dict(os.environ) 243 304 if'pdf'in outs: 244 305 tsk=self.create_task('dvipdf',task.outputs,node.change_ext('.pdf')) 245 tsk.env.env=dict( v)306 tsk.env.env=dict(os.environ) 246 307 elif self.type=='pdflatex': 247 308 if'ps'in outs: … … 250 311 def configure(self): 251 312 v=self.env 252 for p in'tex latex pdflatex xelatex bibtex dvips dvipdf ps2pdf makeindex pdf2ps '.split():313 for p in'tex latex pdflatex xelatex bibtex dvips dvipdf ps2pdf makeindex pdf2ps makeglossaries'.split(): 253 314 try: 254 315 self.find_program(p,var=p.upper()) -
waflib/Tools/vala.py
r5525507 r904702d 11 11 ext_out=['.h'] 12 12 def run(self): 13 cmd= [self.env['VALAC']]+self.env['VALAFLAGS']13 cmd=self.env.VALAC+self.env.VALAFLAGS 14 14 cmd.extend([a.abspath()for a in self.inputs]) 15 15 ret=self.exec_command(cmd,cwd=self.outputs[0].parent.abspath()) … … 160 160 valac=self.find_program(valac_name,var='VALAC') 161 161 try: 162 output=self.cmd_and_log(valac+ ' --version')162 output=self.cmd_and_log(valac+['--version']) 163 163 except Exception: 164 164 valac_version=None -
waflib/Tools/waf_unit_test.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os ,sys6 from waflib.TaskGen import feature,after_method 5 import os 6 from waflib.TaskGen import feature,after_method,taskgen_method 7 7 from waflib import Utils,Task,Logs,Options 8 8 testlock=Utils.threading.Lock() … … 12 12 if getattr(self,'link_task',None): 13 13 self.create_task('utest',self.link_task.outputs) 14 @taskgen_method 15 def add_test_results(self,tup): 16 Logs.debug("ut: %r",tup) 17 self.utest_result=tup 18 try: 19 self.bld.utest_results.append(tup) 20 except AttributeError: 21 self.bld.utest_results=[tup] 14 22 class utest(Task.Task): 15 23 color='PINK' … … 24 32 return Task.RUN_ME 25 33 return ret 26 def run(self): 27 filename=self.inputs[0].abspath() 28 self.ut_exec=getattr(self.generator,'ut_exec',[filename]) 29 if getattr(self.generator,'ut_fun',None): 30 self.generator.ut_fun(self) 34 def add_path(self,dct,path,var): 35 dct[var]=os.pathsep.join(Utils.to_list(path)+[os.environ.get(var,'')]) 36 def get_test_env(self): 31 37 try: 32 38 fu=getattr(self.generator.bld,'all_test_paths') … … 40 46 if s not in lst: 41 47 lst.append(s) 42 def add_path(dct,path,var):43 dct[var]=os.pathsep.join(Utils.to_list(path)+[os.environ.get(var,'')])44 48 if Utils.is_win32: 45 add_path(fu,lst,'PATH')49 self.add_path(fu,lst,'PATH') 46 50 elif Utils.unversioned_sys_platform()=='darwin': 47 add_path(fu,lst,'DYLD_LIBRARY_PATH')48 add_path(fu,lst,'LD_LIBRARY_PATH')51 self.add_path(fu,lst,'DYLD_LIBRARY_PATH') 52 self.add_path(fu,lst,'LD_LIBRARY_PATH') 49 53 else: 50 add_path(fu,lst,'LD_LIBRARY_PATH')54 self.add_path(fu,lst,'LD_LIBRARY_PATH') 51 55 self.generator.bld.all_test_paths=fu 56 return fu 57 def run(self): 58 filename=self.inputs[0].abspath() 59 self.ut_exec=getattr(self.generator,'ut_exec',[filename]) 60 if getattr(self.generator,'ut_fun',None): 61 self.generator.ut_fun(self) 52 62 cwd=getattr(self.generator,'ut_cwd','')or self.inputs[0].parent.abspath() 53 testcmd=getattr( Options.options,'testcmd',False)63 testcmd=getattr(self.generator,'ut_cmd',False)or getattr(Options.options,'testcmd',False) 54 64 if testcmd: 55 65 self.ut_exec=(testcmd%self.ut_exec[0]).split(' ') 56 proc=Utils.subprocess.Popen(self.ut_exec,cwd=cwd,env= fu,stderr=Utils.subprocess.PIPE,stdout=Utils.subprocess.PIPE)66 proc=Utils.subprocess.Popen(self.ut_exec,cwd=cwd,env=self.get_test_env(),stderr=Utils.subprocess.PIPE,stdout=Utils.subprocess.PIPE) 57 67 (stdout,stderr)=proc.communicate() 58 68 tup=(filename,proc.returncode,stdout,stderr) 59 self.generator.utest_result=tup60 69 testlock.acquire() 61 70 try: 62 bld=self.generator.bld 63 Logs.debug("ut: %r",tup) 64 try: 65 bld.utest_results.append(tup) 66 except AttributeError: 67 bld.utest_results=[tup] 71 return self.generator.add_test_results(tup) 68 72 finally: 69 73 testlock.release() -
waflib/Tools/xlc.py
r5525507 r904702d 8 8 def find_xlc(conf): 9 9 cc=conf.find_program(['xlc_r','xlc'],var='CC') 10 cc=conf.cmd_to_list(cc)11 10 conf.get_xlc_version(cc) 12 11 conf.env.CC_NAME='xlc' 13 conf.env.CC=cc14 12 @conf 15 13 def xlc_common_flags(conf): -
waflib/Tools/xlcxx.py
r5525507 r904702d 8 8 def find_xlcxx(conf): 9 9 cxx=conf.find_program(['xlc++_r','xlc++'],var='CXX') 10 cxx=conf.cmd_to_list(cxx)11 10 conf.get_xlc_version(cxx) 12 11 conf.env.CXX_NAME='xlc++' 13 conf.env.CXX=cxx14 12 @conf 15 13 def xlcxx_common_flags(conf): -
waflib/Utils.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import os,sys,errno,traceback,inspect,re,shutil,datetime,gc 5 import os,sys,errno,traceback,inspect,re,shutil,datetime,gc,platform 6 6 import subprocess 7 try: 8 from collections import deque 9 except ImportError: 10 class deque(list): 11 def popleft(self): 12 return self.pop(0) 7 from collections import deque,defaultdict 13 8 try: 14 9 import _winreg as winreg … … 33 28 import threading 34 29 except ImportError: 30 if not'JOBS'in os.environ: 31 os.environ['JOBS']='1' 35 32 class threading(object): 36 33 pass … … 57 54 rot_idx=0 58 55 try: 59 from collections import defaultdict56 from collections import OrderedDict as ordered_iter_dict 60 57 except ImportError: 61 class defaultdict(dict): 62 def __init__(self,default_factory): 63 super(defaultdict,self).__init__() 64 self.default_factory=default_factory 65 def __getitem__(self,key): 58 class ordered_iter_dict(dict): 59 def __init__(self,*k,**kw): 60 self.lst=[] 61 dict.__init__(self,*k,**kw) 62 def clear(self): 63 dict.clear(self) 64 self.lst=[] 65 def __setitem__(self,key,value): 66 dict.__setitem__(self,key,value) 66 67 try: 67 return super(defaultdict,self).__getitem__(key) 68 except KeyError: 69 value=self.default_factory() 70 self[key]=value 71 return value 72 is_win32=sys.platform in('win32','cli') 73 indicator='\x1b[K%s%s%s\r' 74 if is_win32 and'NOCOLOR'in os.environ: 75 indicator='%s%s%s\r' 68 self.lst.remove(key) 69 except ValueError: 70 pass 71 self.lst.append(key) 72 def __delitem__(self,key): 73 dict.__delitem__(self,key) 74 try: 75 self.lst.remove(key) 76 except ValueError: 77 pass 78 def __iter__(self): 79 for x in self.lst: 80 yield x 81 def keys(self): 82 return self.lst 83 is_win32=sys.platform in('win32','cli','os2') 76 84 def readf(fname,m='r',encoding='ISO8859-1'): 77 85 if sys.hexversion>0x3000000 and not'b'in m: … … 82 90 finally: 83 91 f.close() 84 txt=txt.decode(encoding) 92 if encoding: 93 txt=txt.decode(encoding) 94 else: 95 txt=txt.decode() 85 96 else: 86 97 f=open(fname,m) … … 109 120 f.close() 110 121 return m.digest() 111 if hasattr(os,'O_NOINHERIT')and sys.hexversion<0x3040000:112 def readf_win32(f,m='r',encoding='ISO8859-1'):113 flags=os.O_NOINHERIT|os.O_RDONLY114 if'b'in m:115 flags|=os.O_BINARY116 if'+'in m:117 flags|=os.O_RDWR118 try:119 fd=os.open(f,flags)120 except OSError:121 raise IOError('Cannot read from %r'%f)122 if sys.hexversion>0x3000000 and not'b'in m:123 m+='b'124 f=os.fdopen(fd,m)125 t ry:126 txt=f.read()127 f inally:128 f.close()122 def readf_win32(f,m='r',encoding='ISO8859-1'): 123 flags=os.O_NOINHERIT|os.O_RDONLY 124 if'b'in m: 125 flags|=os.O_BINARY 126 if'+'in m: 127 flags|=os.O_RDWR 128 try: 129 fd=os.open(f,flags) 130 except OSError: 131 raise IOError('Cannot read from %r'%f) 132 if sys.hexversion>0x3000000 and not'b'in m: 133 m+='b' 134 f=os.fdopen(fd,m) 135 try: 136 txt=f.read() 137 finally: 138 f.close() 139 if encoding: 129 140 txt=txt.decode(encoding) 130 141 else: 131 f=os.fdopen(fd,m) 132 try: 133 txt=f.read() 134 finally: 135 f.close() 136 return txt 137 def writef_win32(f,data,m='w',encoding='ISO8859-1'): 138 if sys.hexversion>0x3000000 and not'b'in m: 139 data=data.encode(encoding) 140 m+='b' 141 flags=os.O_CREAT|os.O_TRUNC|os.O_WRONLY|os.O_NOINHERIT 142 if'b'in m: 143 flags|=os.O_BINARY 144 if'+'in m: 145 flags|=os.O_RDWR 146 try: 147 fd=os.open(f,flags) 148 except OSError: 149 raise IOError('Cannot write to %r'%f) 142 txt=txt.decode() 143 else: 150 144 f=os.fdopen(fd,m) 151 145 try: 152 f.write(data)146 txt=f.read() 153 147 finally: 154 148 f.close() 155 def h_file_win32(fname): 156 try: 157 fd=os.open(fname,os.O_BINARY|os.O_RDONLY|os.O_NOINHERIT) 158 except OSError: 159 raise IOError('Cannot read from %r'%fname) 160 f=os.fdopen(fd,'rb') 161 m=md5() 162 try: 163 while fname: 164 fname=f.read(200000) 165 m.update(fname) 166 finally: 167 f.close() 168 return m.digest() 169 readf_old=readf 170 writef_old=writef 171 h_file_old=h_file 149 return txt 150 def writef_win32(f,data,m='w',encoding='ISO8859-1'): 151 if sys.hexversion>0x3000000 and not'b'in m: 152 data=data.encode(encoding) 153 m+='b' 154 flags=os.O_CREAT|os.O_TRUNC|os.O_WRONLY|os.O_NOINHERIT 155 if'b'in m: 156 flags|=os.O_BINARY 157 if'+'in m: 158 flags|=os.O_RDWR 159 try: 160 fd=os.open(f,flags) 161 except OSError: 162 raise IOError('Cannot write to %r'%f) 163 f=os.fdopen(fd,m) 164 try: 165 f.write(data) 166 finally: 167 f.close() 168 def h_file_win32(fname): 169 try: 170 fd=os.open(fname,os.O_BINARY|os.O_RDONLY|os.O_NOINHERIT) 171 except OSError: 172 raise IOError('Cannot read from %r'%fname) 173 f=os.fdopen(fd,'rb') 174 m=md5() 175 try: 176 while fname: 177 fname=f.read(200000) 178 m.update(fname) 179 finally: 180 f.close() 181 return m.digest() 182 readf_unix=readf 183 writef_unix=writef 184 h_file_unix=h_file 185 if hasattr(os,'O_NOINHERIT')and sys.hexversion<0x3040000: 172 186 readf=readf_win32 173 187 writef=writef_win32 … … 191 205 :type s: string 192 206 """ 207 def listdir_win32(s): 208 if not s: 209 try: 210 import ctypes 211 except ImportError: 212 return[x+':\\'for x in list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')] 213 else: 214 dlen=4 215 maxdrives=26 216 buf=ctypes.create_string_buffer(maxdrives*dlen) 217 ndrives=ctypes.windll.kernel32.GetLogicalDriveStringsA(maxdrives*dlen,ctypes.byref(buf)) 218 return[str(buf.raw[4*i:4*i+2].decode('ascii'))for i in range(int(ndrives/dlen))] 219 if len(s)==2 and s[1]==":": 220 s+=os.sep 221 if not os.path.isdir(s): 222 e=OSError('%s is not a directory'%s) 223 e.errno=errno.ENOENT 224 raise e 225 return os.listdir(s) 193 226 listdir=os.listdir 194 227 if is_win32: 195 def listdir_win32(s):196 if not s:197 try:198 import ctypes199 except ImportError:200 return[x+':\\'for x in list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')]201 else:202 dlen=4203 maxdrives=26204 buf=ctypes.create_string_buffer(maxdrives*dlen)205 ndrives=ctypes.windll.kernel32.GetLogicalDriveStringsA(maxdrives*dlen,ctypes.byref(buf))206 return[str(buf.raw[4*i:4*i+2].decode('ascii'))for i in range(int(ndrives/dlen))]207 if len(s)==2 and s[1]==":":208 s+=os.sep209 if not os.path.isdir(s):210 e=OSError('%s is not a directory'%s)211 e.errno=errno.ENOENT212 raise e213 return os.listdir(s)214 228 listdir=listdir_win32 215 229 def num2ver(ver): … … 232 246 else: 233 247 return sth 234 re_nl=re.compile('\r*\n',re.M) 235 def str_to_dict(txt): 236 tbl={} 237 lines=re_nl.split(txt) 238 for x in lines: 239 x=x.strip() 240 if not x or x.startswith('#')or x.find('=')<0: 241 continue 242 tmp=x.split('=') 243 tbl[tmp[0].strip()]='='.join(tmp[1:]).strip() 244 return tbl 245 def split_path(path): 248 def split_path_unix(path): 246 249 return path.split('/') 247 250 def split_path_cygwin(path): … … 262 265 elif is_win32: 263 266 split_path=split_path_win32 267 else: 268 split_path=split_path_unix 264 269 split_path.__doc__=""" 265 270 Split a path by / or \\. This function is not like os.path.split … … 276 281 if not os.path.isdir(path): 277 282 raise Errors.WafError('Cannot create the folder %r'%path,ex=e) 283 def check_exe(name,env=None): 284 if not name: 285 raise ValueError('Cannot execute an empty string!') 286 def is_exe(fpath): 287 return os.path.isfile(fpath)and os.access(fpath,os.X_OK) 288 fpath,fname=os.path.split(name) 289 if fpath and is_exe(name): 290 return os.path.abspath(name) 291 else: 292 env=env or os.environ 293 for path in env["PATH"].split(os.pathsep): 294 path=path.strip('"') 295 exe_file=os.path.join(path,name) 296 if is_exe(exe_file): 297 return os.path.abspath(exe_file) 298 return None 278 299 def def_attrs(cls,**kw): 279 300 for k,v in kw.items(): … … 281 302 setattr(cls,k,v) 282 303 def quote_define_name(s): 283 fu=re.compile("[^a-zA-Z0-9]").sub("_",s) 304 fu=re.sub('[^a-zA-Z0-9]','_',s) 305 fu=re.sub('_+','_',fu) 284 306 fu=fu.upper() 285 307 return fu … … 337 359 if s=='powerpc': 338 360 return'darwin' 339 if s=='win32'or s.endswith('os2')and s!='sunos2':return s 361 if s=='win32'or s=='os2': 362 return s 340 363 return re.split('\d+$',s)[0] 341 364 def nada(*k,**kw): … … 346 369 def __str__(self): 347 370 delta=datetime.datetime.utcnow()-self.start_time 348 days= int(delta.days)349 hours =delta.seconds//3600350 minutes =(delta.seconds-hours*3600)//60351 seconds =delta.seconds-hours*3600-minutes*60+float(delta.microseconds)/1000/1000371 days=delta.days 372 hours,rem=divmod(delta.seconds,3600) 373 minutes,seconds=divmod(rem,60) 374 seconds+=delta.microseconds*1e-6 352 375 result='' 353 376 if days: … … 411 434 if os.path.isfile(result): 412 435 return result 436 def lib64(): 437 if os.sep=='/': 438 is_64=platform.architecture()[0]=='64bit' 439 if os.path.exists('/usr/lib64')and not os.path.exists('/usr/lib32'): 440 return'64'if is_64 else'' 441 else: 442 return''if is_64 else'32' 443 return'' -
waflib/ansiterm.py
r5525507 r904702d 3 3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file 4 4 5 import sys,os 5 import os,re,sys 6 from waflib.Utils import threading 7 wlock=threading.Lock() 6 8 try: 7 if not(sys.stderr.isatty()and sys.stdout.isatty()): 8 raise ValueError('not a tty') 9 from ctypes import Structure,windll,c_short,c_ushort,c_ulong,c_int,byref,POINTER,c_long,c_char 9 from ctypes import Structure,windll,c_short,c_ushort,c_ulong,c_int,byref,c_wchar,POINTER,c_long 10 except ImportError: 11 class AnsiTerm(object): 12 def __init__(self,stream): 13 self.stream=stream 14 try: 15 self.errors=self.stream.errors 16 except AttributeError: 17 pass 18 self.encoding=self.stream.encoding 19 def write(self,txt): 20 try: 21 wlock.acquire() 22 self.stream.write(txt) 23 self.stream.flush() 24 finally: 25 wlock.release() 26 def fileno(self): 27 return self.stream.fileno() 28 def flush(self): 29 self.stream.flush() 30 def isatty(self): 31 return self.stream.isatty() 32 else: 10 33 class COORD(Structure): 11 34 _fields_=[("X",c_short),("Y",c_short)] … … 13 36 _fields_=[("Left",c_short),("Top",c_short),("Right",c_short),("Bottom",c_short)] 14 37 class CONSOLE_SCREEN_BUFFER_INFO(Structure): 15 _fields_=[("Size",COORD),("CursorPosition",COORD),("Attributes",c_ short),("Window",SMALL_RECT),("MaximumWindowSize",COORD)]38 _fields_=[("Size",COORD),("CursorPosition",COORD),("Attributes",c_ushort),("Window",SMALL_RECT),("MaximumWindowSize",COORD)] 16 39 class CONSOLE_CURSOR_INFO(Structure): 17 40 _fields_=[('dwSize',c_ulong),('bVisible',c_int)] 41 try: 42 _type=unicode 43 except NameError: 44 _type=str 45 to_int=lambda number,default:number and int(number)or default 46 STD_OUTPUT_HANDLE=-11 47 STD_ERROR_HANDLE=-12 18 48 windll.kernel32.GetStdHandle.argtypes=[c_ulong] 19 49 windll.kernel32.GetStdHandle.restype=c_ulong … … 22 52 windll.kernel32.SetConsoleTextAttribute.argtypes=[c_ulong,c_ushort] 23 53 windll.kernel32.SetConsoleTextAttribute.restype=c_long 24 windll.kernel32.FillConsoleOutputCharacter A.argtypes=[c_ulong,c_char,c_ulong,POINTER(COORD),POINTER(c_ulong)]25 windll.kernel32.FillConsoleOutputCharacter A.restype=c_long54 windll.kernel32.FillConsoleOutputCharacterW.argtypes=[c_ulong,c_wchar,c_ulong,POINTER(COORD),POINTER(c_ulong)] 55 windll.kernel32.FillConsoleOutputCharacterW.restype=c_long 26 56 windll.kernel32.FillConsoleOutputAttribute.argtypes=[c_ulong,c_ushort,c_ulong,POINTER(COORD),POINTER(c_ulong)] 27 57 windll.kernel32.FillConsoleOutputAttribute.restype=c_long … … 30 60 windll.kernel32.SetConsoleCursorInfo.argtypes=[c_ulong,POINTER(CONSOLE_CURSOR_INFO)] 31 61 windll.kernel32.SetConsoleCursorInfo.restype=c_long 32 sbinfo=CONSOLE_SCREEN_BUFFER_INFO()33 csinfo=CONSOLE_CURSOR_INFO()34 hconsole=windll.kernel32.GetStdHandle(-11)35 windll.kernel32.GetConsoleScreenBufferInfo(hconsole,byref(sbinfo))36 if sbinfo.Size.X<9 or sbinfo.Size.Y<9:raise ValueError('small console')37 windll.kernel32.GetConsoleCursorInfo(hconsole,byref(csinfo))38 except Exception:39 pass40 else:41 import re,threading42 is_vista=getattr(sys,"getwindowsversion",None)and sys.getwindowsversion()[0]>=643 try:44 _type=unicode45 except NameError:46 _type=str47 to_int=lambda number,default:number and int(number)or default48 wlock=threading.Lock()49 STD_OUTPUT_HANDLE=-1150 STD_ERROR_HANDLE=-1251 62 class AnsiTerm(object): 52 def __init__(self): 53 self.encoding=sys.stdout.encoding 54 self.hconsole=windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE) 63 def __init__(self,s): 64 self.stream=s 65 try: 66 self.errors=s.errors 67 except AttributeError: 68 pass 69 self.encoding=s.encoding 55 70 self.cursor_history=[] 56 self.orig_sbinfo=CONSOLE_SCREEN_BUFFER_INFO() 57 self.orig_csinfo=CONSOLE_CURSOR_INFO() 58 windll.kernel32.GetConsoleScreenBufferInfo(self.hconsole,byref(self.orig_sbinfo)) 59 windll.kernel32.GetConsoleCursorInfo(hconsole,byref(self.orig_csinfo)) 71 handle=(s.fileno()==2)and STD_ERROR_HANDLE or STD_OUTPUT_HANDLE 72 self.hconsole=windll.kernel32.GetStdHandle(handle) 73 self._sbinfo=CONSOLE_SCREEN_BUFFER_INFO() 74 self._csinfo=CONSOLE_CURSOR_INFO() 75 windll.kernel32.GetConsoleCursorInfo(self.hconsole,byref(self._csinfo)) 76 self._orig_sbinfo=CONSOLE_SCREEN_BUFFER_INFO() 77 r=windll.kernel32.GetConsoleScreenBufferInfo(self.hconsole,byref(self._orig_sbinfo)) 78 self._isatty=r==1 60 79 def screen_buffer_info(self): 61 sbinfo=CONSOLE_SCREEN_BUFFER_INFO() 62 windll.kernel32.GetConsoleScreenBufferInfo(self.hconsole,byref(sbinfo)) 63 return sbinfo 80 windll.kernel32.GetConsoleScreenBufferInfo(self.hconsole,byref(self._sbinfo)) 81 return self._sbinfo 64 82 def clear_line(self,param): 65 83 mode=param and int(param)or 0 … … 75 93 line_length=sbinfo.Size.X-sbinfo.CursorPosition.X 76 94 chars_written=c_ulong() 77 windll.kernel32.FillConsoleOutputCharacter A(self.hconsole,c_char(' '),line_length,line_start,byref(chars_written))95 windll.kernel32.FillConsoleOutputCharacterW(self.hconsole,c_wchar(' '),line_length,line_start,byref(chars_written)) 78 96 windll.kernel32.FillConsoleOutputAttribute(self.hconsole,sbinfo.Attributes,line_length,line_start,byref(chars_written)) 79 97 def clear_screen(self,param): … … 91 109 clear_length=((sbinfo.Size.X-sbinfo.CursorPosition.X)+sbinfo.Size.X*(sbinfo.Size.Y-sbinfo.CursorPosition.Y)) 92 110 chars_written=c_ulong() 93 windll.kernel32.FillConsoleOutputCharacter A(self.hconsole,c_char(' '),clear_length,clear_start,byref(chars_written))111 windll.kernel32.FillConsoleOutputCharacterW(self.hconsole,c_wchar(' '),clear_length,clear_start,byref(chars_written)) 94 112 windll.kernel32.FillConsoleOutputAttribute(self.hconsole,sbinfo.Attributes,clear_length,clear_start,byref(chars_written)) 95 113 def push_cursor(self,param): … … 134 152 def set_color(self,param): 135 153 cols=param.split(';') 136 sbinfo=CONSOLE_SCREEN_BUFFER_INFO() 137 windll.kernel32.GetConsoleScreenBufferInfo(self.hconsole,byref(sbinfo)) 154 sbinfo=self.screen_buffer_info() 138 155 attr=sbinfo.Attributes 139 156 for c in cols: 140 if is_vista: 141 c=int(c) 142 else: 143 c=to_int(c,0) 157 c=to_int(c,0) 144 158 if 29<c<38: 145 159 attr=(attr&0xfff0)|self.rgb2bgr(c-30) … … 147 161 attr=(attr&0xff0f)|(self.rgb2bgr(c-40)<<4) 148 162 elif c==0: 149 attr=self. orig_sbinfo.Attributes163 attr=self._orig_sbinfo.Attributes 150 164 elif c==1: 151 165 attr|=0x08 … … 156 170 windll.kernel32.SetConsoleTextAttribute(self.hconsole,attr) 157 171 def show_cursor(self,param): 158 csinfo.bVisible=1159 windll.kernel32.SetConsoleCursorInfo(self.hconsole,byref( csinfo))172 self._csinfo.bVisible=1 173 windll.kernel32.SetConsoleCursorInfo(self.hconsole,byref(self._csinfo)) 160 174 def hide_cursor(self,param): 161 csinfo.bVisible=0162 windll.kernel32.SetConsoleCursorInfo(self.hconsole,byref( csinfo))175 self._csinfo.bVisible=0 176 windll.kernel32.SetConsoleCursorInfo(self.hconsole,byref(self._csinfo)) 163 177 ansi_command_table={'A':move_up,'B':move_down,'C':move_right,'D':move_left,'E':next_line,'F':prev_line,'G':set_column,'H':set_cursor,'f':set_cursor,'J':clear_screen,'K':clear_line,'h':show_cursor,'l':hide_cursor,'m':set_color,'s':push_cursor,'u':pop_cursor,} 164 178 ansi_tokens=re.compile('(?:\x1b\[([0-9?;]*)([a-zA-Z])|([^\x1b]+))') … … 166 180 try: 167 181 wlock.acquire() 168 for param,cmd,txt in self.ansi_tokens.findall(text): 169 if cmd: 170 cmd_func=self.ansi_command_table.get(cmd) 171 if cmd_func: 172 cmd_func(self,param) 173 else: 174 self.writeconsole(txt) 182 if self._isatty: 183 for param,cmd,txt in self.ansi_tokens.findall(text): 184 if cmd: 185 cmd_func=self.ansi_command_table.get(cmd) 186 if cmd_func: 187 cmd_func(self,param) 188 else: 189 self.writeconsole(txt) 190 else: 191 self.stream.write(text) 175 192 finally: 176 193 wlock.release() … … 180 197 if isinstance(txt,_type): 181 198 writeconsole=windll.kernel32.WriteConsoleW 182 TINY_STEP=3000 183 for x in range(0,len(txt),TINY_STEP): 184 tiny=txt[x:x+TINY_STEP] 185 writeconsole(self.hconsole,tiny,len(tiny),byref(chars_written),None) 199 done=0 200 todo=len(txt) 201 chunk=32<<10 202 while todo!=0: 203 doing=min(chunk,todo) 204 buf=txt[done:done+doing] 205 r=writeconsole(self.hconsole,buf,doing,byref(chars_written),None) 206 if r==0: 207 chunk>>=1 208 continue 209 done+=doing 210 todo-=doing 211 def fileno(self): 212 return self.stream.fileno() 186 213 def flush(self): 187 214 pass 188 215 def isatty(self): 189 return True 190 sys.stderr=sys.stdout=AnsiTerm() 191 os.environ['TERM']='vt100' 216 return self._isatty 217 if sys.stdout.isatty()or sys.stderr.isatty(): 218 handle=sys.stdout.isatty()and STD_OUTPUT_HANDLE or STD_ERROR_HANDLE 219 console=windll.kernel32.GetStdHandle(handle) 220 sbinfo=CONSOLE_SCREEN_BUFFER_INFO() 221 def get_term_cols(): 222 windll.kernel32.GetConsoleScreenBufferInfo(console,byref(sbinfo)) 223 return sbinfo.Size.X-1 224 try: 225 import struct,fcntl,termios 226 except ImportError: 227 pass 228 else: 229 if(sys.stdout.isatty()or sys.stderr.isatty())and os.environ.get('TERM','')not in('dumb','emacs'): 230 FD=sys.stdout.isatty()and sys.stdout.fileno()or sys.stderr.fileno() 231 def fun(): 232 return struct.unpack("HHHH",fcntl.ioctl(FD,termios.TIOCGWINSZ,struct.pack("HHHH",0,0,0,0)))[1] 233 try: 234 fun() 235 except Exception ,e: 236 pass 237 else: 238 get_term_cols=fun -
waflib/extras/compat15.py
r5525507 r904702d 27 27 Build.BuildContext.is_install=0 28 28 Node.Node.relpath_gen=Node.Node.path_from 29 Utils.pproc=Utils.subprocess 30 Utils.get_term_cols=Logs.get_term_cols 31 def cmd_output(cmd,**kw): 32 silent=False 33 if'silent'in kw: 34 silent=kw['silent'] 35 del(kw['silent']) 36 if'e'in kw: 37 tmp=kw['e'] 38 del(kw['e']) 39 kw['env']=tmp 40 kw['shell']=isinstance(cmd,str) 41 kw['stdout']=Utils.subprocess.PIPE 42 if silent: 43 kw['stderr']=Utils.subprocess.PIPE 44 try: 45 p=Utils.subprocess.Popen(cmd,**kw) 46 output=p.communicate()[0] 47 except OSError ,e: 48 raise ValueError(str(e)) 49 if p.returncode: 50 if not silent: 51 msg="command execution failed: %s -> %r"%(cmd,str(output)) 52 raise ValueError(msg) 53 output='' 54 return output 55 Utils.cmd_output=cmd_output 29 56 def name_to_obj(self,s,env=None): 30 Logs.warn('compat: change "name_to_obj(name, env)" by "get_tgen_by_name(name)"') 57 if Logs.verbose: 58 Logs.warn('compat: change "name_to_obj(name, env)" by "get_tgen_by_name(name)"') 31 59 return self.get_tgen_by_name(s) 32 60 Build.BuildContext.name_to_obj=name_to_obj … … 50 78 self.all_envs[name]=env 51 79 else: 52 if fromenv:Logs.warn("The environment %s may have been configured already"%name) 80 if fromenv: 81 Logs.warn("The environment %s may have been configured already"%name) 53 82 return env 54 83 Configure.ConfigurationContext.retrieve=retrieve … … 57 86 Configure.conftest=Configure.conf 58 87 Configure.ConfigurationError=Errors.ConfigurationError 88 Utils.WafError=Errors.WafError 59 89 Options.OptionsContext.sub_options=Options.OptionsContext.recurse 60 90 Options.OptionsContext.tool_options=Context.Context.load … … 77 107 ret=eld(*k,**kw) 78 108 if'set_options'in ret.__dict__: 79 Logs.warn('compat: rename "set_options" to options') 109 if Logs.verbose: 110 Logs.warn('compat: rename "set_options" to options') 80 111 ret.options=ret.set_options 81 112 if'detect'in ret.__dict__: 82 Logs.warn('compat: rename "detect" to "configure"') 113 if Logs.verbose: 114 Logs.warn('compat: rename "detect" to "configure"') 83 115 ret.configure=ret.detect 84 116 return ret 85 117 Context.load_tool=load_tool 118 def get_curdir(self): 119 return self.path.abspath() 120 Context.Context.curdir=property(get_curdir,Utils.nada) 86 121 rev=Context.load_module 87 def load_module(path ):88 ret=rev(path )122 def load_module(path,encoding=None): 123 ret=rev(path,encoding) 89 124 if'set_options'in ret.__dict__: 90 Logs.warn('compat: rename "set_options" to "options" (%r)'%path) 125 if Logs.verbose: 126 Logs.warn('compat: rename "set_options" to "options" (%r)'%path) 91 127 ret.options=ret.set_options 92 128 if'srcdir'in ret.__dict__: 93 Logs.warn('compat: rename "srcdir" to "top" (%r)'%path) 129 if Logs.verbose: 130 Logs.warn('compat: rename "srcdir" to "top" (%r)'%path) 94 131 ret.top=ret.srcdir 95 132 if'blddir'in ret.__dict__: 96 Logs.warn('compat: rename "blddir" to "out" (%r)'%path) 133 if Logs.verbose: 134 Logs.warn('compat: rename "blddir" to "out" (%r)'%path) 97 135 ret.out=ret.blddir 98 136 return ret … … 102 140 self.features=self.to_list(self.features) 103 141 if'cc'in self.features: 104 Logs.warn('compat: the feature cc does not exist anymore (use "c")') 142 if Logs.verbose: 143 Logs.warn('compat: the feature cc does not exist anymore (use "c")') 105 144 self.features.remove('cc') 106 145 self.features.append('c') 107 146 if'cstaticlib'in self.features: 108 Logs.warn('compat: the feature cstaticlib does not exist anymore (use "cstlib" or "cxxstlib")') 147 if Logs.verbose: 148 Logs.warn('compat: the feature cstaticlib does not exist anymore (use "cstlib" or "cxxstlib")') 109 149 self.features.remove('cstaticlib') 110 150 self.features.append(('cxx'in self.features)and'cxxstlib'or'cstlib') 111 151 if getattr(self,'ccflags',None): 112 Logs.warn('compat: "ccflags" was renamed to "cflags"') 152 if Logs.verbose: 153 Logs.warn('compat: "ccflags" was renamed to "cflags"') 113 154 self.cflags=self.ccflags 114 155 return old_post(self) … … 129 170 get=self.bld.get_tgen_by_name 130 171 seen=set([]) 172 seen_uselib=set([]) 131 173 tmp=Utils.deque(names) 132 174 if tmp: 133 Logs.warn('compat: "uselib_local" is deprecated, replace by "use"') 175 if Logs.verbose: 176 Logs.warn('compat: "uselib_local" is deprecated, replace by "use"') 134 177 while tmp: 135 178 lib_name=tmp.popleft() … … 158 201 env.prepend_value('LIBPATH',[tmp_path]) 159 202 for v in self.to_list(getattr(y,'uselib',[])): 160 if not env['STLIB_'+v]: 161 if not v in self.uselib: 162 self.uselib.insert(0,v) 203 if v not in seen_uselib: 204 seen_uselib.add(v) 205 if not env['STLIB_'+v]: 206 if not v in self.uselib: 207 self.uselib.insert(0,v) 163 208 if getattr(y,'export_includes',None): 164 209 self.includes.extend(y.to_incnodes(y.export_includes)) … … 219 264 self.export_includes=val 220 265 TaskGen.task_gen.export_incdirs=property(None,set_incdirs) 266 def install_dir(self,path): 267 if not path: 268 return[] 269 destpath=Utils.subst_vars(path,self.env) 270 if self.is_install>0: 271 Logs.info('* creating %s'%destpath) 272 Utils.check_dir(destpath) 273 elif self.is_install<0: 274 Logs.info('* removing %s'%destpath) 275 try: 276 os.remove(destpath) 277 except OSError: 278 pass 279 Build.BuildContext.install_dir=install_dir
Note: See TracChangeset
for help on using the changeset viewer.