v['PYC'] = getattr(Options.options, 'pyc', 1) v['PYO'] = getattr(Options.options, 'pyo', 1) def options(opt): opt.add_option( '--nopyc', action='store_false', default=1, help= 'Do not install bytecode compiled .pyc files (configuration) [Default:install]', dest='pyc') opt.add_option( '--nopyo', action='store_false', default=1, help= 'Do not install optimised compiled .pyo files (configuration) [Default:install]', dest='pyo') extension('.py')(process_py) feature('py')(feature_py) feature('pyext')(init_pyext) before_method('propagate_uselib_vars', 'apply_link')(init_pyext) before_method('propagate_uselib_vars')(init_pyembed) feature('pyembed')(init_pyembed) conf(get_python_variables) conf(check_python_headers) conf(check_python_version) conf(check_python_module)
#! /usr/bin/env python # encoding: utf-8 # WARNING! All changes made to this file will be lost! import os, sys import waflib.Task from waflib.TaskGen import extension, feature class asm(waflib.Task.Task): color = 'BLUE' run_str = '${AS} ${ASFLAGS} ${CPPPATH_ST:INCPATHS} ${AS_SRC_F}${SRC} ${AS_TGT_F}${TGT}' def asm_hook(self, node): return self.create_compiled_task('asm', node) extension('.s', '.S', '.asm', '.ASM', '.spp', '.SPP')(asm_hook)
if Options.options.want_rpath: def process_rpath(vars_,coreval): for d in vars_: var=d.upper() value=env['LIBPATH_'+var] if value: core=env[coreval] accu=[] for lib in value: if var!='QTCORE': if lib in core: continue accu.append('-Wl,--rpath='+lib) env['RPATH_'+var]=accu process_rpath(vars,'LIBPATH_QTCORE') process_rpath(vars_debug,'LIBPATH_QTCORE_DEBUG') def options(opt): opt.add_option('--want-rpath',action='store_true',default=False,dest='want_rpath',help='enable the rpath for qt libraries') opt.add_option('--header-ext',type='string',default='',help='header extension for moc files',dest='qt_header_ext') for i in'qtdir qtbin qtlibs'.split(): opt.add_option('--'+i,type='string',default='',dest=i) if sys.platform=="darwin": opt.add_option('--no-qt4-framework',action="store_false",help='do not use the framework version of Qt4 in OS X',dest='use_qt4_osxframework',default=True) opt.add_option('--translate',action="store_true",help="collect translation strings",dest="trans_qt4",default=False) extension(*EXT_RCC)(create_rcc_task) extension(*EXT_UI)(create_uic_task) extension('.ts')(add_lang) feature('qt4')(apply_qt4) after_method('apply_link')(apply_qt4) extension(*EXT_QT4)(cxx_hook)
def runnable_status(self): ret = super(fcprogram_test, self).runnable_status() if ret == Task.SKIP_ME: ret = Task.RUN_ME return ret def exec_command(self, cmd, **kw): bld = self.generator.bld kw['shell'] = isinstance(cmd, str) kw['stdout'] = kw['stderr'] = Utils.subprocess.PIPE kw['cwd'] = bld.variant_dir bld.out = bld.err = '' bld.to_log('command: %s\n' % cmd) kw['output'] = 0 try: (bld.out, bld.err) = bld.cmd_and_log(cmd, **kw) except Exception, e: return -1 if bld.out: bld.to_log("out: %s\n" % bld.out) if bld.err: bld.to_log("err: %s\n" % bld.err) class fcstlib(ccroot.stlink_task): pass feature('fcprogram', 'fcshlib', 'fcstlib', 'fcprogram_test')(dummy) extension('.f', '.f90', '.F', '.F90')(fc_hook)
#! /usr/bin/env python # encoding: utf-8 # WARNING! All changes made to this file will be lost! from waflib.TaskGen import extension from waflib import Task, Utils def add_lua(self, node): tsk = self.create_task('luac', node, node.change_ext('.luac')) inst_to = getattr(self, 'install_path', self.env.LUADIR and '${LUADIR}' or None) if inst_to: self.bld.install_files(inst_to, tsk.outputs) return tsk class luac(Task.Task): run_str = '${LUAC} -s -o ${TGT} ${SRC}' color = 'PINK' def configure(conf): conf.find_program('luac', var='LUAC') extension('.lua')(add_lua)
self.end_msg(False) return None self.end_msg(r or True) return r def check_perl_ext_devel(self): env=self.env perl=env.PERL if not perl: self.fatal('find perl first') def read_out(cmd): return Utils.to_list(self.cmd_and_log(perl+cmd)) env['LINKFLAGS_PERLEXT']=read_out(" -MConfig -e'print $Config{lddlflags}'") env['INCLUDES_PERLEXT']=read_out(" -MConfig -e'print \"$Config{archlib}/CORE\"'") env['CFLAGS_PERLEXT']=read_out(" -MConfig -e'print \"$Config{ccflags} $Config{cccdlflags}\"'") env['XSUBPP']=read_out(" -MConfig -e'print \"$Config{privlib}/ExtUtils/xsubpp$Config{exe_ext}\"'") env['EXTUTILS_TYPEMAP']=read_out(" -MConfig -e'print \"$Config{privlib}/ExtUtils/typemap\"'") if not getattr(Options.options,'perlarchdir',None): env['ARCHDIR_PERL']=self.cmd_and_log(perl+" -MConfig -e'print $Config{sitearch}'") else: env['ARCHDIR_PERL']=getattr(Options.options,'perlarchdir') env['perlext_PATTERN']='%s.'+self.cmd_and_log(perl+" -MConfig -e'print $Config{dlext}'") def options(opt): opt.add_option('--with-perl-binary',type='string',dest='perlbinary',help='Specify alternate perl binary',default=None) opt.add_option('--with-perl-archdir',type='string',dest='perlarchdir',help='Specify directory where to install arch specific files',default=None) before_method('apply_incpaths','apply_link','propagate_uselib_vars')(init_perlext) feature('perlext')(init_perlext) extension('.xs')(xsubpp_file) conf(check_perl_version) conf(check_perl_module) conf(check_perl_ext_devel)
#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file from waflib.TaskGen import extension from waflib import Task,Utils def add_lua(self,node): tsk=self.create_task('luac',node,node.change_ext('.luac')) inst_to=getattr(self,'install_path',self.env.LUADIR and'${LUADIR}'or None) if inst_to: self.bld.install_files(inst_to,tsk.outputs) return tsk class luac(Task.Task): run_str='${LUAC} -s -o ${TGT} ${SRC}' color='PINK' def configure(conf): conf.find_program('luac',var='LUAC') extension('.lua')(add_lua)
def check_vala(self,min_version=(0,8,0),branch=None): if not branch: branch=min_version[:2] try: find_valac(self,'valac-%d.%d'%(branch[0],branch[1]),min_version) except self.errors.ConfigurationError: find_valac(self,'valac',min_version) def check_vala_deps(self): if not self.env['HAVE_GOBJECT']: pkg_args={'package':'gobject-2.0','uselib_store':'GOBJECT','args':'--cflags --libs'} if getattr(Options.options,'vala_target_glib',None): pkg_args['atleast_version']=Options.options.vala_target_glib self.check_cfg(**pkg_args) if not self.env['HAVE_GTHREAD']: pkg_args={'package':'gthread-2.0','uselib_store':'GTHREAD','args':'--cflags --libs'} if getattr(Options.options,'vala_target_glib',None): pkg_args['atleast_version']=Options.options.vala_target_glib self.check_cfg(**pkg_args) def configure(self): self.load('gnu_dirs') self.check_vala_deps() self.check_vala() def options(opt): opt.load('gnu_dirs') valaopts=opt.add_option_group('Vala Compiler Options') valaopts.add_option('--vala-target-glib',default=None,dest='vala_target_glib',metavar='MAJOR.MINOR',help='Target version of glib for Vala GObject code generation') extension('.vala','.gs')(vala_file) conf(find_valac) conf(check_vala) conf(check_vala_deps)
obj_ext = '.res' rctask = self.create_task('winrc', node, node.change_ext(obj_ext)) try: self.compiled_tasks.append(rctask) except AttributeError: self.compiled_tasks = [rctask] class winrc(Task.Task): run_str = '${WINRC} ${WINRCFLAGS} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${WINRC_TGT_F} ${TGT} ${WINRC_SRC_F} ${SRC}' color = 'BLUE' def configure(conf): v = conf.env v['WINRC_TGT_F'] = '-o' v['WINRC_SRC_F'] = '-i' if not conf.env.WINRC: if v.CC_NAME == 'msvc': conf.find_program('RC', var='WINRC', path_list=v['PATH']) v['WINRC_TGT_F'] = '/fo' v['WINRC_SRC_F'] = '' else: conf.find_program('windres', var='WINRC', path_list=v['PATH']) if not conf.env.WINRC: conf.fatal('winrc was not found!') v['WINRCFLAGS'] = [] extension('.rc')(rc_file)
if not node.parent in self.masters: m = self.masters[node.parent] = self.master = self.create_task("batch") self.allmasters.append(m) else: m = self.masters[node.parent] if len(m.slaves) > MAX_BATCH: m = self.masters[node.parent] = self.master = self.create_task("batch") self.allmasters.append(m) m.add_slave(task) return task return n_hook extension(".c")(hook("c")) extension(".cpp", ".cc", ".cxx", ".C", ".c++")(hook("cxx")) @feature("cprogram", "cshlib", "cstaticlib", "cxxprogram", "cxxshlib", "cxxstlib") @after_method("apply_link") def link_after_masters(self): if getattr(self, "allmasters", None): for m in self.allmasters: self.link_task.set_run_after(m) # Modify the c and cxx task classes - in theory it would be better to # create subclasses and to re-map the c/c++ extensions # for x in ["c", "cxx"]:
self.check_cfg(**pkg_args) if not self.env["HAVE_GTHREAD"]: pkg_args = {"package": "gthread-2.0", "uselib_store": "GTHREAD", "args": "--cflags --libs"} if getattr(Options.options, "vala_target_glib", None): pkg_args["atleast_version"] = Options.options.vala_target_glib self.check_cfg(**pkg_args) def configure(self): self.load("gnu_dirs") self.check_vala_deps() self.check_vala() def options(opt): opt.load("gnu_dirs") valaopts = opt.add_option_group("Vala Compiler Options") valaopts.add_option( "--vala-target-glib", default=None, dest="vala_target_glib", metavar="MAJOR.MINOR", help="Target version of glib for Vala GObject code generation", ) extension(".vala", ".gs")(vala_file) conf(find_valac) conf(check_vala) conf(check_vala_deps)
fix_path(m) self.allmasters.append(m) else: m = self.masters[node.parent] if len(m.slaves) > MAX_BATCH: m = self.masters[node.parent] = self.master = self.create_task( "batch") fix_path(m) self.allmasters.append(m) m.add_slave(task) return task return n_hook extension(".c")(hook("c")) extension(".cpp", ".cc", ".cxx", ".C", ".c++")(hook("cxx")) @feature("cprogram", "cshlib", "cstaticlib", "cxxprogram", "cxxshlib", "cxxstlib") @after_method("apply_link") def link_after_masters(self): if getattr(self, "allmasters", None): for m in self.allmasters: self.link_task.set_run_after(m) # Modify the c and cxx task classes - in theory it would be best to # create subclasses and to re-map the c/c++ extensions for x in ("c", "cxx"):
class bison(Task.Task): color = "BLUE" run_str = "${BISON} ${BISONFLAGS} ${SRC[0].abspath()} -o ${TGT[0].name}" ext_out = [".h"] def big_bison(self, 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 = self.create_task("bison", node, outs) tsk.cwd = node.parent.get_bld().abspath() self.source.append(outs[0]) def configure(conf): conf.find_program("bison", var="BISON") conf.env.BISONFLAGS = ["-d"] extension(".y", ".yc", ".yy")(big_bison)
def add_those_o_files(self, node): tsk = self.create_task('fake_o', [], node) try: self.compiled_tasks.append(tsk) except AttributeError: self.compiled_tasks = [tsk] taskgen_method(create_compiled_task) taskgen_method(to_incnodes) feature('c', 'cxx', 'd', 'go', 'asm', 'fc', 'includes')(apply_incpaths) after_method('propagate_uselib_vars', 'process_source')(apply_incpaths) feature('c', 'cxx', 'd', 'go', 'fc', 'asm')(apply_link) after_method('process_source')(apply_link) taskgen_method(use_rec) feature('c', 'cxx', 'd', 'use', 'fc')(process_use) before_method('apply_incpaths', 'propagate_uselib_vars')(process_use) after_method('apply_link', 'process_source')(process_use) taskgen_method(add_objects_from_tgen) taskgen_method(get_uselib_vars) feature('c', 'cxx', 'd', 'fc', 'javac', 'cs', 'uselib')(propagate_uselib_vars) after_method('process_use')(propagate_uselib_vars) feature('cshlib', 'cxxshlib', 'fcshlib')(apply_implib) after_method('apply_link')(apply_implib) feature('cshlib', 'cxxshlib', 'dshlib', 'fcshlib', 'vnum')(apply_vnum) after_method('apply_link')(apply_vnum) conf(read_shlib) conf(read_stlib) feature('fake_lib')(process_lib) extension('.o', '.obj')(add_those_o_files)
class run_ruby(Task.Task): run_str = '${RUBY} ${RBFLAGS} -I ${SRC[0].parent.abspath()} ${SRC}' def options(opt): opt.add_option( '--with-ruby-archdir', type='string', dest='rubyarchdir', help='Specify directory where to install arch specific files') opt.add_option('--with-ruby-libdir', type='string', dest='rubylibdir', help='Specify alternate ruby library path') opt.add_option('--with-ruby-binary', type='string', dest='rubybinary', help='Specify alternate ruby binary') feature('rubyext')(init_rubyext) before_method('apply_incpaths', 'apply_lib_vars', 'apply_bundle', 'apply_link')(init_rubyext) feature('rubyext')(apply_ruby_so_name) before_method('apply_link', 'propagate_uselib')(apply_ruby_so_name) conf(check_ruby_version) conf(check_ruby_ext_devel) conf(check_ruby_module) extension('.rb')(process)
# WARNING! All changes made to this file will be lost! import os,sys,re from waflib import TaskGen,Task from waflib.TaskGen import extension def rc_file(self,node): obj_ext='.rc.o' if self.env['WINRC_TGT_F']=='/fo': obj_ext='.res' rctask=self.create_task('winrc',node,node.change_ext(obj_ext)) self.compiled_tasks.append(rctask) class winrc(Task.Task): run_str='${WINRC} ${WINRCFLAGS} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${WINRC_TGT_F} ${TGT} ${WINRC_SRC_F} ${SRC}' color='BLUE' def configure(conf): v=conf.env v['WINRC_TGT_F']='-o' v['WINRC_SRC_F']='-i' if not conf.env.WINRC: if v.CC_NAME=='msvc': winrc=conf.find_program('RC',var='WINRC',path_list=v['PATH']) v['WINRC_TGT_F']='/fo' v['WINRC_SRC_F']='' else: winrc=conf.find_program('windres',var='WINRC',path_list=v['PATH']) if not conf.env.WINRC: conf.fatal('winrc was not found!') v['WINRCFLAGS']=[] extension('.rc')(rc_file)
self.allmasters = [] if not node.parent in self.masters: m = self.masters[node.parent] = self.master = self.create_task('batch') self.allmasters.append(m) else: m = self.masters[node.parent] if len(m.slaves) > MAX_BATCH: m = self.masters[node.parent] = self.master = self.create_task('batch') self.allmasters.append(m) m.add_slave(task) return task return n_hook extension('.c')(hook('c')) extension('.cpp','.cc','.cxx','.C','.c++')(hook('cxx')) @feature('cprogram', 'cshlib', 'cstaticlib', 'cxxprogram', 'cxxshlib', 'cxxstlib') @after_method('apply_link') def link_after_masters(self): if getattr(self, 'allmasters', None): for m in self.allmasters: self.link_task.set_run_after(m) # Modify the c and cxx task classes - in theory it would be better to # create subclasses and to re-map the c/c++ extensions # for x in ['c', 'cxx']: t = Task.classes[x] def run(self):
self.env.ARCHDIR_RUBY=read_config('sitearchdir')[0] if Options.options.rubylibdir: self.env.LIBDIR_RUBY=Options.options.rubylibdir else: self.env.LIBDIR_RUBY=read_config('sitelibdir')[0] def check_ruby_module(self,module_name): self.start_msg('Ruby module %s'%module_name) try: self.cmd_and_log([self.env['RUBY'],'-e','require \'%s\';puts 1'%module_name]) except: self.end_msg(False) self.fatal('Could not find the ruby module %r'%module_name) self.end_msg(True) def process(self,node): tsk=self.create_task('run_ruby',node) class run_ruby(Task.Task): run_str='${RUBY} ${RBFLAGS} -I ${SRC[0].parent.abspath()} ${SRC}' def options(opt): opt.add_option('--with-ruby-archdir',type='string',dest='rubyarchdir',help='Specify directory where to install arch specific files') opt.add_option('--with-ruby-libdir',type='string',dest='rubylibdir',help='Specify alternate ruby library path') opt.add_option('--with-ruby-binary',type='string',dest='rubybinary',help='Specify alternate ruby binary') feature('rubyext')(init_rubyext) before_method('apply_incpaths','apply_lib_vars','apply_bundle','apply_link')(init_rubyext) feature('rubyext')(apply_ruby_so_name) before_method('apply_link','propagate_uselib')(apply_ruby_so_name) conf(check_ruby_version) conf(check_ruby_ext_devel) conf(check_ruby_module) extension('.rb')(process)
import waflib.Task from waflib.Tools.ccroot import link_task, stlink_task from waflib.TaskGen import extension, feature class asm(Task.Task): color = "BLUE" run_str = "${AS} ${ASFLAGS} ${CPPPATH_ST:INCPATHS} ${AS_SRC_F}${SRC} ${AS_TGT_F}${TGT}" def asm_hook(self, node): return self.create_compiled_task("asm", node) class asmprogram(link_task): run_str = "${ASLINK} ${AS_TGT_F}${TGT} ${SRC}" ext_out = [".bin"] inst_to = "${BINDIR}" chmod = Utils.O755 class asmshlib(asmprogram): inst_to = "${LIBDIR}" class asmstlib(stlink_task): pass extension(".s", ".S", ".asm", ".ASM", ".spp", ".SPP")(asm_hook)
return Task.SKIP_ME def add_those_o_files(self,node): tsk=self.create_task('fake_o',[],node) try: self.compiled_tasks.append(tsk) except AttributeError: self.compiled_tasks=[tsk] taskgen_method(create_compiled_task) taskgen_method(to_incnodes) feature('c','cxx','d','go','asm','fc','includes')(apply_incpaths) after_method('propagate_uselib_vars','process_source')(apply_incpaths) feature('c','cxx','d','go','fc','asm')(apply_link) after_method('process_source')(apply_link) taskgen_method(use_rec) feature('c','cxx','d','use','fc')(process_use) before_method('apply_incpaths','propagate_uselib_vars')(process_use) after_method('apply_link','process_source')(process_use) taskgen_method(add_objects_from_tgen) taskgen_method(get_uselib_vars) feature('c','cxx','d','fc','javac','cs','uselib')(propagate_uselib_vars) after_method('process_use')(propagate_uselib_vars) feature('cshlib','cxxshlib','fcshlib')(apply_implib) after_method('apply_link')(apply_implib) feature('cshlib','cxxshlib','dshlib','fcshlib','vnum')(apply_vnum) after_method('apply_link')(apply_vnum) conf(read_shlib) conf(read_stlib) feature('fake_lib')(process_lib) extension('.o','.obj')(add_those_o_files)
def options(opt): opt.add_option( "--nopyc", action="store_false", default=1, help="Do not install bytecode compiled .pyc files (configuration) [Default:install]", dest="pyc", ) opt.add_option( "--nopyo", action="store_false", default=1, help="Do not install optimised compiled .pyo files (configuration) [Default:install]", dest="pyo", ) extension(".py")(process_py) feature("py")(feature_py) feature("pyext")(init_pyext) before_method("propagate_uselib_vars", "apply_link")(init_pyext) after_method("apply_bundle")(init_pyext) feature("pyext")(set_bundle) before_method("apply_link", "apply_bundle")(set_bundle) before_method("propagate_uselib_vars")(init_pyembed) feature("pyembed")(init_pyembed) conf(get_python_variables) conf(check_python_headers) conf(check_python_version) conf(check_python_module)
pkg_args = { 'package': 'gthread-2.0', 'uselib_store': 'GTHREAD', 'args': '--cflags --libs' } if getattr(Options.options, 'vala_target_glib', None): pkg_args['atleast_version'] = Options.options.vala_target_glib self.check_cfg(**pkg_args) def configure(self): self.load('gnu_dirs') self.check_vala_deps() self.check_vala() def options(opt): opt.load('gnu_dirs') valaopts = opt.add_option_group('Vala Compiler Options') valaopts.add_option( '--vala-target-glib', default=None, dest='vala_target_glib', metavar='MAJOR.MINOR', help='Target version of glib for Vala GObject code generation') extension('.vala', '.gs')(vala_file) conf(find_valac) conf(check_vala) conf(check_vala_deps)
if not yasm: conf.fatal('could not find yasm, install it or set PATH env var') conf.env.AS_TGT_F = ['-o'] conf.env.ASLNK_TGT_F = ['-o'] def apply_yasm_vars(self): self.env.append_value('YASM_FLAGS', self.to_list(getattr(self, 'yasm_flags', []))) self.env.append_value( 'YASM_INCLUDES', " -I".join([''] + self.to_list(self.env.INCPATHS)).split()) feature('asm')(apply_yasm_vars) Task.simple_task_type( 'yasm', '${YASM} ${YASM_FLAGS} ${YASM_INCLUDES} ${SRC} -o ${TGT}', color='BLUE', ext_out='.o', shell=False) def yasm_hook(self, node): self.meths.append('apply_yasm_vars') return self.create_compiled_task('yasm', node) extension('.s')(yasm_hook)
try: conf.find_program('python',var='PYTHON') except conf.errors.ConfigurationError: warn("could not find a python executable, setting to sys.executable '%s'"%sys.executable) conf.env.PYTHON=sys.executable if conf.env.PYTHON!=sys.executable: warn("python executable '%s' different from sys.executable '%s'"%(conf.env.PYTHON,sys.executable)) conf.env.PYTHON=conf.cmd_to_list(conf.env.PYTHON) v=conf.env v['PYCMD']='"import sys, py_compile;py_compile.compile(sys.argv[1], sys.argv[2])"' v['PYFLAGS']='' v['PYFLAGS_OPT']='-O' v['PYC']=getattr(Options.options,'pyc',1) v['PYO']=getattr(Options.options,'pyo',1) def options(opt): opt.add_option('--nopyc',action='store_false',default=1,help='Do not install bytecode compiled .pyc files (configuration) [Default:install]',dest='pyc') opt.add_option('--nopyo',action='store_false',default=1,help='Do not install optimised compiled .pyo files (configuration) [Default:install]',dest='pyo') extension('.py')(process_py) feature('py')(feature_py) feature('pyext')(init_pyext) before_method('propagate_uselib_vars','apply_link')(init_pyext) after_method('apply_bundle')(init_pyext) feature('pyext')(set_bundle) before_method('apply_link','apply_bundle')(set_bundle) before_method('propagate_uselib_vars')(init_pyembed) feature('pyembed')(init_pyembed) conf(get_python_variables) conf(check_python_headers) conf(check_python_version) conf(check_python_module)
#! /usr/bin/env python # encoding: utf-8 # WARNING! All changes made to this file will be lost! import os,sys import waflib.Task from waflib.TaskGen import extension,feature class asm(waflib.Task.Task): color='BLUE' run_str='${AS} ${ASFLAGS} ${CPPPATH_ST:INCPATHS} ${AS_SRC_F}${SRC} ${AS_TGT_F}${TGT}' def asm_hook(self,node): return self.create_compiled_task('asm',node) extension('.s','.S','.asm','.ASM','.spp','.SPP')(asm_hook)
def d_hook(self,node): ext=Utils.destos_to_binfmt(self.env.DEST_OS)=='pe'and'obj'or'o' out='%s.%d.%s'%(node.name,self.idx,ext) def create_compiled_task(self,name,node): task=self.create_task(name,node,node.parent.find_or_declare(out)) try: self.compiled_tasks.append(task) except AttributeError: self.compiled_tasks=[task] return task if getattr(self,'generate_headers',None): tsk=create_compiled_task(self,'d_with_header',node) tsk.outputs.append(node.change_ext(self.env['DHEADER_ext'])) else: tsk=create_compiled_task(self,'d',node) return tsk def generate_header(self,filename,install_path=None): try: self.header_lst.append([filename,install_path]) except AttributeError: self.header_lst=[[filename,install_path]] def process_header(self): for i in getattr(self,'header_lst',[]): node=self.path.find_resource(i[0]) if not node: raise Errors.WafError('file %r not found on d obj'%i[0]) self.create_task('d_header',node,node.change_ext('.di')) extension('.d','.di','.D')(d_hook) taskgen_method(generate_header) feature('d')(process_header)
inst_to='${LIBDIR}' class fcprogram_test(fcprogram): def can_retrieve_cache(self): return False def runnable_status(self): ret=super(fcprogram_test,self).runnable_status() if ret==Task.SKIP_ME: ret=Task.RUN_ME return ret def exec_command(self,cmd,**kw): bld=self.generator.bld kw['shell']=isinstance(cmd,str) kw['stdout']=kw['stderr']=Utils.subprocess.PIPE kw['cwd']=bld.variant_dir bld.out=bld.err='' bld.to_log('command: %s\n'%cmd) kw['output']=0 try: (bld.out,bld.err)=bld.cmd_and_log(cmd,**kw) except Exception ,e: return-1 if bld.out: bld.to_log("out: %s\n"%bld.out) if bld.err: bld.to_log("err: %s\n"%bld.err) class fcstlib(ccroot.stlink_task): pass feature('fcprogram','fcshlib','fcstlib','fcprogram_test')(dummy) extension('.f','.f90','.F','.F90')(fc_hook)
opt.add_option('--header-ext', type='string', default='', help='header extension for moc files', dest='qt_header_ext') for i in 'qtdir qtbin qtlibs'.split(): opt.add_option('--' + i, type='string', default='', dest=i) if sys.platform == "darwin": opt.add_option('--no-qt4-framework', action="store_false", help='do not use the framework version of Qt4 in OS X', dest='use_qt4_osxframework', default=True) opt.add_option('--translate', action="store_true", help="collect translation strings", dest="trans_qt4", default=False) extension(*EXT_RCC)(create_rcc_task) extension(*EXT_UI)(create_uic_task) extension('.ts')(add_lang) feature('qt4')(apply_qt4) after_method('apply_link')(apply_qt4) extension(*EXT_QT4)(cxx_hook) conf(find_qt4_binaries) conf(find_qt4_libraries) conf(simplify_qt4_libs) conf(add_qt4_rpath) conf(set_qt4_libs_to_check)
self.allmasters = [] if not node.parent in self.masters: m = self.masters[node.parent] = self.master = self.create_task('batch') self.allmasters.append(m) else: m = self.masters[node.parent] if len(m.slaves) > MAX_BATCH: m = self.masters[node.parent] = self.master = self.create_task('batch') self.allmasters.append(m) m.add_slave(task) return task return n_hook extension('.c')(hook('c')) extension('.cpp','.cc','.cxx','.C','.c++')(hook('cxx')) @feature('cprogram', 'cshlib', 'cstaticlib', 'cxxprogram', 'cxxshlib', 'cxxstlib') @after_method('apply_link') def link_after_masters(self): if getattr(self, 'allmasters', None): for m in self.allmasters: self.link_task.set_run_after(m) # Modify the c and cxx task classes - in theory it would be better to # create subclasses and to re-map the c/c++ extensions # for x in ('c', 'cxx'): t = Task.classes[x] def run(self):
inst_to='${LIBDIR}' class fcprogram_test(fcprogram): def can_retrieve_cache(self): return False def runnable_status(self): ret=super(fcprogram_test,self).runnable_status() if ret==Task.SKIP_ME: ret=Task.RUN_ME return ret def exec_command(self,cmd,**kw): bld=self.generator.bld kw['shell']=isinstance(cmd,str) kw['stdout']=kw['stderr']=Utils.subprocess.PIPE kw['cwd']=bld.variant_dir bld.out=bld.err='' bld.to_log('command: %s\n'%cmd) kw['output']=0 try: (bld.out,bld.err)=bld.cmd_and_log(cmd,**kw) except Exception ,e: return-1 if bld.out: bld.to_log("out: %s\n"%bld.out) if bld.err: bld.to_log("err: %s\n"%bld.err) class fcstlib(ccroot.stlink_task): pass feature('fcprogram','fcshlib','fcstlib','fcprogram_test')(dummy) extension('.f','.f90','.F','.F90','.for','.FOR')(fc_hook) conf(modfile)
def runnable_status(self): ret = super(fcprogram_test, self).runnable_status() if ret == Task.SKIP_ME: ret = Task.RUN_ME return ret def exec_command(self, cmd, **kw): bld = self.generator.bld kw['shell'] = isinstance(cmd, str) kw['stdout'] = kw['stderr'] = Utils.subprocess.PIPE kw['cwd'] = bld.variant_dir bld.out = bld.err = '' bld.to_log('command: %s\n' % cmd) kw['output'] = 0 try: (bld.out, bld.err) = bld.cmd_and_log(cmd, **kw) except Exception, e: return -1 if bld.out: bld.to_log("out: %s\n" % bld.out) if bld.err: bld.to_log("err: %s\n" % bld.err) class fcstlib(ccroot.stlink_task): pass feature('fcprogram', 'fcshlib', 'fcstlib', 'fcprogram_test')(dummy) extension('.f', '.f90', '.F', '.F90', '.for', '.FOR')(fc_hook) conf(modfile)
class bison(Task.Task): color = 'BLUE' run_str = '${BISON} ${BISONFLAGS} ${SRC[0].abspath()} -o ${TGT[0].name}' ext_out = ['.h'] def big_bison(self, 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 = self.create_task('bison', node, outs) tsk.cwd = node.parent.get_bld().abspath() self.source.append(outs[0]) def configure(conf): conf.find_program('bison', var='BISON') conf.env.BISONFLAGS = ['-d'] extension('.y', '.yc', '.yy')(big_bison)
#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! http://waf.googlecode.com/svn/docs/wafbook/single.html#_obtaining_the_waf_file from waflib import Task from waflib.TaskGen import extension class bison(Task.Task): color='BLUE' run_str='${BISON} ${BISONFLAGS} ${SRC[0].abspath()} -o ${TGT[0].name}' ext_out=['.h'] def big_bison(self,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=self.create_task('bison',node,outs) tsk.cwd=node.parent.get_bld().abspath() self.source.append(outs[0]) def configure(conf): conf.find_program('bison',var='BISON') conf.env.BISONFLAGS=['-d'] extension('.y','.yc','.yy')(big_bison)
#! /usr/bin/env python # encoding: utf-8 import waflib.Tools.asm from waflib.TaskGen import feature, extension from waflib import Task def configure(conf): yasm=conf.find_program(['yasm'],var='YASM',path_list=['/usr/bin','/usr/local/bin']) if not yasm:conf.fatal('could not find yasm, install it or set PATH env var') conf.env.AS_TGT_F=['-o'] conf.env.ASLNK_TGT_F=['-o'] def apply_yasm_vars(self): self.env.append_value('YASM_FLAGS',self.to_list(getattr(self,'yasm_flags',[]))) self.env.append_value('YASM_INCLUDES'," -I".join([''] + self.to_list(self.env.INCPATHS)).split()) feature('asm')(apply_yasm_vars) Task.simple_task_type('yasm','${YASM} ${YASM_FLAGS} ${YASM_INCLUDES} ${SRC} -o ${TGT}',color='BLUE',ext_out='.o',shell=False) def yasm_hook(self,node): self.meths.append('apply_yasm_vars') return self.create_compiled_task('yasm',node) extension('.s')(yasm_hook)
env['EXTUTILS_TYPEMAP'] = read_out( " -MConfig -e'print \"$Config{privlib}/ExtUtils/typemap\"'") if not getattr(Options.options, 'perlarchdir', None): env['ARCHDIR_PERL'] = self.cmd_and_log( perl + " -MConfig -e'print $Config{sitearch}'") else: env['ARCHDIR_PERL'] = getattr(Options.options, 'perlarchdir') env['perlext_PATTERN'] = '%s.' + self.cmd_and_log( perl + " -MConfig -e'print $Config{dlext}'") def options(opt): opt.add_option('--with-perl-binary', type='string', dest='perlbinary', help='Specify alternate perl binary', default=None) opt.add_option( '--with-perl-archdir', type='string', dest='perlarchdir', help='Specify directory where to install arch specific files', default=None) before('apply_incpaths', 'apply_link', 'propagate_uselib_vars')(init_perlext) feature('perlext')(init_perlext) extension('.xs')(xsubpp_file) conf(check_perl_version) conf(check_perl_module) conf(check_perl_ext_devel)
pass def d_hook(self, node): if getattr(self, 'generate_headers', None): task = self.create_compiled_task('d_with_header', node) header_node = node.change_ext(self.env['DHEADER_ext']) task.outputs.append(header_node) else: task = self.create_compiled_task('d', node) return task def generate_header(self, filename, install_path=None): try: self.header_lst.append([filename, install_path]) except AttributeError: self.header_lst = [[filename, install_path]] def process_header(self): for i in getattr(self, 'header_lst', []): node = self.path.find_resource(i[0]) if not node: raise Errors.WafError('file %r not found on d obj' % i[0]) self.create_task('d_header', node, node.change_ext('.di')) extension('.d', '.di', '.D')(d_hook) taskgen_method(generate_header) feature('d')(process_header)
def add_those_o_files(self, node): tsk = self.create_task("fake_o", [], node) try: self.compiled_tasks.append(tsk) except AttributeError: self.compiled_tasks = [tsk] taskgen_method(create_compiled_task) taskgen_method(to_incnodes) feature("c", "cxx", "d", "go", "asm", "fc", "includes")(apply_incpaths) after_method("propagate_uselib_vars", "process_source")(apply_incpaths) feature("c", "cxx", "d", "go", "fc", "asm")(apply_link) after_method("process_source")(apply_link) taskgen_method(use_rec) feature("c", "cxx", "d", "use", "fc")(process_use) before_method("apply_incpaths", "propagate_uselib_vars")(process_use) after_method("apply_link", "process_source")(process_use) taskgen_method(add_objects_from_tgen) taskgen_method(get_uselib_vars) feature("c", "cxx", "d", "fc", "javac", "cs", "uselib")(propagate_uselib_vars) after_method("process_use")(propagate_uselib_vars) feature("cshlib", "cxxshlib", "fcshlib")(apply_implib) after_method("apply_link")(apply_implib) feature("cshlib", "cxxshlib", "dshlib", "fcshlib", "vnum")(apply_vnum) after_method("apply_link")(apply_vnum) conf(read_shlib) conf(read_stlib) feature("fake_lib")(process_lib) extension(".o", ".obj")(add_those_o_files)