3
# WARNING! Do not edit! http://waf.googlecode.com/svn/docs/wafbook/single.html#_obtaining_the_waf_file
5
import os,tempfile,optparse,sys,re
6
from waflib import Logs,Utils,Context
7
cmds='distclean configure build install clean uninstall check dist distcheck'.split()
10
lockfile=os.environ.get('WAFLOCK','.lock-wafbuild')
11
try:cache_global=os.path.abspath(os.environ['WAFCACHE'])
12
except KeyError:cache_global=''
13
platform=Utils.unversioned_sys_platform()
14
class opt_parser(optparse.OptionParser):
15
def __init__(self,ctx):
16
optparse.OptionParser.__init__(self,conflict_handler="resolve",version='waf %s (%s)'%(Context.WAFVERSION,Context.WAFREVISION))
17
self.formatter.width=Logs.get_term_cols()
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:
33
d=tempfile.gettempdir()
34
default_prefix=d[0].upper()+d[1:]
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')
53
for cls in Context.classes:
54
if not cls.cmd or cls.cmd=='options':
59
for(k,v)in Context.g_module.__dict__.items():
60
if k in['options','init','shutdown']:
62
if type(v)is type(Context.create_context):
63
if v.__doc__ and not k.startswith('_'):
68
lst=[' %s: %s'%(k.ljust(just),v)for(k,v)in cmds_str.items()]
71
return'''waf [commands] [options]
73
Main commands (example: ./waf build -j4)
76
class OptionsContext(Context.Context):
79
def __init__(self,**kw):
80
super(OptionsContext,self).__init__(**kw)
81
self.parser=opt_parser(self)
84
count=int(os.environ.get('JOBS',0))
86
if'NUMBER_OF_PROCESSORS'in os.environ:
87
count=int(os.environ.get('NUMBER_OF_PROCESSORS',1))
89
if hasattr(os,'sysconf_names'):
90
if'SC_NPROCESSORS_ONLN'in os.sysconf_names:
91
count=int(os.sysconf('SC_NPROCESSORS_ONLN'))
92
elif'SC_NPROCESSORS_CONF'in os.sysconf_names:
93
count=int(os.sysconf('SC_NPROCESSORS_CONF'))
94
elif os.name not in('nt','java'):
95
tmp=self.cmd_and_log(['sysctl','-n','hw.ncpu'])
96
if re.match('^[0-9]+$',tmp):
103
def add_option(self,*k,**kw):
104
self.parser.add_option(*k,**kw)
105
def add_option_group(self,*k,**kw):
107
gr=self.option_groups[k[0]]
109
gr=self.parser.add_option_group(*k,**kw)
110
self.option_groups[k[0]]=gr
112
def get_option_group(self,opt_str):
114
return self.option_groups[opt_str]
116
for group in self.parser.option_groups:
117
if group.title==opt_str:
120
def parse_args(self,_args=None):
121
global options,commands
122
(options,leftover_args)=self.parser.parse_args(args=_args)
123
commands=leftover_args
125
options.destdir=os.path.abspath(os.path.expanduser(options.destdir))
126
if options.verbose>=1:
127
self.load('errcheck')
129
super(OptionsContext,self).execute()