Commit ad97104d authored by nextime's avatar nextime

first commit

parents
argv = ['./waf', 'configure']
blddir = '/home/nextime/Microchip/python/PyBindGen/pybindgen-0.15.0/build'
commands = {'dist': 0, 'configure': True, 'distcheck': 0, 'install': 0, 'build': 0, 'clean': 0, 'distclean': 0, 'check': 0, 'uninstall': 0}
cwd = '/home/nextime/Microchip/python/PyBindGen/pybindgen-0.15.0'
environ = {'PYTHONPATH': '/home/nextime/Microchip/python/PyBindGen/pybindgen-0.15.0', 'SSH_CLIENT': '192.168.4.4 44028 22', 'PRINTER': 'HP_HP_Color_LaserJet_CP1515n', 'LOGNAME': 'nextime', 'USER': 'nextime', 'HOME': '/home/nextime', 'PATH': '/home/nextime/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/home/nextime/Microchip/bin:/usr/hitech/picc-18/pro/9.63PL3/bin', '_': './waf', 'SSH_CONNECTION': '192.168.4.4 44028 192.168.4.2 22', 'LANG': 'en_US.UTF-8', 'TERM': 'xterm', 'SHELL': '/bin/bash', 'XDG_SESSION_COOKIE': '3388004bbfef6792c52a954d0000041e-1340407338.408424-243343910', 'SHLVL': '1', 'SSH_TTY': '/dev/pts/3', 'OLDPWD': '/home/nextime/Microchip/python/PyBindGen/pybindgen-0.15.0/examples', 'HISTCONTROL': 'ignoreboth', 'PWD': '/home/nextime/Microchip/python/PyBindGen/pybindgen-0.15.0', 'MAIL': '/var/mail/nextime', 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:'}
files = ['/home/nextime/Microchip/python/PyBindGen/pybindgen-0.15.0/benchmarks/wscript', '/home/nextime/Microchip/python/PyBindGen/pybindgen-0.15.0/wscript']
hash = -505678433355082749
options = {'compile_targets': None, 'force': False, 'verbose': 0, 'nocache': False, 'progress_bar': 0, 'valgrind': False, 'destdir': '', 'keep': False, 'zones': '', 'blddir': '', 'prefix': '/usr/local/', 'examples': False, 'disable_pygccxml': False, 'pyo': 1, 'srcdir': '', 'jobs': 8, 'pyc': 1, 'check_cxx_compiler': 'g++ icpc sunc++', 'check_c_compiler': 'gcc icc suncc', 'build_profile': 'default'}
srcdir = '/home/nextime/Microchip/python/PyBindGen/pybindgen-0.15.0'
#! /usr/bin/env python
# encoding: utf-8
import os,shlex,sys,time
try:import cPickle
except ImportError:import pickle as cPickle
import Environment,Utils,Options
from Logs import warn
from Constants import*
conf_template='''# project %(app)s configured on %(now)s by
# waf %(wafver)s (abi %(abi)s, python %(pyver)x on %(systype)s)
# using %(args)s
#
'''
class ConfigurationError(Utils.WscriptError):
pass
autoconfig=False
def find_file(filename,path_list):
for directory in Utils.to_list(path_list):
if os.path.exists(os.path.join(directory,filename)):
return directory
return''
def find_program_impl(env,filename,path_list=[],var=None,environ=None):
if not environ:
environ=os.environ
try:path_list=path_list.split()
except AttributeError:pass
if var:
if env[var]:return env[var]
if var in environ:env[var]=environ[var]
if not path_list:path_list=environ.get('PATH','').split(os.pathsep)
ext=(Options.platform=='win32')and'.exe,.com,.bat,.cmd'or''
for y in[filename+x for x in ext.split(',')]:
for directory in path_list:
x=os.path.join(directory,y)
if os.path.isfile(x):
if var:env[var]=x
return x
return''
class ConfigurationContext(Utils.Context):
tests={}
error_handlers=[]
def __init__(self,env=None,blddir='',srcdir=''):
self.env=None
self.envname=''
self.environ=dict(os.environ)
self.line_just=40
self.blddir=blddir
self.srcdir=srcdir
self.all_envs={}
self.cwd=self.curdir=os.getcwd()
self.tools=[]
self.setenv(DEFAULT)
self.lastprog=''
self.hash=0
self.files=[]
self.tool_cache=[]
if self.blddir:
self.post_init()
def post_init(self):
self.cachedir=os.path.join(self.blddir,CACHE_DIR)
path=os.path.join(self.blddir,WAF_CONFIG_LOG)
try:os.unlink(path)
except(OSError,IOError):pass
try:
self.log=open(path,'w')
except(OSError,IOError):
self.fatal('could not open %r for writing'%path)
app=getattr(Utils.g_module,'APPNAME','')
if app:
ver=getattr(Utils.g_module,'VERSION','')
if ver:
app="%s (%s)"%(app,ver)
now=time.ctime()
pyver=sys.hexversion
systype=sys.platform
args=" ".join(sys.argv)
wafver=WAFVERSION
abi=ABI
self.log.write(conf_template%vars())
def __del__(self):
if hasattr(self,'log')and self.log:
self.log.close()
def fatal(self,msg):
raise ConfigurationError(msg)
def check_tool(self,input,tooldir=None,funs=None):
tools=Utils.to_list(input)
if tooldir:tooldir=Utils.to_list(tooldir)
for tool in tools:
tool=tool.replace('++','xx')
if tool=='java':tool='javaw'
mag=(tool,id(self.env),funs)
if mag in self.tool_cache:
continue
self.tool_cache.append(mag)
module=Utils.load_tool(tool,tooldir)
func=getattr(module,'detect',None)
if func:
if type(func)is type(find_file):func(self)
else:self.eval_rules(funs or func)
self.tools.append({'tool':tool,'tooldir':tooldir,'funs':funs})
def sub_config(self,k):
self.recurse(k,name='configure')
def pre_recurse(self,name_or_mod,path,nexdir):
return{'conf':self,'ctx':self}
def post_recurse(self,name_or_mod,path,nexdir):
if not autoconfig:
return
self.hash=hash((self.hash,getattr(name_or_mod,'waf_hash_val',name_or_mod)))
self.files.append(path)
def store(self,file=''):
if not os.path.isdir(self.cachedir):
os.makedirs(self.cachedir)
if not file:
file=open(os.path.join(self.cachedir,'build.config.py'),'w')
file.write('version = 0x%x\n'%HEXVERSION)
file.write('tools = %r\n'%self.tools)
file.close()
if not self.all_envs:
self.fatal('nothing to store in the configuration context!')
for key in self.all_envs:
tmpenv=self.all_envs[key]
tmpenv.store(os.path.join(self.cachedir,key+CACHE_SUFFIX))
def set_env_name(self,name,env):
self.all_envs[name]=env
return env
def retrieve(self,name,fromenv=None):
try:
env=self.all_envs[name]
except KeyError:
env=Environment.Environment()
env['PREFIX']=os.path.abspath(os.path.expanduser(Options.options.prefix))
self.all_envs[name]=env
else:
if fromenv:warn("The environment %s may have been configured already"%name)
return env
def setenv(self,name):
self.env=self.retrieve(name)
self.envname=name
def add_os_flags(self,var,dest=None):
try:self.env.append_value(dest or var,Utils.to_list(self.environ[var]))
except KeyError:pass
def check_message_1(self,sr):
self.line_just=max(self.line_just,len(sr))
self.log.write(sr+'\n\n')
Utils.pprint('NORMAL',"%s :"%sr.ljust(self.line_just),sep='')
def check_message_2(self,sr,color='GREEN'):
Utils.pprint(color,sr)
def check_message(self,th,msg,state,option=''):
sr='Checking for %s %s'%(th,msg)
self.check_message_1(sr)
p=self.check_message_2
if state:p('ok '+option)
else:p('not found','YELLOW')
def check_message_custom(self,th,msg,custom,option='',color='PINK'):
sr='Checking for %s %s'%(th,msg)
self.check_message_1(sr)
self.check_message_2(custom,color)
def find_program(self,filename,path_list=[],var=None,mandatory=False):
ret=None
if var:
if self.env[var]:
ret=self.env[var]
elif var in os.environ:
ret=os.environ[var]
if not isinstance(filename,list):filename=[filename]
if not ret:
for x in filename:
ret=find_program_impl(self.env,x,path_list,var,environ=self.environ)
if ret:break
self.check_message('program',','.join(filename),ret,ret)
self.log.write('find program=%r paths=%r var=%r -> %r\n\n'%(filename,path_list,var,ret))
if not ret and mandatory:
self.fatal('The program %r could not be found'%filename)
if var:
self.env[var]=ret
return ret
def cmd_to_list(self,cmd):
if isinstance(cmd,str)and cmd.find(' '):
try:
os.stat(cmd)
except OSError:
return shlex.split(cmd)
else:
return[cmd]
return cmd
def __getattr__(self,name):
r=self.__class__.__dict__.get(name,None)
if r:return r
if name and name.startswith('require_'):
for k in['check_','find_']:
n=name.replace('require_',k)
ret=self.__class__.__dict__.get(n,None)
if ret:
def run(*k,**kw):
r=ret(self,*k,**kw)
if not r:
self.fatal('requirement failure')
return r
return run
self.fatal('No such method %r'%name)
def eval_rules(self,rules):
self.rules=Utils.to_list(rules)
for x in self.rules:
f=getattr(self,x)
if not f:self.fatal("No such method '%s'."%x)
try:
f()
except Exception,e:
ret=self.err_handler(x,e)
if ret==BREAK:
break
elif ret==CONTINUE:
continue
else:
self.fatal(e)
def err_handler(self,fun,error):
pass
def conf(f):
setattr(ConfigurationContext,f.__name__,f)
return f
def conftest(f):
ConfigurationContext.tests[f.__name__]=f
return conf(f)
#! /usr/bin/env python
# encoding: utf-8
HEXVERSION=0x10509
WAFVERSION="1.5.9"
WAFREVISION="6626:6639M"
ABI=7
O644=420
O755=493
MAXJOBS=99999999
CACHE_DIR='c4che'
CACHE_SUFFIX='.cache.py'
DBFILE='.wafpickle-%d'%ABI
WSCRIPT_FILE='wscript'
WSCRIPT_BUILD_FILE='wscript_build'
WAF_CONFIG_LOG='config.log'
WAF_CONFIG_H='config.h'
SIG_NIL='iluvcuteoverload'
VARIANT='_VARIANT_'
DEFAULT='default'
SRCDIR='srcdir'
BLDDIR='blddir'
APPNAME='APPNAME'
VERSION='VERSION'
DEFINES='defines'
UNDEFINED=()
BREAK="break"
CONTINUE="continue"
JOBCONTROL="JOBCONTROL"
MAXPARALLEL="MAXPARALLEL"
NORMAL="NORMAL"
NOT_RUN=0
MISSING=1
CRASHED=2
EXCEPTION=3
SKIPPED=8
SUCCESS=9
ASK_LATER=-1
SKIP_ME=-2
RUN_ME=-3
LOG_FORMAT="%(asctime)s %(c1)s%(zone)s%(c2)s %(message)s"
HOUR_FORMAT="%H:%M:%S"
TEST_OK=True
CFG_FILES='cfg_files'
INSTALL=1337
UNINSTALL=-1337
#! /usr/bin/env python
# encoding: utf-8
import sys
if sys.hexversion < 0x020400f0: from sets import Set as set
import os,copy,re
import Logs,Options,Utils
from Constants import*
re_imp=re.compile('^(#)*?([^#=]*?)\ =\ (.*?)$',re.M)
class Environment(object):
__slots__=("table","parent")
def __init__(self,filename=None):
self.table={}
if filename:
self.load(filename)
def __contains__(self,key):
if key in self.table:return True
try:return self.parent.__contains__(key)
except AttributeError:return False
def __str__(self):
keys=set()
cur=self
while cur:
keys.update(cur.table.keys())
cur=getattr(cur,'parent',None)
keys=list(keys)
keys.sort()
return"\n".join(["%r %r"%(x,self.__getitem__(x))for x in keys])
def __getitem__(self,key):
try:
while 1:
x=self.table.get(key,None)
if not x is None:
return x
self=self.parent
except AttributeError:
return[]
def __setitem__(self,key,value):
self.table[key]=value
def __delitem__(self,key,value):
del self.table[key]
def set_variant(self,name):
self.table[VARIANT]=name
def variant(self):
try:
while 1:
x=self.table.get(VARIANT,None)
if not x is None:
return x
self=self.parent
except AttributeError:
return DEFAULT
def copy(self):
newenv=Environment()
newenv.parent=self
return newenv
def detach(self):
tbl=self.get_merged_dict()
try:
delattr(self,'parent')
except AttributeError:
pass
else:
keys=tbl.keys()
for x in keys:
tbl[x]=copy.copy(tbl[x])
self.table=tbl
def get_flat(self,key):
s=self[key]
if isinstance(s,str):return s
return' '.join(s)
def _get_list_value_for_modification(self,key):
try:
value=self.table[key]
except KeyError:
try:value=self.parent[key]
except AttributeError:value=[]
if isinstance(value,list):
value=value[:]
else:
value=[value]
else:
if not isinstance(value,list):
value=[value]
self.table[key]=value
return value
def append_value(self,var,value):
current_value=self._get_list_value_for_modification(var)
if isinstance(value,list):
current_value.extend(value)
else:
current_value.append(value)
def prepend_value(self,var,value):
current_value=self._get_list_value_for_modification(var)
if isinstance(value,list):
current_value=value+current_value
self.table[var]=current_value
else:
current_value.insert(0,value)
def append_unique(self,var,value):
current_value=self._get_list_value_for_modification(var)
if isinstance(value,list):
for value_item in value:
if value_item not in current_value:
current_value.append(value_item)
else:
if value not in current_value:
current_value.append(value)
def get_merged_dict(self):
table_list=[]
env=self
while 1:
table_list.insert(0,env.table)
try:env=env.parent
except AttributeError:break
merged_table={}
for table in table_list:
merged_table.update(table)
return merged_table
def store(self,filename):
file=open(filename,'w')
merged_table=self.get_merged_dict()
keys=list(merged_table.keys())
keys.sort()
for k in keys:file.write('%s = %r\n'%(k,merged_table[k]))
file.close()
def load(self,filename):
tbl=self.table
code=Utils.readf(filename)
for m in re_imp.finditer(code):
g=m.group
tbl[g(2)]=eval(g(3))
Logs.debug('env: %s'%str(self.table))
def get_destdir(self):
if self.__getitem__('NOINSTALL'):return''
return Options.options.destdir
def update(self,d):
for k,v in d.iteritems():
self[k]=v
def __getattr__(self,name):
if name in self.__slots__:
return object.__getattr__(self,name)
else:
return self[name]
def __setattr__(self,name,value):
if name in self.__slots__:
object.__setattr__(self,name,value)
else:
self[name]=value
def __detattr__(self,name):
if name in self.__slots__:
object.__detattr__(self,name)
else:
del self[name]
#! /usr/bin/env python
# encoding: utf-8
import os,re,logging,traceback,sys
from Constants import*
zones=''
verbose=0
colors_lst={'USE':True,'BOLD':'\x1b[01;1m','RED':'\x1b[01;91m','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',}
got_tty=not os.environ.get('TERM','dumb')in['dumb','emacs']
if got_tty:
try:
got_tty=sys.stderr.isatty()
except AttributeError:
got_tty=False
import Utils
if not got_tty or sys.platform=='win32'or'NOCOLOR'in os.environ:
colors_lst['USE']=False
def get_color(cl):
if not colors_lst['USE']:return''
return colors_lst.get(cl,'')
class foo(object):
def __getattr__(self,a):
return get_color(a)
def __call__(self,a):
return get_color(a)
colors=foo()
re_log=re.compile(r'(\w+): (.*)',re.M)
class log_filter(logging.Filter):
def __init__(self,name=None):
pass
def filter(self,rec):
rec.c1=colors.PINK
rec.c2=colors.NORMAL
rec.zone=rec.module
if rec.levelno>=logging.INFO:
if rec.levelno>=logging.ERROR:
rec.c1=colors.RED
elif rec.levelno>=logging.WARNING:
rec.c1=colors.YELLOW
else:
rec.c1=colors.GREEN
return True
zone=''
m=re_log.match(rec.msg)
if m:
zone=rec.zone=m.group(1)
rec.msg=m.group(2)
if zones:
return getattr(rec,'zone','')in zones or'*'in zones
elif not verbose>2:
return False
return True
class formatter(logging.Formatter):
def __init__(self):
logging.Formatter.__init__(self,LOG_FORMAT,HOUR_FORMAT)
def format(self,rec):
if rec.levelno>=logging.WARNING or rec.levelno==logging.INFO:
try:
return'%s%s%s'%(rec.c1,rec.msg.decode('utf-8'),rec.c2)
except:
return rec.c1+rec.msg+rec.c2
return logging.Formatter.format(self,rec)
def debug(msg):
if verbose:
msg=msg.replace('\n',' ')
logging.debug(msg)
def error(msg):
logging.error(msg)
if verbose>1:
if isinstance(msg,Utils.WafError):
st=msg.stack
else:
st=traceback.extract_stack()
if st:
st=st[:-1]
buf=[]
for filename,lineno,name,line in st:
buf.append(' File "%s", line %d, in %s'%(filename,lineno,name))
if line:
buf.append(' %s'%line.strip())
if buf:logging.error("\n".join(buf))
warn=logging.warn
info=logging.info
def init_log():
log=logging.getLogger()
log.handlers=[]
log.filters=[]
hdlr=logging.StreamHandler()
hdlr.setFormatter(formatter())
log.addHandler(hdlr)
log.addFilter(log_filter())
log.setLevel(logging.DEBUG)
init_log()
#! /usr/bin/env python
# encoding: utf-8
import os,sys,imp,types,tempfile,optparse
import Logs,Utils
from Constants import*
cmds='distclean configure build install clean uninstall check dist distcheck'.split()
commands={}
is_install=False
options={}
arg_line=[]
launch_dir=''
tooldir=''
lockfile=os.environ.get('WAFLOCK','.lock-wscript')
try:cache_global=os.path.abspath(os.environ['WAFCACHE'])
except KeyError:cache_global=''
platform=Utils.unversioned_sys_platform()
conf_file='conf-runs-%s-%d.pickle'%(platform,ABI)
default_prefix=os.environ.get('PREFIX')
if not default_prefix:
if platform=='win32':default_prefix=tempfile.gettempdir()
else:default_prefix='/usr/local/'
default_jobs=os.environ.get('JOBS',-1)
if default_jobs<1:
try:
if'SC_NPROCESSORS_ONLN'in os.sysconf_names:
default_jobs=os.sysconf('SC_NPROCESSORS_ONLN')
else:
default_jobs=int(Utils.cmd_output(['sysctl','-n','hw.ncpu']))
except:
if os.name=='java':
from java.lang import Runtime
default_jobs=Runtime.getRuntime().availableProcessors()
else:
default_jobs=int(os.environ.get('NUMBER_OF_PROCESSORS',1))
default_destdir=os.environ.get('DESTDIR','')
def get_usage(self):
cmds_str=[]
module=Utils.g_module
if module:
tbl=module.__dict__
keys=list(tbl.keys())
keys.sort()
if'build'in tbl:
if not module.build.__doc__:
module.build.__doc__='builds the project'
if'configure'in tbl:
if not module.configure.__doc__:
module.configure.__doc__='configures the project'
ban=['set_options','init','shutdown']
optlst=[x for x in keys if not x in ban and type(tbl[x])is type(parse_args_impl)and tbl[x].__doc__ and not x.startswith('_')]
just=max([len(x)for x in optlst])
for x in optlst:
cmds_str.append(' %s: %s'%(x.ljust(just),tbl[x].__doc__))
ret='\n'.join(cmds_str)
else:
ret=' '.join(cmds)
return'''waf [command] [options]
Main commands (example: ./waf build -j4)
%s
'''%ret
setattr(optparse.OptionParser,'get_usage',get_usage)
def create_parser(module=None):
Logs.debug('options: create_parser is called')
parser=optparse.OptionParser(conflict_handler="resolve",version='waf %s (%s)'%(WAFVERSION,WAFREVISION))
parser.formatter.width=Utils.get_term_cols()
p=parser.add_option
p('-j','--jobs',type='int',default=default_jobs,help='amount of parallel jobs (%r)'%default_jobs,dest='jobs')
p('-k','--keep',action='store_true',default=False,help='keep running happily on independent task groups',dest='keep')
p('-v','--verbose',action='count',default=0,help='verbosity level -v -vv or -vvv [default: 0]',dest='verbose')
p('--nocache',action='store_true',default=False,help='ignore the WAFCACHE (if set)',dest='nocache')
p('--zones',action='store',default='',help='debugging zones (task_gen, deps, tasks, etc)',dest='zones')
p('-p','--progress',action='count',default=0,help='-p: progress bar; -pp: ide output',dest='progress_bar')
p('--targets',action='store',default='',help='build given task generators, e.g. "target1,target2"',dest='compile_targets')
gr=optparse.OptionGroup(parser,'configuration options')
parser.add_option_group(gr)
gr.add_option('-b','--blddir',action='store',default='',help='build dir for the project (configuration)',dest='blddir')
gr.add_option('-s','--srcdir',action='store',default='',help='src dir for the project (configuration)',dest='srcdir')
gr.add_option('--prefix',help='installation prefix (configuration) [default: %r]'%default_prefix,default=default_prefix,dest='prefix')
gr=optparse.OptionGroup(parser,'installation options')
parser.add_option_group(gr)
gr.add_option('--destdir',help='installation root [default: %r]'%default_destdir,default=default_destdir,dest='destdir')
gr.add_option('-f','--force',action='store_true',default=False,help='force file installation',dest='force')
return parser
def parse_args_impl(parser,_args=None):
global options,commands,arg_line
(options,args)=parser.parse_args(args=_args)
arg_line=args
commands={}
for var in cmds:commands[var]=0
if not args:
commands['build']=1
args.append('build')
for arg in args:
commands[arg]=True
if'check'in args:
idx=args.index('check')
try:
bidx=args.index('build')
if bidx>idx:
raise ValueError('build before check')
except ValueError,e:
args.insert(idx,'build')
if args[0]!='init':
args.insert(0,'init')
if options.keep:options.jobs=1
if options.jobs<1:options.jobs=1
if'install'in sys.argv or'uninstall'in sys.argv:
options.destdir=options.destdir and os.path.abspath(os.path.expanduser(options.destdir))
Logs.verbose=options.verbose
Logs.init_log()
if options.zones:
Logs.zones=options.zones.split(',')
if not Logs.verbose:Logs.verbose=1
elif Logs.verbose>0:
Logs.zones=['runner']
if Logs.verbose>2:
Logs.zones=['*']
class Handler(Utils.Context):
parser=None
def __init__(self,module=None):
self.parser=create_parser(module)
self.cwd=os.getcwd()
Handler.parser=self
def add_option(self,*k,**kw):
self.parser.add_option(*k,**kw)
def add_option_group(self,*k,**kw):
return self.parser.add_option_group(*k,**kw)
def get_option_group(self,opt_str):
return self.parser.get_option_group(opt_str)
def sub_options(self,*k,**kw):
if not k:raise Utils.WscriptError('folder expected')
self.recurse(k[0],name='set_options')
def tool_options(self,*k,**kw):
if not k[0]:
raise Utils.WscriptError('invalid tool_options call %r %r'%(k,kw))
tools=Utils.to_list(k[0])
path=Utils.to_list(kw.get('tdir',kw.get('tooldir',tooldir)))
for tool in tools:
tool=tool.replace('++','xx')
module=Utils.load_tool(tool,path)
try:
fun=module.set_options
except AttributeError:
pass
else:
fun(kw.get('option_group',self))
def parse_args(self,args=None):
parse_args_impl(self.parser,args)
#! /usr/bin/env python
# encoding: utf-8
import sys
if sys.hexversion < 0x020400f0: from sets import Set as set
import sys,random,time,threading,traceback
try:from Queue import Queue
except ImportError:from queue import Queue
import Build,Utils,Logs,Options
from Logs import debug,error
from Constants import*
GAP=15
run_old=threading.Thread.run
def run(*args,**kwargs):
try:
run_old(*args,**kwargs)
except(KeyboardInterrupt,SystemExit):
raise
except:
sys.excepthook(*sys.exc_info())
threading.Thread.run=run
class TaskConsumer(threading.Thread):
def __init__(self,m):
threading.Thread.__init__(self)
self.setDaemon(1)
self.master=m
self.start()
def run(self):
try:
self.loop()
except:
pass
def loop(self):
m=self.master
while 1:
tsk=m.ready.get()
if m.stop:
m.out.put(tsk)
continue
try:
tsk.generator.bld.printout(tsk.display())
if tsk.__class__.stat:ret=tsk.__class__.stat(tsk)
else:ret=tsk.call_run()
except Exception,e:
tsk.err_msg=Utils.ex_stack()
tsk.hasrun=EXCEPTION
m.error_handler(tsk)
m.out.put(tsk)
continue
if ret:
tsk.err_code=ret
tsk.hasrun=CRASHED
else:
try:
tsk.post_run()
except Utils.WafError:
pass
except Exception:
tsk.err_msg=Utils.ex_stack()
tsk.hasrun=EXCEPTION
else:
tsk.hasrun=SUCCESS
if tsk.hasrun!=SUCCESS:
m.error_handler(tsk)
m.out.put(tsk)
class Parallel(object):
def __init__(self,bld,j=2):
self.numjobs=j
self.manager=bld.task_manager
self.manager.current_group=0
self.total=self.manager.total()
self.outstanding=[]
self.maxjobs=MAXJOBS
self.frozen=[]
self.ready=Queue(0)
self.out=Queue(0)
self.count=0
self.processed=1
self.consumers=None
self.stop=False
self.error=False
def get_next(self):
if not self.outstanding:
return None
return self.outstanding.pop(0)
def postpone(self,tsk):
if random.randint(0,1):
self.frozen.insert(0,tsk)
else:
self.frozen.append(tsk)
def refill_task_list(self):
while self.count>self.numjobs+GAP or self.count>=self.maxjobs:
self.get_out()
while not self.outstanding:
if self.count:
self.get_out()
if self.frozen:
self.outstanding+=self.frozen
self.frozen=[]
elif not self.count:
(jobs,tmp)=self.manager.get_next_set()
if jobs!=None:self.maxjobs=jobs
if tmp:self.outstanding+=tmp
break
def get_out(self):
ret=self.out.get()
self.manager.add_finished(ret)
if not self.stop and getattr(ret,'more_tasks',None):
self.outstanding+=ret.more_tasks
self.total+=len(ret.more_tasks)
self.count-=1
def error_handler(self,tsk):
if not Options.options.keep:
self.stop=True
self.error=True
def start(self):
while not self.stop:
self.refill_task_list()
tsk=self.get_next()
if not tsk:
if self.count:
continue
else:
break
if tsk.hasrun:
self.processed+=1
self.manager.add_finished(tsk)
continue
try:
st=tsk.runnable_status()
except Exception,e:
tsk.err_msg=Utils.ex_stack()
tsk.hasrun=EXCEPTION
self.processed+=1
self.error_handler(tsk)
self.manager.add_finished(tsk)
continue
if st==ASK_LATER:
self.postpone(tsk)
elif st==SKIP_ME:
self.processed+=1
tsk.hasrun=SKIPPED
self.manager.add_finished(tsk)
else:
tsk.position=(self.processed,self.total)
self.count+=1
self.ready.put(tsk)
self.processed+=1
if not self.consumers:
self.consumers=[TaskConsumer(self)for i in xrange(self.numjobs)]
while self.error and self.count:
self.get_out()
assert(self.count==0 or self.stop)
#! /usr/bin/env python
# encoding: utf-8
import os,sys
import Build,TaskGen,Utils,Options,Logs,Task
from Constants import*
class unit_test(object):
def __init__(self):
self.returncode_ok=0
self.num_tests_ok=0
self.num_tests_failed=0
self.num_tests_err=0
self.total_num_tests=0
self.max_label_length=0
self.unit_tests=Utils.ordered_dict()
self.unit_test_results={}
self.unit_test_erroneous={}
self.change_to_testfile_dir=False
self.want_to_see_test_output=False
self.want_to_see_test_error=False
self.run_if_waf_does='check'
def run(self):
self.num_tests_ok=0
self.num_tests_failed=0
self.num_tests_err=0
self.total_num_tests=0
self.max_label_length=0
self.unit_tests=Utils.ordered_dict()
self.unit_test_results={}
self.unit_test_erroneous={}
ld_library_path=[]
if not Options.commands[self.run_if_waf_does]:return
for obj in Build.bld.all_task_gen:
try:
link_task=obj.link_task
except AttributeError:
pass
else:
lib_path=link_task.outputs[0].parent.abspath(obj.env)
if lib_path not in ld_library_path:
ld_library_path.append(lib_path)
unit_test=getattr(obj,'unit_test','')
if unit_test and'cprogram'in obj.features:
try:
output=obj.path
filename=os.path.join(output.abspath(obj.env),obj.target)
srcdir=output.abspath()
label=os.path.join(output.bldpath(obj.env),obj.target)
self.max_label_length=max(self.max_label_length,len(label))
self.unit_tests[label]=(filename,srcdir)
except KeyError:
pass
self.total_num_tests=len(self.unit_tests)
Utils.pprint('GREEN','Running the unit tests')
count=0
result=1
for label in self.unit_tests.allkeys:
file_and_src=self.unit_tests[label]
filename=file_and_src[0]
srcdir=file_and_src[1]
count+=1
line=Build.bld.progress_line(count,self.total_num_tests,Logs.colors.GREEN,Logs.colors.NORMAL)
if Options.options.progress_bar and line:
sys.stderr.write(line)
sys.stderr.flush()
try:
kwargs={}
kwargs['env']=os.environ.copy()
if self.change_to_testfile_dir:
kwargs['cwd']=srcdir
if not self.want_to_see_test_output:
kwargs['stdout']=Utils.pproc.PIPE
if not self.want_to_see_test_error:
kwargs['stderr']=Utils.pproc.PIPE
if ld_library_path:
v=kwargs['env']
def add_path(dct,path,var):
dct[var]=os.pathsep.join(Utils.to_list(path)+[os.environ.get(var,'')])
if sys.platform=='win32':
add_path(v,ld_library_path,'PATH')
elif sys.platform=='darwin':
add_path(v,ld_library_path,'DYLD_LIBRARY_PATH')
add_path(v,ld_library_path,'LD_LIBRARY_PATH')
else:
add_path(v,ld_library_path,'LD_LIBRARY_PATH')
pp=Utils.pproc.Popen(filename,**kwargs)
pp.wait()
result=int(pp.returncode==self.returncode_ok)
if result:
self.num_tests_ok+=1
else:
self.num_tests_failed+=1
self.unit_test_results[label]=result
self.unit_test_erroneous[label]=0
except OSError:
self.unit_test_erroneous[label]=1
self.num_tests_err+=1
except KeyboardInterrupt:
pass
if Options.options.progress_bar:sys.stdout.write(Logs.colors.cursor_on)
def print_results(self):
if not Options.commands[self.run_if_waf_does]:return
p=Utils.pprint
if self.total_num_tests==0:
p('YELLOW','No unit tests present')
return
for label in self.unit_tests.allkeys:
filename=self.unit_tests[label]
err=0
result=0
try:err=self.unit_test_erroneous[label]
except KeyError:pass
try:result=self.unit_test_results[label]
except KeyError:pass
n=self.max_label_length-len(label)
if err:n+=4
elif result:n+=7
else:n+=3
line='%s %s'%(label,'.'*n)
if err:p('RED','%sERROR'%line)
elif result:p('GREEN','%sOK'%line)
else:p('YELLOW','%sFAILED'%line)
percentage_ok=float(self.num_tests_ok)/float(self.total_num_tests)*100.0
percentage_failed=float(self.num_tests_failed)/float(self.total_num_tests)*100.0
percentage_erroneous=float(self.num_tests_err)/float(self.total_num_tests)*100.0
p('NORMAL','''
Successful tests: %i (%.1f%%)
Failed tests: %i (%.1f%%)
Erroneous tests: %i (%.1f%%)
Total number of tests: %i
'''%(self.num_tests_ok,percentage_ok,self.num_tests_failed,percentage_failed,self.num_tests_err,percentage_erroneous,self.total_num_tests))
p('GREEN','Unit tests finished')
import threading
testlock=threading.Lock()
def make_test(self):
if not'cprogram'in self.features:
Logs.error('test cannot be executed %s'%self)
return
tsk=self.create_task('utest')
tsk.set_inputs(self.link_task.outputs)
def exec_test(self):
fail=False
try:
testlock.acquire()
filename=self.inputs[0].abspath(self.env)
try:
ret=Utils.cmd_output(filename,cwd='/cygdrive/c/home/waf-1.5.8/demos/unit_test/tests/test0')
except Exception,e:
fail=True
ret=""
else:
pass
stats=getattr(self.generator.bld,'utest_results',[])
stats.append((filename,fail,ret))
self.generator.bld.utest_results=stats
testlock.release()
except Exception,e:
print e
cls=Task.task_type_from_func('utest',func=exec_test,color='RED',ext_in='.bin')
old=cls.runnable_status
def test_status(self):
if getattr(Options.options,'all_tests',False):
return RUN_ME
return old(self)
cls.runnable_status=test_status
cls.quiet=1
def summary(bld):
lst=getattr(bld,'utest_results',[])
if lst:
Utils.pprint('CYAN','execution summary')
for(f,fail,ret)in lst:
col=fail and'RED'or'GREEN'
Utils.pprint(col,(fail and'FAIL'or'ok')+" "+f)
def set_options(opt):
opt.add_option('--alltests',action='store_true',default=False,help='Exec all unit tests',dest='all_tests')
TaskGen.feature('test')(make_test)
TaskGen.after('apply_link')(make_test)
#! /usr/bin/env python
# encoding: utf-8
import os,sys
import Task,Utils
from Configure import conftest
ar_str='${AR} ${ARFLAGS} ${AR_TGT_F}${TGT} ${AR_SRC_F}${SRC}'
cls=Task.simple_task_type('static_link',ar_str,color='YELLOW',ext_in='.o',shell=False)
cls.maxjobs=1
cls.install=Utils.nada
old=cls.run
def wrap(self):
try:os.remove(self.outputs[0].abspath(self.env))
except OSError:pass
return old(self)
setattr(cls,'run',wrap)
def detect(conf):
conf.find_program('ar',var='AR')
conf.find_program('ranlib',var='RANLIB')
conf.env.ARFLAGS='rcs'
def find_ar(conf):
v=conf.env
conf.check_tool('ar')
if not v['AR']:conf.fatal('ar is required for static libraries - not found')
conftest(find_ar)
#! /usr/bin/env python
# encoding: utf-8
import Task
from TaskGen import extension
bison='${BISON} ${BISONFLAGS} ${SRC[0].abspath()} -o ${TGT[0].name}'
cls=Task.simple_task_type('bison',bison,'GREEN',ext_in='.yc .y .yy',ext_out='.c .cxx .h .l',before='cxx',shell=False)
def big_bison(self,node):
tsk=self.create_task('bison')
tsk.set_inputs(node)
has_h='-d'in self.env['BISONFLAGS']
outs=[]
if node.name.endswith('.yc'):
outs.append(node.change_ext('.tab.cc'))
if has_h:
outs.append(node.change_ext('.tab.hh'))
else:
outs.append(node.change_ext('.tab.c'))
if has_h:
outs.append(node.change_ext('.tab.h'))
tsk.set_outputs(outs)
tsk.cwd=node.bld_dir(tsk.env)
self.allnodes.append(outs[0])
def detect(conf):
bison=conf.find_program('bison',var='BISON',mandatory=True)
v=conf.env
v['BISONFLAGS']='-d'
extension(['.y','.yc','.yy'])(big_bison)
#! /usr/bin/env python
# encoding: utf-8
import os.path,glob,types,re,sys
import Configure,config_c,Options,Utils,Logs
from Logs import warn
from Configure import conf
boost_code='''
#include <iostream>
#include <boost/version.hpp>
int main() { std::cout << BOOST_VERSION << std::endl; }
'''
boost_libpath=['/usr/lib','/usr/local/lib','/opt/local/lib','/sw/lib','/lib']
boost_cpppath=['/usr/include','/usr/local/include','/opt/local/include','/sw/include']
STATIC_NOSTATIC='nostatic'
STATIC_BOTH='both'
STATIC_ONLYSTATIC='onlystatic'
is_versiontag=re.compile('^\d+_\d+_?\d*$')
is_threadingtag=re.compile('^mt$')
is_abitag=re.compile('^[sgydpn]+$')
is_toolsettag=re.compile('^(acc|borland|como|cw|dmc|darwin|gcc|hp_cxx|intel|kylix|vc|mgw|qcc|sun|vacpp)\d*$')
def set_options(opt):
opt.add_option('--boost-includes',type='string',default='',dest='boostincludes',help='path to the boost directory where the includes are e.g. /usr/local/include/boost-1_35')
opt.add_option('--boost-libs',type='string',default='',dest='boostlibs',help='path to the directory where the boost libs are e.g. /usr/local/lib')
def string_to_version(s):
version=s.split('.')
if len(version)<3:return 0
return int(version[0])*100000+int(version[1])*100+int(version[2])
def version_string(version):
major=version/100000
minor=version/100%1000
minor_minor=version%100
if minor_minor==0:
return"%d_%d"%(major,minor)
else:
return"%d_%d_%d"%(major,minor,minor_minor)
def libfiles(lib,pattern,lib_paths):
result=[]
for lib_path in lib_paths:
libname=pattern%('boost_'+lib+'*')
result+=glob.glob(lib_path+'/'+libname)
return result
def get_boost_version_number(self,dir):
try:
return self.run_c_code(compiler='cxx',code=boost_code,includes=dir,execute=1,env=self.env.copy(),type='cprogram',compile_mode='cxx',compile_filename='test.cpp')
except Configure.ConfigurationError,e:
return-1
def set_default(kw,var,val):
if not var in kw:
kw[var]=val
def tags_score(tags,kw):
score=0
needed_tags={'threading':kw['tag_threading'],'abi':kw['tag_abi'],'toolset':kw['tag_toolset'],'version':kw['tag_version']}
if kw['tag_toolset']is None:
v=kw['env']
toolset=v['CXX_NAME']
if v['CXX_VERSION']:
version_no=v['CXX_VERSION'].split('.')
toolset+=version_no[0]
if len(version_no)>1:
toolset+=version_no[1]
needed_tags['toolset']=toolset
found_tags={}
for tag in tags:
if is_versiontag.match(tag):found_tags['version']=tag
if is_threadingtag.match(tag):found_tags['threading']=tag
if is_abitag.match(tag):found_tags['abi']=tag
if is_toolsettag.match(tag):found_tags['toolset']=tag
for tagname in needed_tags.iterkeys():
if needed_tags[tagname]is not None and tagname in found_tags:
if re.compile(needed_tags[tagname]).match(found_tags[tagname]):
score+=kw['score_'+tagname][0]
else:
score+=kw['score_'+tagname][1]
return score
def validate_boost(self,kw):
ver=kw.get('version','')
for x in'min_version max_version version'.split():
set_default(kw,x,ver)
set_default(kw,'lib','')
kw['lib']=Utils.to_list(kw['lib'])
set_default(kw,'env',self.env)
set_default(kw,'libpath',boost_libpath)
set_default(kw,'cpppath',boost_cpppath)
for x in'tag_threading tag_version tag_toolset'.split():
set_default(kw,x,None)
set_default(kw,'tag_abi','^[^d]*$')
set_default(kw,'score_threading',(10,-10))
set_default(kw,'score_abi',(10,-10))
set_default(kw,'score_toolset',(1,-1))
set_default(kw,'score_version',(100,-100))
set_default(kw,'score_min',0)
set_default(kw,'static',STATIC_NOSTATIC)
set_default(kw,'found_includes',False)
set_default(kw,'min_score',0)
set_default(kw,'errmsg','not found')
set_default(kw,'okmsg','ok')
def find_boost_includes(self,kw):
boostPath=getattr(Options.options,'boostincludes','')
if boostPath:
boostPath=[os.path.normpath(os.path.expandvars(os.path.expanduser(boostPath)))]
else:
boostPath=Utils.to_list(kw['cpppath'])
min_version=string_to_version(kw.get('min_version',''))
max_version=string_to_version(kw.get('max_version',''))or(sys.maxint-1)
version=0
for include_path in boostPath:
boost_paths=glob.glob(os.path.join(include_path,'boost*'))
for path in boost_paths:
pathname=os.path.split(path)[-1]
ret=-1
if pathname=='boost':
path=include_path
ret=self.get_boost_version_number(path)
elif pathname.startswith('boost-'):
ret=self.get_boost_version_number(path)
ret=int(ret)
if ret!=-1 and ret>=min_version and ret<=max_version and ret>version:
boost_path=path
version=ret
if not version:
self.fatal('boost headers not found! (required version min: %s max: %s)'%(kw['min_version'],kw['max_version']))
return False
found_version=version_string(version)
versiontag='^'+found_version+'$'
if kw['tag_version']is None:
kw['tag_version']=versiontag
elif kw['tag_version']!=versiontag:
warn('boost header version %r and tag_version %r do not match!'%(versiontag,kw['tag_version']))
env=self.env
env['CPPPATH_BOOST']=boost_path
env['BOOST_VERSION']=found_version
self.found_includes=1
ret='Version %s (%s)'%(found_version,boost_path)
return ret
def find_boost_library(self,lib,kw):
def find_library_from_list(lib,files):
lib_pattern=re.compile('.*boost_(.*?)\..*')
result=(None,None)
resultscore=kw['min_score']-1
for file in files:
m=lib_pattern.search(file,1)
if m:
libname=m.group(1)
libtags=libname.split('-')[1:]
currentscore=tags_score(libtags,kw)
if currentscore>resultscore:
result=(libname,file)
resultscore=currentscore
return result
lib_paths=getattr(Options.options,'boostlibs','')
if lib_paths:
lib_paths=[os.path.normpath(os.path.expandvars(os.path.expanduser(lib_paths)))]
else:
lib_paths=Utils.to_list(kw['libpath'])
v=kw.get('env',self.env)
(libname,file)=(None,None)
if kw['static']in[STATIC_NOSTATIC,STATIC_BOTH]:
st_env_prefix='LIB'
files=libfiles(lib,v['shlib_PATTERN'],lib_paths)
(libname,file)=find_library_from_list(lib,files)
if libname is None and kw['static']in[STATIC_ONLYSTATIC,STATIC_BOTH]:
st_env_prefix='STATICLIB'
staticLibPattern=v['staticlib_PATTERN']
if self.env['CC_NAME']=='msvc':
staticLibPattern='lib'+staticLibPattern
files=libfiles(lib,staticLibPattern,lib_paths)
(libname,file)=find_library_from_list(lib,files)
if libname is not None:
v['LIBPATH_BOOST_'+lib.upper()]=[os.path.split(file)[0]]
if self.env['CC_NAME']=='msvc'and os.path.splitext(file)[1]=='.lib':
v[st_env_prefix+'_BOOST_'+lib.upper()]=['libboost_'+libname]
else:
v[st_env_prefix+'_BOOST_'+lib.upper()]=['boost_'+libname]
return
self.fatal('lib boost_'+lib+' not found!')
def check_boost(self,*k,**kw):
if not self.env['CXX']:
self.fatal('load a c++ compiler tool first, for example conf.check_tool("g++")')
self.validate_boost(kw)
ret=None
try:
if not kw.get('found_includes',None):
self.check_message_1(kw.get('msg_includes','boost headers'))
ret=self.find_boost_includes(kw)
except Configure.ConfigurationError,e:
if'errmsg'in kw:
self.check_message_2(kw['errmsg'],'YELLOW')
if'mandatory'in kw:
if Logs.verbose>1:
raise
else:
self.fatal('the configuration failed (see %r)'%self.log.name)
else:
if'okmsg'in kw:
self.check_message_2(kw.get('okmsg_includes',ret))
for lib in kw['lib']:
self.check_message_1('library boost_'+lib)
try:
self.find_boost_library(lib,kw)
except Configure.ConfigurationError,e:
ret=False
if'errmsg'in kw:
self.check_message_2(kw['errmsg'],'YELLOW')
if'mandatory'in kw:
if Logs.verbose>1:
raise
else:
self.fatal('the configuration failed (see %r)'%self.log.name)
else:
if'okmsg'in kw:
self.check_message_2(kw['okmsg'])
return ret
conf(get_boost_version_number)
conf(validate_boost)
conf(find_boost_includes)
conf(find_boost_library)
conf(check_boost)
#! /usr/bin/env python
# encoding: utf-8
import sys
if sys.hexversion < 0x020400f0: from sets import Set as set
import os
import TaskGen,Build,Utils,Task
from Logs import debug
import ccroot
from TaskGen import feature,before,extension,after
g_cc_flag_vars=['CCDEPS','FRAMEWORK','FRAMEWORKPATH','STATICLIB','LIB','LIBPATH','LINKFLAGS','RPATH','CCFLAGS','CPPPATH','CPPFLAGS','CCDEFINES']
EXT_CC=['.c']
g_cc_type_vars=['CCFLAGS','LINKFLAGS']
class cc_taskgen(ccroot.ccroot_abstract):
pass
def init_cc(self):
self.p_flag_vars=set(self.p_flag_vars).union(g_cc_flag_vars)
self.p_type_vars=set(self.p_type_vars).union(g_cc_type_vars)
if not self.env['CC_NAME']:
raise Utils.WafError("At least one compiler (gcc, ..) must be selected")
def apply_obj_vars_cc(self):
env=self.env
app=env.append_unique
cpppath_st=env['CPPPATH_ST']
for i in env['INC_PATHS']:
app('_CCINCFLAGS',cpppath_st%i.bldpath(env))
app('_CCINCFLAGS',cpppath_st%i.srcpath(env))
for i in env['CPPPATH']:
app('_CCINCFLAGS',cpppath_st%i)
def apply_defines_cc(self):
self.defines=getattr(self,'defines',[])
lst=self.to_list(self.defines)+self.to_list(self.env['CCDEFINES'])
milst=[]
for defi in lst:
if not defi in milst:
milst.append(defi)
libs=self.to_list(self.uselib)
for l in libs:
val=self.env['CCDEFINES_'+l]
if val:milst+=val
self.env['DEFLINES']=["%s %s"%(x[0],Utils.trimquotes('='.join(x[1:])))for x in[y.split('=')for y in milst]]
y=self.env['CCDEFINES_ST']
self.env['_CCDEFFLAGS']=[y%x for x in milst]
def c_hook(self,node):
task=self.create_task('cc')
if getattr(self,'obj_ext',None):
obj_ext=self.obj_ext
else:
obj_ext='_%d.o'%self.idx
task.inputs=[node]
task.outputs=[node.change_ext(obj_ext)]
try:
self.compiled_tasks.append(task)
except AttributeError:
raise Utils.WafError('Have you forgotten to set the feature "cc" on %s?'%str(self))
return task
cc_str='${CC} ${CCFLAGS} ${CPPFLAGS} ${_CCINCFLAGS} ${_CCDEFFLAGS} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT}'
cls=Task.simple_task_type('cc',cc_str,'GREEN',ext_out='.o',ext_in='.c',shell=False)
cls.scan=ccroot.scan
cls.vars.append('CCDEPS')
link_str='${LINK_CC} ${CCLNK_SRC_F}${SRC} ${CCLNK_TGT_F}${TGT[0].abspath(env)} ${LINKFLAGS}'
cls=Task.simple_task_type('cc_link',link_str,color='YELLOW',ext_in='.o',ext_out='.bin',shell=False)
cls.maxjobs=1
cls.install=Utils.nada
feature('cc')(init_cc)
before('apply_type_vars')(init_cc)
after('default_cc')(init_cc)
feature('cc')(apply_obj_vars_cc)
after('apply_incpaths')(apply_obj_vars_cc)
feature('cc')(apply_defines_cc)
after('apply_lib_vars')(apply_defines_cc)
extension(EXT_CC)(c_hook)
#! /usr/bin/env python
# encoding: utf-8
import Logs
import Options
import Utils
class CompilerTraits(object):
def get_warnings_flags(self,level):
raise NotImplementedError
def get_optimization_flags(self,level):
raise NotImplementedError
def get_debug_flags(self,level):
raise NotImplementedError
class GccTraits(CompilerTraits):
def __init__(self):
super(GccTraits,self).__init__()
self.warnings_flags=[['-Wall'],['-Werror'],['-Wextra']]
def get_warnings_flags(self,level):
warnings=[]
for l in range(level):
if l<len(self.warnings_flags):
warnings.extend(self.warnings_flags[l])
else:
break
return warnings
def get_optimization_flags(self,level):
if level==0:
return['-O0']
elif level==1:
return['-O']
elif level==2:
return['-O2']
elif level==3:
return['-O3']
def get_debug_flags(self,level):
if level==0:
return(['-g0'],['NDEBUG'])
elif level==1:
return(['-g'],[])
elif level>=2:
return(['-ggdb','-g3'],['_DEBUG'])
class IccTraits(CompilerTraits):
def __init__(self):
super(IccTraits,self).__init__()
self.warnings_flags=[[],[],['-Wall']]
def get_warnings_flags(self,level):
warnings=[]
for l in range(level):
if l<len(self.warnings_flags):
warnings.extend(self.warnings_flags[l])
else:
break
return warnings
def get_optimization_flags(self,level):
if level==0:
return['-O0']
elif level==1:
return['-O']
elif level==2:
return['-O2']
elif level==3:
return['-O3']
def get_debug_flags(self,level):
if level==0:
return(['-g0'],['NDEBUG'])
elif level==1:
return(['-g'],[])
elif level>=2:
return(['-ggdb','-g3'],['_DEBUG'])
class MsvcTraits(CompilerTraits):
def __init__(self):
super(MsvcTraits,self).__init__()
self.warnings_flags=[['/W2'],['/WX'],['/Wall']]
def get_warnings_flags(self,level):
warnings=[]
for l in range(level):
if l<len(self.warnings_flags):
warnings.extend(self.warnings_flags[l])
else:
break
return warnings
def get_optimization_flags(self,level):
if level==0:
return['/Od']
elif level==1:
return[]
elif level==2:
return['/O2']
elif level==3:
return['/Ox']
def get_debug_flags(self,level):
if level==0:
return([],['NDEBUG'])
elif level==1:
return(['/ZI','/RTC1'],[])
elif level>=2:
return(['/ZI','/RTC1'],['_DEBUG'])
gcc=GccTraits()
icc=IccTraits()
msvc=MsvcTraits()
compiler_mapping={'gcc':gcc,'g++':gcc,'msvc':msvc,'icc':icc,'icpc':icc,}
profiles={'default':[2,1,1],'debug':[0,2,3],'release':[3,1,0],}
default_profile='default'
def set_options(opt):
assert default_profile in profiles
opt.add_option('-d','--build-profile',action='store',default=default_profile,help=("Specify the build profile. ""Build profiles control the default compilation flags"" used for C/C++ programs, if CCFLAGS/CXXFLAGS are not"" set set in the environment. [Allowed Values: %s]"%", ".join([repr(p)for p in profiles.keys()])),choices=profiles.keys(),dest='build_profile')
def detect(conf):
cc=conf.env['COMPILER_CC']or None
cxx=conf.env['COMPILER_CXX']or None
if not(cc or cxx):
raise Utils.WafError("neither COMPILER_CC nor COMPILER_CXX are defined; ""maybe the compiler_cc or compiler_cxx tool has not been configured yet?")
try:
compiler=compiler_mapping[cc]
except KeyError:
try:
compiler=compiler_mapping[cxx]
except KeyError:
Logs.warn("No compiler flags support for compiler %r or %r"%(cc,cxx))
return
opt_level,warn_level,dbg_level=profiles[Options.options.build_profile]
optimizations=compiler.get_optimization_flags(opt_level)
debug,debug_defs=compiler.get_debug_flags(dbg_level)
warnings=compiler.get_warnings_flags(warn_level)
if cc and not conf.env['CCFLAGS']:
conf.env.append_value('CCFLAGS',optimizations)
conf.env.append_value('CCFLAGS',debug)
conf.env.append_value('CCFLAGS',warnings)
conf.env.append_value('CCDEFINES',debug_defs)
if cxx and not conf.env['CXXFLAGS']:
conf.env.append_value('CXXFLAGS',optimizations)
conf.env.append_value('CXXFLAGS',debug)
conf.env.append_value('CXXFLAGS',warnings)
conf.env.append_value('CXXDEFINES',debug_defs)
#! /usr/bin/env python
# encoding: utf-8
from TaskGen import feature,taskgen,before,task_gen
import Node,Task,Utils,Build,pproc,Constants
import Options
import shellcmd
shellcmd.subprocess=pproc
from Logs import debug,error
shellcmd.debug=debug
import Task
import re
arg_rx=re.compile(r"(?P<dollar>\$\$)|(?P<subst>\$\{(?P<var>\w+)(?P<code>.*?)\})",re.M)
class command_task(Task.Task):
color="BLUE"
def __init__(self,env,generator):
Task.Task.__init__(self,env,normal=1,generator=generator)
def __str__(self):
env=self.env
src_str=' '.join([a.nice_path(env)for a in self.inputs])
tgt_str=' '.join([a.nice_path(env)for a in self.outputs])
if self.outputs:
sep=' -> '
else:
sep=''
pipeline=shellcmd.Pipeline()
pipeline.parse(self.generator.command)
cmd=pipeline.get_abbreviated_command()
return'command (%s): %s%s%s\n'%(cmd,src_str,sep,tgt_str)
def _subst_arg(self,arg,direction,namespace):
def repl(match):
if match.group('dollar'):
return"$"
elif match.group('subst'):
var=match.group('var')
code=match.group('code')
result=eval(var+code,namespace)
if isinstance(result,Node.Node):
if var=='TGT':
return result.bldpath(self.env)
elif var=='SRC':
return result.srcpath(self.env)
else:
raise ValueError("Bad subst variable %r"%var)
elif result is self.inputs:
if len(self.inputs)==1:
return result[0].srcpath(self.env)
else:
raise ValueError("${SRC} requested but have multiple sources; which one?")
elif result is self.outputs:
if len(self.outputs)==1:
return result[0].bldpath(self.env)
else:
raise ValueError("${TGT} requested but have multiple targets; which one?")
else:
return result
return None
return arg_rx.sub(repl,arg)
def run(self):
pipeline=shellcmd.Pipeline()
pipeline.parse(self.generator.command)
namespace=self.env.get_merged_dict()
if self.generator.variables is not None:
namespace.update(self.generator.variables)
namespace.update(env=self.env,SRC=self.inputs,TGT=self.outputs)
for cmd in pipeline.pipeline:
if isinstance(cmd,shellcmd.Command):
if isinstance(cmd.stdin,basestring):
cmd.stdin=self._subst_arg(cmd.stdin,'in',namespace)
if isinstance(cmd.stdout,basestring):
cmd.stdout=self._subst_arg(cmd.stdout,'out',namespace)
if isinstance(cmd.stderr,basestring):
cmd.stderr=self._subst_arg(cmd.stderr,'out',namespace)
for argI in xrange(len(cmd.argv)):
cmd.argv[argI]=self._subst_arg(cmd.argv[argI],None,namespace)
if cmd.env_vars is not None:
env_vars=dict()
for name,value in cmd.env_vars.iteritems():
env_vars[name]=self._subst_arg(value,None,namespace)
cmd.env_vars=env_vars
elif isinstance(cmd,shellcmd.Chdir):
cmd.dir=self._subst_arg(cmd.dir,None,namespace)
return pipeline.run(verbose=(Options.options.verbose>0))
def init_command(self):
Utils.def_attrs(self,variables=None)
def apply_command(self):
self.meths.remove('apply_core')
task=self.create_task('command')
setattr(task,"dep_vars",getattr(self,"dep_vars",None))
inputs=[]
for src in self.to_list(self.source):
node=self.path.find_resource(src)
if node is None:
raise Utils.WafError("source %s not found"%src)
inputs.append(node)
task.set_inputs(inputs)
task.set_outputs([self.path.find_or_declare(tgt)for tgt in self.to_list(self.target)])
class command_taskgen(task_gen):
def __init__(self,*k,**kw):
task_gen.__init__(self,*k,**kw)
self.features.append('command')
taskgen(init_command)
feature('command')(init_command)
taskgen(apply_command)
feature('command')(apply_command)
before('apply_core')(apply_command)
#! /usr/bin/env python
# encoding: utf-8
import os,sys,imp,types,ccroot
import optparse
import Utils,Configure,Options
from Logs import debug
c_compiler={'win32':['msvc','gcc'],'cygwin':['gcc'],'darwin':['gcc'],'aix5':['gcc'],'linux':['gcc','icc','suncc'],'sunos':['gcc','suncc'],'irix':['gcc'],'hpux':['gcc'],'default':['gcc']}
def __list_possible_compiler(platform):
try:
return c_compiler[platform]
except KeyError:
return c_compiler["default"]
def detect(conf):
try:test_for_compiler=Options.options.check_c_compiler
except AttributeError:conf.fatal("Add set_options(opt): opt.tool_options('compiler_cc')")
for compiler in test_for_compiler.split():
try:
conf.check_tool(compiler)
except Configure.ConfigurationError,e:
debug('compiler_cc: %r'%e)
else:
if conf.env['CC']:
conf.check_message(compiler,'',True)
conf.env['COMPILER_CC']=compiler
break
conf.check_message(compiler,'',False)
def set_options(opt):
build_platform=Utils.unversioned_sys_platform()
possible_compiler_list=__list_possible_compiler(build_platform)
test_for_compiler=' '.join(possible_compiler_list)
cc_compiler_opts=opt.add_option_group("C Compiler Options")
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")
for c_compiler in test_for_compiler.split():
opt.tool_options('%s'%c_compiler,option_group=cc_compiler_opts)
#! /usr/bin/env python
# encoding: utf-8
import os,sys,imp,types,ccroot
import optparse
import Utils,Configure,Options
from Logs import debug
cxx_compiler={'win32':['msvc','g++'],'cygwin':['g++'],'darwin':['g++'],'aix':['g++'],'linux':['g++','icpc','sunc++'],'sunos':['g++','sunc++'],'irix':['g++'],'hpux':['g++'],'default':['g++']}
def __list_possible_compiler(platform):
try:
return cxx_compiler[platform]
except KeyError:
return cxx_compiler["default"]
def detect(conf):
try:test_for_compiler=Options.options.check_cxx_compiler
except AttributeError:raise Configure.ConfigurationError("Add set_options(opt): opt.tool_options('compiler_cxx')")
for compiler in test_for_compiler.split():
try:
conf.check_tool(compiler)
except Configure.ConfigurationError,e:
debug('compiler_cxx: %r'%e)
else:
if conf.env['CXX']:
conf.check_message(compiler,'',True)
conf.env['COMPILER_CXX']=compiler
break
conf.check_message(compiler,'',False)
def set_options(opt):
build_platform=Utils.unversioned_sys_platform()
possible_compiler_list=__list_possible_compiler(build_platform)
test_for_compiler=' '.join(possible_compiler_list)
cxx_compiler_opts=opt.add_option_group('C++ Compiler Options')
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")
for cxx_compiler in test_for_compiler.split():
opt.tool_options('%s'%cxx_compiler,option_group=cxx_compiler_opts)
#! /usr/bin/env python
# encoding: utf-8
import os,sys,imp,types
import Utils,Configure,Options
def detect(conf):
if getattr(Options.options,'check_dmd_first',None):
test_for_compiler=['dmd','gdc']
else:
test_for_compiler=['gdc','dmd']
for d_compiler in test_for_compiler:
try:
conf.check_tool(d_compiler)
except:
pass
else:
break
else:
conf.fatal('no suitable d compiler was found')
def set_options(opt):
d_compiler_opts=opt.add_option_group('D Compiler Options')
d_compiler_opts.add_option('--check-dmd-first',action='store_true',help='checks for the gdc compiler before dmd (default is the other way round)',dest='check_dmd_first',default=False)
for d_compiler in['gdc','dmd']:
opt.tool_options('%s'%d_compiler,option_group=d_compiler_opts)
#! /usr/bin/env python
# encoding: utf-8
import TaskGen,Utils,Task
from Logs import error
from TaskGen import before,after,taskgen,feature
flag_vars=['FLAGS','ASSEMBLIES']
def init_cs(self):
Utils.def_attrs(self,flags='',assemblies='',resources='',uselib='')
def apply_uselib_cs(self):
if not self.uselib:
return
global flag_vars
for var in self.to_list(self.uselib):
for v in self.flag_vars:
val=self.env[v+'_'+var]
if val:self.env.append_value(v,val)
def apply_cs(self):
try:self.meths.remove('apply_core')
except ValueError:pass
assemblies_flags=[]
for i in self.to_list(self.assemblies)+self.env['ASSEMBLIES']:
assemblies_flags+='/r:'+i
self.env['_ASSEMBLIES']+=assemblies_flags
for i in self.to_list(self.resources):
self.env['_RESOURCES'].append('/resource:'+i)
self.env['_FLAGS']+=self.to_list(self.flags)+self.env['FLAGS']
curnode=self.path
nodes=[]
for i in self.to_list(self.source):
nodes.append(curnode.find_resource(i))
task=self.create_task('mcs')
task.inputs=nodes
task.set_outputs(self.path.find_or_declare(self.target))
Task.simple_task_type('mcs','${MCS} ${SRC} /out:${TGT} ${_FLAGS} ${_ASSEMBLIES} ${_RESOURCES}',color='YELLOW')
def detect(conf):
mcs=conf.find_program('mcs',var='MCS')
if not mcs:mcs=conf.find_program('gmcs',var='MCS')
feature('cs')(init_cs)
feature('cs')(apply_uselib_cs)
after('init_cs')(apply_uselib_cs)
feature('cs')(apply_cs)
after('apply_uselib_cs')(apply_cs)
before('apply_core')(apply_cs)
#! /usr/bin/env python
# encoding: utf-8
import sys
if sys.hexversion < 0x020400f0: from sets import Set as set
import TaskGen,Task,Utils
from Logs import debug
import ccroot
from TaskGen import feature,before,extension,after
g_cxx_flag_vars=['CXXDEPS','FRAMEWORK','FRAMEWORKPATH','STATICLIB','LIB','LIBPATH','LINKFLAGS','RPATH','CXXFLAGS','CCFLAGS','CPPPATH','CPPFLAGS','CXXDEFINES']
EXT_CXX=['.cpp','.cc','.cxx','.C','.c++']
g_cxx_type_vars=['CXXFLAGS','LINKFLAGS']
class cxx_taskgen(ccroot.ccroot_abstract):
pass
def init_cxx(self):
if not'cc'in self.features:
self.mappings['.c']=TaskGen.task_gen.mappings['.cxx']
self.p_flag_vars=set(self.p_flag_vars).union(g_cxx_flag_vars)
self.p_type_vars=set(self.p_type_vars).union(g_cxx_type_vars)
if not self.env['CXX_NAME']:
raise Utils.WafError("At least one compiler (g++, ..) must be selected")
def apply_obj_vars_cxx(self):
env=self.env
app=env.append_unique
cxxpath_st=env['CPPPATH_ST']
for i in env['INC_PATHS']:
app('_CXXINCFLAGS',cxxpath_st%i.bldpath(env))
app('_CXXINCFLAGS',cxxpath_st%i.srcpath(env))
for i in env['CPPPATH']:
app('_CXXINCFLAGS',cxxpath_st%i)
def apply_defines_cxx(self):
self.defines=getattr(self,'defines',[])
lst=self.to_list(self.defines)+self.to_list(self.env['CXXDEFINES'])
milst=[]
for defi in lst:
if not defi in milst:
milst.append(defi)
libs=self.to_list(self.uselib)
for l in libs:
val=self.env['CXXDEFINES_'+l]
if val:milst+=self.to_list(val)
self.env['DEFLINES']=["%s %s"%(x[0],Utils.trimquotes('='.join(x[1:])))for x in[y.split('=')for y in milst]]
y=self.env['CXXDEFINES_ST']
self.env['_CXXDEFFLAGS']=[y%x for x in milst]
def cxx_hook(self,node):
task=self.create_task('cxx')
if getattr(self,'obj_ext',None):
obj_ext=self.obj_ext
else:
obj_ext='_%d.o'%self.idx
task.inputs=[node]
task.outputs=[node.change_ext(obj_ext)]
try:
self.compiled_tasks.append(task)
except AttributeError:
raise Utils.WafError('Have you forgotten to set the feature "cxx" on %s?'%str(self))
return task
cxx_str='${CXX} ${CXXFLAGS} ${CPPFLAGS} ${_CXXINCFLAGS} ${_CXXDEFFLAGS} ${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT}'
cls=Task.simple_task_type('cxx',cxx_str,color='GREEN',ext_out='.o',ext_in='.cxx',shell=False)
cls.scan=ccroot.scan
cls.vars.append('CXXDEPS')
link_str='${LINK_CXX} ${CXXLNK_SRC_F}${SRC} ${CXXLNK_TGT_F}${TGT[0].abspath(env)} ${LINKFLAGS}'
cls=Task.simple_task_type('cxx_link',link_str,color='YELLOW',ext_in='.o',ext_out='.bin',shell=False)
cls.maxjobs=1
cls.install=Utils.nada
feature('cxx')(init_cxx)
before('apply_type_vars')(init_cxx)
after('default_cc')(init_cxx)
feature('cxx')(apply_obj_vars_cxx)
after('apply_incpaths')(apply_obj_vars_cxx)
feature('cxx')(apply_defines_cxx)
after('apply_lib_vars')(apply_defines_cxx)
extension(EXT_CXX)(cxx_hook)
#! /usr/bin/env python
# encoding: utf-8
import Task,Utils
from TaskGen import taskgen,before,after,feature
def add_dbus_file(self,filename,prefix,mode):
if not hasattr(self,'dbus_lst'):
self.dbus_lst=[]
self.meths.append('process_dbus')
self.dbus_lst.append([filename,prefix,mode])
def process_dbus(self):
for filename,prefix,mode in getattr(self,'dbus_lst',[]):
env=self.env.copy()
node=self.path.find_resource(filename)
if not node:
raise Utils.WafError('file not found '+filename)
env['DBUS_BINDING_TOOL_PREFIX']=prefix
env['DBUS_BINDING_TOOL_MODE']=mode
task=self.create_task('dbus_binding_tool',env)
task.set_inputs(node)
task.set_outputs(node.change_ext('.h'))
Task.simple_task_type('dbus_binding_tool','${DBUS_BINDING_TOOL} --prefix=${DBUS_BINDING_TOOL_PREFIX} --mode=${DBUS_BINDING_TOOL_MODE} --output=${TGT} ${SRC}',color='BLUE',before='cc')
def detect(conf):
dbus_binding_tool=conf.find_program('dbus-binding-tool',var='DBUS_BINDING_TOOL')
taskgen(add_dbus_file)
before('apply_core')(process_dbus)
#! /usr/bin/env python
# encoding: utf-8
import sys
import Utils,ar
from Configure import conftest
def find_dmd(conf):
conf.find_program(['dmd','ldc'],var='D_COMPILER',mandatory=True)
def common_flags_ldc(conf):
v=conf.env
v['DFLAGS']=['-d-version=Posix']
v['DLINKFLAGS']=[]
v['D_shlib_DFLAGS']=['-relocation-model=pic']
def common_flags_dmd(conf):
v=conf.env
v['DFLAGS']=['-version=Posix']
v['D_SRC_F']=''
v['D_TGT_F']=['-c','-of']
v['DPATH_ST']='-I%s'
v['D_LINKER']=v['D_COMPILER']
v['DLNK_SRC_F']=''
v['DLNK_TGT_F']='-of'
v['DLIB_ST']='-L-l%s'
v['DLIBPATH_ST']='-L-L%s'
v['DFLAGS_OPTIMIZED']=['-O']
v['DFLAGS_DEBUG']=['-g','-debug']
v['DFLAGS_ULTRADEBUG']=['-g','-debug']
v['DLINKFLAGS']=['-quiet']
v['D_shlib_DFLAGS']=['-fPIC']
v['D_shlib_LINKFLAGS']=['-L-shared']
v['DHEADER_ext']='.di'
v['D_HDR_F']=['-H','-Hf']
def detect(conf):
conf.find_dmd()
conf.check_tool('ar')
conf.check_tool('d')
conf.common_flags_dmd()
conf.d_platform_flags()
if conf.env.D_COMPILER.find('ldc')>-1:
conf.common_flags_ldc()
conftest(find_dmd)
conftest(common_flags_ldc)
conftest(common_flags_dmd)
#! /usr/bin/env python
# encoding: utf-8
import TaskGen
def decide_ext(self,node):
if'cxx'in self.features:return'.lex.cc'
else:return'.lex.c'
TaskGen.declare_chain(name='flex',rule='${FLEX} -o${TGT} ${FLEXFLAGS} ${SRC}',ext_in='.l',decider=decide_ext,before='cc cxx',)
def detect(conf):
conf.find_program('flex',var='FLEX',mandatory=True)
v=conf.env
v['FLEXFLAGS']=''
#! /usr/bin/env python
# encoding: utf-8
import os,sys
import Task
from TaskGen import extension,taskgen,after,before
EXT_ASM=['.s','.S','.asm','.ASM','.spp','.SPP']
as_str='${AS} ${ASFLAGS} ${_ASINCFLAGS} ${SRC} -o ${TGT}'
Task.simple_task_type('asm',as_str,'PINK',ext_out='.o',shell=False)
def asm_hook(self,node):
task=self.create_task('asm')
try:obj_ext=self.obj_ext
except AttributeError:obj_ext='_%d.o'%self.idx
task.inputs=[node]
task.outputs=[node.change_ext(obj_ext)]
self.compiled_tasks.append(task)
self.meths.append('asm_incflags')
def asm_incflags(self):
if self.env['ASINCFLAGS']:self.env['_ASINCFLAGS']=self.env['ASINCFLAGS']
if'cxx'in self.features:self.env['_ASINCFLAGS']=self.env['_CXXINCFLAGS']
else:self.env['_ASINCFLAGS']=self.env['_CCINCFLAGS']
def detect(conf):
conf.find_program(['gas','as'],var='AS')
if not conf.env.AS:conf.env.AS=conf.env.CC
extension(EXT_ASM)(asm_hook)
taskgen(asm_incflags)
after('apply_obj_vars_cc')(asm_incflags)
after('apply_obj_vars_cxx')(asm_incflags)
before('apply_link')(asm_incflags)
#! /usr/bin/env python
# encoding: utf-8
import os,sys
import Configure,Options,Utils
import ccroot,ar
from Configure import conftest
def find_gcc(conf):
cc=conf.find_program(['gcc','cc'],var='CC',mandatory=True)
cc=conf.cmd_to_list(cc)
ccroot.get_cc_version(conf,cc,gcc=True)
conf.env.CC_NAME='gcc'
conf.env.CC=cc
def gcc_common_flags(conf):
v=conf.env
v['CC_SRC_F']=''
v['CC_TGT_F']=['-c','-o','']
v['CPPPATH_ST']='-I%s'
if not v['LINK_CC']:v['LINK_CC']=v['CC']
v['CCLNK_SRC_F']=''
v['CCLNK_TGT_F']=['-o','']
v['LIB_ST']='-l%s'
v['LIBPATH_ST']='-L%s'
v['STATICLIB_ST']='-l%s'
v['STATICLIBPATH_ST']='-L%s'
v['RPATH_ST']='-Wl,-rpath,%s'
v['CCDEFINES_ST']='-D%s'
v['SONAME_ST']='-Wl,-h,%s'
v['SHLIB_MARKER']='-Wl,-Bdynamic'
v['STATICLIB_MARKER']='-Wl,-Bstatic'
v['FULLSTATIC_MARKER']='-static'
v['program_PATTERN']='%s'
v['shlib_CCFLAGS']=['-fPIC','-DPIC']
v['shlib_LINKFLAGS']=['-shared']
v['shlib_PATTERN']='lib%s.so'
v['staticlib_LINKFLAGS']=['-Wl,-Bstatic']
v['staticlib_PATTERN']='lib%s.a'
v['LINKFLAGS_MACBUNDLE']=['-bundle','-undefined','dynamic_lookup']
v['CCFLAGS_MACBUNDLE']=['-fPIC']
v['macbundle_PATTERN']='%s.bundle'
def gcc_modifier_win32(conf):
v=conf.env
v['program_PATTERN']='%s.exe'
v['shlib_PATTERN']='%s.dll'
v['implib_PATTERN']='lib%s.dll.a'
v['IMPLIB_ST']='-Wl,--out-implib,%s'
v['shlib_CCFLAGS']=['-DPIC','-DDLL_EXPORT']
v.append_value('LINKFLAGS','-Wl,--enable-auto-import')
def gcc_modifier_cygwin(conf):
gcc_modifier_win32(conf)
v=conf.env
v['shlib_PATTERN']='cyg%s.dll'
v.append_value('shlib_LINKFLAGS','-Wl,--enable-auto-image-base')
def gcc_modifier_darwin(conf):
v=conf.env
v['shlib_CCFLAGS']=['-fPIC','-compatibility_version','1','-current_version','1']
v['shlib_LINKFLAGS']=['-dynamiclib']
v['shlib_PATTERN']='lib%s.dylib'
v['staticlib_LINKFLAGS']=[]
v['SHLIB_MARKER']=''
v['STATICLIB_MARKER']=''
def gcc_modifier_aix(conf):
v=conf.env
v['program_LINKFLAGS']=['-Wl,-brtl']
v['shlib_LINKFLAGS']=['-shared','-Wl,-brtl,-bexpfull']
v['SHLIB_MARKER']=''
def gcc_modifier_platform(conf):
dest_os=conf.env['DEST_OS']or Utils.unversioned_sys_platform()
gcc_modifier_func=globals().get('gcc_modifier_'+dest_os)
if gcc_modifier_func:
gcc_modifier_func(conf)
def detect(conf):
conf.find_gcc()
conf.find_cpp()
conf.find_ar()
conf.gcc_common_flags()
conf.gcc_modifier_platform()
conf.cc_load_tools()
conf.cc_add_flags()
conftest(find_gcc)
conftest(gcc_common_flags)
conftest(gcc_modifier_win32)
conftest(gcc_modifier_cygwin)
conftest(gcc_modifier_darwin)
conftest(gcc_modifier_aix)
conftest(gcc_modifier_platform)
#! /usr/bin/env python
# encoding: utf-8
import sys
import Utils,ar
from Configure import conftest
def find_gdc(conf):
conf.find_program('gdc',var='D_COMPILER',mandatory=True)
def common_flags_gdc(conf):
v=conf.env
v['DFLAGS']=[]
v['D_SRC_F']=''
v['D_TGT_F']=['-c','-o','']
v['DPATH_ST']='-I%s'
v['D_LINKER']=v['D_COMPILER']
v['DLNK_SRC_F']=''
v['DLNK_TGT_F']=['-o','']
v['DLIB_ST']='-l%s'
v['DLIBPATH_ST']='-L%s'
v['DLINKFLAGS']=[]
v['DFLAGS_OPTIMIZED']=['-O3']
v['DFLAGS_DEBUG']=['-O0']
v['DFLAGS_ULTRADEBUG']=['-O0']
v['D_shlib_DFLAGS']=[]
v['D_shlib_LINKFLAGS']=['-shared']
v['DHEADER_ext']='.di'
v['D_HDR_F']='-fintfc -fintfc-file='
def detect(conf):
conf.find_gdc()
conf.check_tool('ar')
conf.check_tool('d')
conf.common_flags_gdc()
conf.d_platform_flags()
conftest(find_gdc)
conftest(common_flags_gdc)
#! /usr/bin/env python
# encoding: utf-8
import TaskGen
TaskGen.declare_chain(name='gob2',rule='${GOB2} -o ${TGT[0].bld_dir(env)} ${GOB2FLAGS} ${SRC}',ext_in='.gob',ext_out='.c')
def detect(conf):
gob2=conf.find_program('gob2',var='GOB2',mandatory=True)
conf.env['GOB2']=gob2
conf.env['GOB2FLAGS']=''
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com> <gjc@inescporto.pt>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
corepost @ aca1a7b8
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
twistar @ 20e7cd2a
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment