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)
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 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('apply_incpaths', 'apply_lib_vars', 'apply_bundle', 'apply_link')(init_rubyext) after('vars_target_cshlib')(init_rubyext) feature('rubyext')(apply_ruby_so_name) before('apply_link', 'propagate_uselib')(apply_ruby_so_name) conf(check_ruby_version) conf(check_ruby_ext_devel)
x.logger.memhandler.flush() for x in tasks: if x.hasrun!=Task.SUCCESS: self.end_msg(kw.get('errmsg','no'),color='YELLOW') self.fatal(kw.get('fatalmsg',None)or'One of the tests has failed, see the config.log for more information') self.end_msg('ok') conf(parse_flags) conf(ret_msg) conf(validate_cfg) conf(exec_cfg) conf(check_cfg) conf(validate_c) conf(post_check) conf(check) feature('test_exec')(test_exec_fun) after_method('apply_link')(test_exec_fun) conf(run_c_code) conf(check_cxx) conf(check_cc) conf(define) conf(undefine) conf(define_cond) conf(is_defined) conf(get_define) conf(have_define) conf(write_config_header) conf(get_config_header) conf(cc_add_flags) conf(cxx_add_flags) conf(link_add_flags)
bld.cwd=kw['cwd']=bld.variant_dir ret=self.exec_response_command(k[0],**kw) if not ret and getattr(self,'do_manifest',None): ret=self.exec_mf() return ret for k in'c cxx winrc cprogram cxxprogram cshlib cxxshlib cstlib cxxstlib qxx'.split(): cls=Task.classes.get(k,None) if cls: cls.exec_command=exec_command_msvc cls.exec_response_command=exec_response_command cls.quote_response_command=quote_response_command cls.exec_mf=exec_mf conf(get_msvc_version) conf(gather_wsdk_versions) conf(gather_msvc_versions) conf(gather_icl_versions) conf(get_msvc_versions) conf(print_all_msvc_detected) conf(find_lt_names_msvc) conf(libname_msvc) conf(check_lib_msvc) conf(check_libs_msvc) conf(no_autodetect) conf(autodetect) conf(find_msvc) conf(msvc_common_flags) after('apply_link')(apply_flags_msvc) feature('c','cxx')(apply_flags_msvc) feature('cprogram','cshlib','cxxprogram','cxxshlib')(apply_manifest) after('apply_link')(apply_manifest)
n1=dir.find_or_declare(['Contents','Info.plist']) plisttask.set_outputs([n1]) plisttask.mac_plist=self.mac_plist plisttask.install_path=os.path.join(self.install_path,name,'Contents') self.plisttask=plisttask def apply_bundle(self): if self.env['MACBUNDLE']or getattr(self,'mac_bundle',False): self.env['LINKFLAGS_cshlib']=self.env['LINKFLAGS_cxxshlib']=[] self.env['cshlib_PATTERN']=self.env['cxxshlib_PATTERN']=self.env['macbundle_PATTERN'] use=self.use=self.to_list(getattr(self,'use',[])) if not'MACBUNDLE'in use: use.append('MACBUNDLE') app_dirs=['Contents','Contents/MacOS','Contents/Resources'] class macapp(Task.Task): color='PINK' def run(self): shutil.copy2(self.inputs[0].srcpath(),self.outputs[0].abspath()) class macplist(Task.Task): color='PINK' ext_in=['.bin'] def run(self): self.outputs[0].write(self.mac_plist) feature('c','cxx')(set_macosx_deployment_target) taskgen_method(create_bundle_dirs) feature('cprogram','cxxprogram')(create_task_macapp) after_method('apply_link')(create_task_macapp) feature('cprogram','cxxprogram')(create_task_macplist) after_method('apply_link')(create_task_macplist) feature('cshlib','cxxshlib')(apply_bundle) before_method('apply_link','propagate_uselib_vars')(apply_bundle)
fname = '%s/share/kde4/apps/cmake/modules/KDELibsDependencies.cmake' % prefix try: os.stat(fname) except OSError: self.fatal('could not open %s' % fname) try: txt = Utils.readf(fname) except (OSError, IOError): self.fatal('could not read %s' % fname) txt = txt.replace('\\\n', '\n') fu = re.compile('#(.*)\n') txt = fu.sub('', txt) setregexp = re.compile('([sS][eE][tT]\s*\()\s*([^\s]+)\s+\"([^"]+)\"\)') found = setregexp.findall(txt) for (_, key, val) in found: self.env[key] = val self.env['LIB_KDECORE'] = ['kdecore'] self.env['LIB_KDEUI'] = ['kdeui'] self.env['LIB_KIO'] = ['kio'] self.env['LIB_KHTML'] = ['khtml'] self.env['LIB_KPARTS'] = ['kparts'] self.env['LIBPATH_KDECORE'] = [self.env['KDE4_LIB_INSTALL_DIR']] self.env['INCLUDES_KDECORE'] = [self.env['KDE4_INCLUDE_INSTALL_DIR']] self.env.append_value( 'INCLUDES_KDECORE', [self.env['KDE4_INCLUDE_INSTALL_DIR'] + os.sep + 'KDE']) self.find_program('msgfmt', var='MSGFMT') feature('msgfmt')(apply_msgfmt)
return sorted(seen, key=methodcaller('srcpath')), None def keyword(self): return "Documenting module" def __str__(self): return self.env.MODULE class gz(Task): run_str = "gzip -c ${SRC} > ${TGT}" def keyword(self): return "Compressing" feature("entrypynt")(feature_py) # This makes sure install_from is either None or a Node which generate_python_starter relies upon. @feature("entrypynt") @after_method("feature_py") def compose_environment(self): parent = getattr(self, 'parent', None) if parent: self.env = parent.env else: env = self.env def flag(*args): env.append_value("MANPAGERFLAGS", args) short_desc = getattr(self, 'short', None) if short_desc: flag("-d", "'{}'".format(short_desc))
incDirs = [x.parent.abspath() for x in f] dir = conf.root.find_dir(conf.env.JAVA_HOME[0]) f = dir.ant_glob("**/*jvm.(so|dll)") libDirs = [x.parent.abspath() for x in f] or [javaHome] for i, d in enumerate(libDirs): if conf.check( header_name="jni.h", define_name="HAVE_JNI_H", lib="jvm", libpath=d, includes=incDirs, uselib_store="JAVA", uselib="JAVA", ): break else: conf.fatal("could not find lib jvm in %r (see config.log)" % libDirs) feature("javac")(apply_java) before("process_source")(apply_java) feature("javac")(use_javac_files) after("apply_java")(use_javac_files) feature("jar")(jar_files) after("apply_java", "use_javac_files")(jar_files) before("process_source")(jar_files) feature("jar")(use_jar_files) after("jar_files")(use_jar_files) conf(check_java_class) conf(check_jni_headers)
bld.utest_results = [tup] finally: testlock.release() def summary(bld): lst = getattr(bld, 'utest_results', []) if lst: Logs.pprint('CYAN', 'execution summary') total = len(lst) tfail = len([x for x in lst if x[1]]) Logs.pprint('CYAN', ' tests that pass %d/%d' % (total - tfail, total)) for (f, code, out, err) in lst: if not code: Logs.pprint('CYAN', ' %s' % f) Logs.pprint('CYAN', ' tests that fail %d/%d' % (tfail, total)) for (f, code, out, err) in lst: if code: Logs.pprint('CYAN', ' %s' % f) def options(opt): opt.add_option('--alltests', action='store_true', default=False, help='Exec all unit tests', dest='all_tests') feature('test')(make_test) after('apply_link')(make_test)
return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; ''' class grep_for_endianness(Task.Task): color='PINK' def run(self): txt=self.inputs[0].read(flags='rb').decode('iso8859-1') if txt.find('LiTTleEnDian')>-1: self.generator.tmp.append('little') elif txt.find('BIGenDianSyS')>-1: self.generator.tmp.append('big') else: return-1 def grep_for_endianness_fun(self): self.create_task('grep_for_endianness',self.compiled_tasks[0].outputs[0]) def check_endianness(self): tmp=[] def check_msg(self): return tmp[0] self.check(fragment=ENDIAN_FRAGMENT,features='c grep_for_endianness',msg="Checking for endianness",define='ENDIANNESS',tmp=tmp,okmsg=check_msg) return tmp[0] feature('link_lib_test')(link_lib_test_fun) before_method('process_source')(link_lib_test_fun) conf(check_library) conf(check_inline) conf(check_large_file) feature('grep_for_endianness')(grep_for_endianness_fun) after_method('process_source')(grep_for_endianness_fun) conf(check_endianness)
else: Logs.pprint('RED', "Error no LINGUAS file found in po directory") class po(Task.Task): run_str = '${MSGFMT} -o ${TGT} ${SRC}' color = 'BLUE' class intltool(Task.Task): run_str = '${INTLTOOL} ${INTLFLAGS} ${INTLCACHE} ${INTLPODIR} ${SRC} ${TGT}' color = 'BLUE' def configure(conf): conf.find_program('msgfmt', var='MSGFMT') conf.find_perl_program('intltool-merge', var='INTLTOOL') prefix = conf.env.PREFIX datadir = conf.env.DATADIR if not datadir: datadir = os.path.join(prefix, 'share') conf.define('LOCALEDIR', os.path.join(datadir, 'locale').replace('\\', '\\\\')) conf.define('DATADIR', datadir.replace('\\', '\\\\')) if conf.env.CC or conf.env.CXX: conf.check(header_name='locale.h') before_method('process_source')(apply_intltool_in_f) feature('intltool_in')(apply_intltool_in_f) feature('intltool_po')(apply_intltool_po)
# 5. 6c import create_plan9c_task(cgo_import) # 6. add some of the gcc tasks to compiled_tasks for task in tg.compiled_tasks: if task.inputs[0].name.endswith('_cgo_main.c'): continue self.compiled_tasks.append(task) # restore the group self.bld.set_group(current_group) decorate( feature('cgo'), before_method('apply_incpaths', 'propagate_uselib_vars'), after_method('apply_link', 'process_source'), process_use, ) decorate( feature('cgo'), after_method('process_use'), propagate_uselib_vars, ) def check_tool_loaded(conf, thetool): for tool in conf.tools: if tool['tool'] == thetool: return True
""" for some obscure reason, the precompiled header will not be taken if all.h is in the same directory as main.cpp we recommend to add the header to compile in a separate directory without any sources Note: the #warning will come once when the .h is compiled, it will not come when the .cpp is compiled Note: do not forget to set the include paths (include=...) """ from waflib.TaskGen import feature, after from waflib.Task import Task from waflib.Tools import c_preproc #@feature('cxx') <- python >= 2.4 #@after('apply_link') def process_pch(self): if getattr(self, 'pch', ''): nodes = self.to_nodes(self.pch) for x in nodes: self.create_task('gchx', x, x.change_ext('.gch')) feature('cxx')(process_pch) after('apply_link')(process_pch) class gchx(Task): run_str = '${CXX} ${CXXFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT}' scan = c_preproc.scan ext_out = ['.h'] color = 'BLUE'
if ctx.check_java_class(val, with_classpath=cp): ctx.fatal('Could not run junit from %r' % val) ctx.env.CLASSPATH_JUNIT = cp #@feature('junit') #@after('apply_java', 'use_javac_files') def make_test(self): """make the unit test task""" if not getattr(self, 'junitsrc', None): return junit_task = self.create_task('junit_test') try: junit_task.set_run_after(self.javac_task) except AttributeError: pass feature('junit')(make_test) after('apply_java', 'use_javac_files')(make_test) class junit_test(Task.Task): color = 'YELLOW' vars = ['JUNIT_EXEC_FLAGS', 'JUNIT_RUNNER'] def runnable_status(self): """ Only run if --junit was set as an option """ for t in self.run_after: if not t.hasrun: return Task.ASK_LATER n = self.generator.path.find_dir(self.generator.junitsrc)
) 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)
else: no_nodes.append(x) self.source = no_nodes bintype = getattr(self, 'type', self.gen.endswith('.dll') and 'library' or 'exe') self.cs_task = tsk = self.create_task('fsc', cs_nodes, self.path.find_or_declare(self.gen)) tsk.env.CSTYPE = '/target:%s' % bintype tsk.env.OUT = '/out:%s' % tsk.outputs[0].abspath() inst_to = getattr(self, 'install_path', bintype=='exe' and '${BINDIR}' or '${LIBDIR}') if inst_to: # note: we are making a copy, so the files added to cs_task.outputs won't be installed automatically mod = getattr(self, 'chmod', bintype=='exe' and Utils.O755 or Utils.O644) self.install_task = self.add_install_files(install_to=inst_to, install_from=self.cs_task.outputs[:], chmod=mod) feature('fs')(cs.use_cs) after_method('apply_fsc')(cs.use_cs) feature('fs')(cs.debug_cs) after_method('apply_fsc', 'use_cs')(cs.debug_cs) class fsc(Task.Task): """ Compile F# files """ color = 'YELLOW' run_str = '${FSC} ${CSTYPE} ${CSFLAGS} ${ASS_ST:ASSEMBLIES} ${RES_ST:RESOURCES} ${OUT} ${SRC}' def configure(conf): """ Find a F# compiler, set the variable FSC for the compiler and FS_NAME (mono or fsc)
task = self.create_task('go', src_nodes, obj_node) try: self.compiled_tasks.append(task) except AttributeError: self.compiled_tasks = [task] def decorate(*args): decorators = args[:-1] func = args[-1] for d in reversed(decorators): func = d(func) decorate( feature('go'), after_method('propagate_uselib_vars', 'process_source'), apply_incpaths, ) decorate( feature('goprogram', 'gopackage'), after_method('process_source'), apply_link, ) ######################################################################## # Configuration ######################################################################## @conf
for(u,du,c)in mangling_schemes(): try: self.check_cc(compile_filename=[],features='link_main_routines_func',msg='nomsg',errmsg='nomsg',mandatory=True,dummy_func_nounder=mangle_name(u,du,c,"foobar"),dummy_func_under=mangle_name(u,du,c,"foo_bar"),main_func_name=self.env.FC_MAIN) except self.errors.ConfigurationError: pass else: self.end_msg("ok ('%s', '%s', '%s-case')"%(u,du,c)) self.env.FORTRAN_MANGLING=(u,du,c) break else: self.end_msg(False) self.fatal('mangler not found') return(u,du,c) def set_lib_pat(self): self.env['fcshlib_PATTERN']=self.env['pyext_PATTERN'] conf(fc_flags) conf(check_fortran) conf(check_fc) conf(fortran_modifier_darwin) conf(fortran_modifier_win32) conf(fortran_modifier_cygwin) conf(check_fortran_dummy_main) conf(is_link_verbose) conf(check_fortran_verbose_flag) conf(check_fortran_clib) feature('link_main_routines_func')(link_main_routines_tg_method) before_method('process_source')(link_main_routines_tg_method) conf(check_fortran_mangling) feature('pyext')(set_lib_pat) before_method('propagate_uselib_vars','apply_link')(set_lib_pat)
from __future__ import division from __future__ import absolute_import from __future__ import print_function import pprint pp = pprint.pprint from waflib import Utils from waflib import Task, TaskGen from waflib.TaskGen import feature from .vendor.distlib.database import make_graph #...do not invoke default rule/ext methods! TaskGen.feats['*'].clear() feature('*')(Utils.nada) @feature('zpy-requirements') def zpy_requirements(gen): env = gen.env bld = gen.bld zpy = bld.zpy _tsk = getattr(gen, 'task', 'ZPyTask_Requirements') for dist in getattr(gen, 'source', tuple()): out = bld.bldnode.make_node(str(dist.key)) tsk = gen.create_task(_tsk, tgt=out.make_node('setup.py')) tsk.dist = dist
test = self.create_task('utest', deps_list) if not hasattr(test.__class__, '__oldstr__'): test.__class__.__oldstr__ = test.__class__.__str__ test.__class__.__str__ = systest_task_str test.__class__.run = systest_task_run test.__unicode__ = systest_task_str test.sys = sysname test.ram = sdramname or sramname or "" test.rom = romname test.atstr = atstr test.filename = filename test.ut_exec = exec_list + param from waflib.TaskGen import feature, after_method, before_method, task_gen feature('systest')(make_systest) after_method('apply_link')(make_systest) # ASM hooks for the gcc compiler def s_hook(self, node): return self.create_compiled_task('c', node) TaskGen.extension('.S')(s_hook) MKPROM = Task.task_factory('MKPROM', func='${MKPROM} ${_MKPROMFLAGS} -o ${TGT} ${SRC}', color='YELLOW') MKPROM_TSKS = list()
Task.task_factory( "intltool", "${INTLTOOL} ${INTLFLAGS} ${INTLCACHE} ${INTLPODIR} ${SRC} ${TGT}", color="BLUE", ext_in=".bin" ) def configure(conf): conf.find_program("msgfmt", var="MSGFMT") conf.find_perl_program("intltool-merge", var="INTLTOOL") def getstr(varname): return getattr(Options.options, varname, "") prefix = conf.env["PREFIX"] datadir = getstr("datadir") if not datadir: datadir = os.path.join(prefix, "share") conf.define("LOCALEDIR", os.path.join(datadir, "locale")) conf.define("DATADIR", datadir) if conf.env["CC"] or conf.env["CXX"]: conf.check(header_name="locale.h") def options(opt): opt.add_option("--want-rpath", type="int", default=1, dest="want_rpath", help="set rpath to 1 or 0 [Default 1]") opt.add_option("--datadir", type="string", default="", dest="datadir", help="read-only application data") before("process_source")(iapply_intltool_in_f) feature("intltool_in")(iapply_intltool_in_f) feature("intltool_po")(apply_intltool_po)
app_dirs = ['Contents', 'Contents/MacOS', 'Contents/Resources'] class macapp(Task.Task): color = 'PINK' def run(self): self.outputs[0].parent.mkdir() shutil.copy2(self.inputs[0].srcpath(), self.outputs[0].abspath()) class macplist(Task.Task): color = 'PINK' ext_in = ['.bin'] def run(self): if getattr(self, 'code', None): txt = self.code else: txt = self.inputs[0].read() self.outputs[0].write(txt) feature('c', 'cxx')(set_macosx_deployment_target) taskgen_method(create_bundle_dirs) feature('cprogram', 'cxxprogram')(create_task_macapp) after_method('apply_link')(create_task_macapp) feature('cprogram', 'cxxprogram')(create_task_macplist) after_method('apply_link')(create_task_macplist) feature('cshlib', 'cxxshlib')(apply_bundle) before_method('apply_link', 'propagate_uselib_vars')(apply_bundle)
if re_linguas.match(lang): node=self.path.find_resource(os.path.join(podir,re_linguas.match(lang).group()+'.po')) task=self.create_task('po',node,node.change_ext('.mo')) if inst: filename=task.outputs[0].name (langname,ext)=os.path.splitext(filename) inst_file=inst+os.sep+langname+os.sep+'LC_MESSAGES'+os.sep+appname+'.mo' self.bld.install_as(inst_file,task.outputs[0],chmod=getattr(self,'chmod',Utils.O644),env=task.env) else: Logs.pprint('RED',"Error no LINGUAS file found in po directory") class po(Task.Task): run_str='${MSGFMT} -o ${TGT} ${SRC}' color='BLUE' class intltool(Task.Task): run_str='${INTLTOOL} ${INTLFLAGS} ${INTLCACHE} ${INTLPODIR} ${SRC} ${TGT}' color='BLUE' def configure(conf): conf.find_program('msgfmt',var='MSGFMT') conf.find_perl_program('intltool-merge',var='INTLTOOL') prefix=conf.env.PREFIX datadir=conf.env.DATADIR if not datadir: datadir=os.path.join(prefix,'share') conf.define('LOCALEDIR',os.path.join(datadir,'locale').replace('\\','\\\\')) conf.define('DATADIR',datadir.replace('\\','\\\\')) if conf.env.CC or conf.env.CXX: conf.check(header_name='locale.h') before_method('process_source')(apply_intltool_in_f) feature('intltool_in')(apply_intltool_in_f) feature('intltool_po')(apply_intltool_po)
kdeconfig=self.find_program('kde4-config') prefix=self.cmd_and_log('%s --prefix'%kdeconfig).strip() fname='%s/share/apps/cmake/modules/KDELibsDependencies.cmake'%prefix try:os.stat(fname) except OSError: fname='%s/share/kde4/apps/cmake/modules/KDELibsDependencies.cmake'%prefix try:os.stat(fname) except OSError:self.fatal('could not open %s'%fname) try: txt=Utils.readf(fname) except(OSError,IOError): self.fatal('could not read %s'%fname) txt=txt.replace('\\\n','\n') fu=re.compile('#(.*)\n') txt=fu.sub('',txt) setregexp=re.compile('([sS][eE][tT]\s*\()\s*([^\s]+)\s+\"([^"]+)\"\)') found=setregexp.findall(txt) for(_,key,val)in found: self.env[key]=val self.env['LIB_KDECORE']=['kdecore'] self.env['LIB_KDEUI']=['kdeui'] self.env['LIB_KIO']=['kio'] self.env['LIB_KHTML']=['khtml'] self.env['LIB_KPARTS']=['kparts'] self.env['LIBPATH_KDECORE']=[self.env['KDE4_LIB_INSTALL_DIR']] self.env['INCLUDES_KDECORE']=[self.env['KDE4_INCLUDE_INSTALL_DIR']] self.env.append_value('INCLUDES_KDECORE',[self.env['KDE4_INCLUDE_INSTALL_DIR']+os.sep+'KDE']) self.find_program('msgfmt',var='MSGFMT') feature('msgfmt')(apply_msgfmt)
if self.env.CXX: kw['features']=['cxx','cxxprogram'] else: kw['features']=['c','cprogram'] kw['fragment']=LARGE_FRAGMENT kw['msg']='Checking for large file support' ret=True try: if self.env.DEST_BINFMT!='pe': ret=self.check(**kw) except self.errors.ConfigurationError: pass else: if ret: return True kw['msg']='Checking for -D_FILE_OFFSET_BITS=64' kw['defines']=['_FILE_OFFSET_BITS=64'] try: ret=self.check(**kw) except self.errors.ConfigurationError: pass else: self.define('_FILE_OFFSET_BITS',64) return ret self.fatal('There is no support for large files') feature('link_lib_test')(link_lib_test_fun) before_method('process_source')(link_lib_test_fun) conf(check_library) conf(check_inline) conf(check_large_file)
self.env.INCLUDES_RUBYEXT=cpppath self.env.CFLAGS_RUBYEXT=read_config('CCDLFLAGS') self.env.rubyext_PATTERN='%s.'+read_config('DLEXT')[0] flags=read_config('LDSHARED') while flags and flags[0][0]!='-': flags=flags[1:] if len(flags)>1 and flags[1]=="ppc": flags=flags[2:] self.env.LINKFLAGS_RUBYEXT=flags self.env.LINKFLAGS_RUBYEXT+=read_config('LIBS') self.env.LINKFLAGS_RUBYEXT+=read_config('LIBRUBYARG_SHARED') if Options.options.rubyarchdir: self.env.ARCHDIR_RUBY=Options.options.rubyarchdir else: 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 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('apply_incpaths','apply_lib_vars','apply_bundle','apply_link')(init_rubyext) after('vars_target_cshlib')(init_rubyext) feature('rubyext')(apply_ruby_so_name) before('apply_link','propagate_uselib')(apply_ruby_so_name) conf(check_ruby_version) conf(check_ruby_ext_devel)
self.bld.add_post_fun(compile_schemas_callback) self.bld._compile_schemas_registered=True Task.task_factory('glib_genmarshal',func=genmarshal_func,vars=['GLIB_GENMARSHAL_PREFIX','GLIB_GENMARSHAL'],color='BLUE',ext_out=['.h']) Task.task_factory('glib_mkenums','${GLIB_MKENUMS} ${GLIB_MKENUMS_OPTIONS} ${GLIB_MKENUMS_SOURCE} > ${GLIB_MKENUMS_TARGET}',color='PINK',ext_out=['.h']) Task.task_factory('glib_validate_schema','rm -f ${GLIB_VALIDATE_SCHEMA_OUTPUT} && ${GLIB_COMPILE_SCHEMAS} --dry-run ${GLIB_COMPILE_SCHEMAS_OPTIONS} && touch ${GLIB_VALIDATE_SCHEMA_OUTPUT}',color='PINK') def configure(conf): conf.find_program('glib-genmarshal',var='GLIB_GENMARSHAL') conf.find_perl_program('glib-mkenums',var='GLIB_MKENUMS') conf.find_program('glib-compile-schemas',var='GLIB_COMPILE_SCHEMAS',mandatory=False) def getstr(varname): return getattr(Options.options,varname,getattr(conf.env,varname,'')) gsettingsschemadir=getstr('GSETTINGSSCHEMADIR') if not gsettingsschemadir: datadir=getstr('DATADIR') if not datadir: prefix=conf.env['PREFIX'] datadir=os.path.join(prefix,'share') gsettingsschemadir=os.path.join(datadir,'glib-2.0','schemas') conf.env['GSETTINGSSCHEMADIR']=gsettingsschemadir def options(opt): opt.add_option('--gsettingsschemadir',help='GSettings schema location [Default: ${datadir}/glib-2.0/schemas]',default='',dest='GSETTINGSSCHEMADIR') taskgen_method(add_marshal_file) before('process_source')(process_marshal) taskgen_method(add_enums_from_template) taskgen_method(add_enums) before('process_source')(process_enums) taskgen_method(add_settings_schemas) taskgen_method(add_settings_enums) feature('glib2')(process_settings)
if not 'features' in kw: if self.env.CXX: kw['features'] = ['cxx', 'cxxprogram'] else: kw['features'] = ['c', 'cprogram'] kw['fragment'] = LARGE_FRAGMENT kw['msg'] = 'Checking for large file support' try: if self.env.DEST_BINFMT != 'pe': self.check(**kw) except self.errors.ConfigurationError: pass else: return True kw['msg'] = 'Checking for -D_FILE_OFFSET_BITS=64' kw['defines'] = ['_FILE_OFFSET_BITS=64'] try: self.check(**kw) except self.errors.ConfigurationError: pass else: self.define('_FILE_OFFSET_BITS', 64) return True self.fatal('There is no support for large files') feature('link_lib_test')(link_lib_test_fun) before_method('process_source')(link_lib_test_fun) conf(check_library) conf(check_inline) conf(check_large_file)
class gcj_program(ccroot.link_task): run_str = '${GCJLINK} ${GCJLINKFLAGS} ${SRC} -o ${TGT}' color = 'YELLOW' class gcj_shlib(gcj_program): pass ccroot.USELIB_VARS['gcj'] = set(['CLASSPATH', 'JAVACFLAGS', 'GCJFLAGS']) ccroot.USELIB_VARS['gcj_program'] = set( ['CLASSPATH', 'JAVACFLAGS', 'GCJLINKFLAGS']) ccroot.USELIB_VARS['gcj_shlib'] = set( ['CLASSPATH', 'JAVACFLAGS', 'GCJLINKFLAGS']) feature('gcj_program', 'gcj_shlib')(ccroot.apply_link) feature('gcj_program', 'gcj_shlib')(ccroot.propagate_uselib_vars) @feature('gcj') @after('propagate_uselib_vars', 'apply_gcj') def set_gcj_classpath(self): lst = [isinstance(x, str) and x or x.abspath() for x in self.env.CLASSPATH] self.env.CLASSPATH = os.pathsep.join(lst) + os.pathsep @feature('gcj') @before('apply_java') def apply_gcj(self): if 'javac' in self.features: self.bld.fatal('feature gcj_native is not compatible with javac %r' %
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)
conf.env.CS_NAME = 'mono' def options(opt): opt.add_option('--with-csc-binary', type='string', dest='cscbinary') class fake_csshlib(Task.Task): color = 'YELLOW' inst_to = None def runnable_status(self): for x in self.outputs: x.sig = Utils.h_file(x.abspath()) return Task.SKIP_ME def read_csshlib(self, name, paths=[]): return self(name=name, features='fake_lib', lib_paths=paths, lib_type='csshlib') feature('cs')(apply_cs) before_method('process_source')(apply_cs) feature('cs')(use_cs) after_method('apply_cs')(use_cs) feature('cs')(debug_cs) after_method('apply_cs', 'use_cs')(debug_cs) conf(read_csshlib)
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)
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)
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)
#@feature('junit') #@after('apply_java', 'use_javac_files') def make_test(self): """make the unit test task""" if not getattr(self, 'junitsrc', None): return junit_task = self.create_task('junit_test') try: junit_task.set_run_after(self.javac_task) except AttributeError: pass feature('junit')(make_test) after('apply_java', 'use_javac_files')(make_test) class junit_test(Task.Task): color = 'YELLOW' vars = ['JUNIT_EXEC_FLAGS', 'JUNIT_RUNNER'] def runnable_status(self): """ Only run if --junit was set as an option """ for t in self.run_after: if not t.hasrun: return Task.ASK_LATER
conf.env.GCJFLAGS_gcj_shlib = ['-fPIC'] class gcj(Task.Task): run_str = '${GCJ} ${GCJFLAGS} -classpath ${CLASSPATH} -c -o ${TGT} ${SRC}' class gcj_program(ccroot.link_task): run_str = '${GCJLINK} ${GCJLINKFLAGS} ${SRC} -o ${TGT}' color = 'YELLOW' class gcj_shlib(gcj_program): pass ccroot.USELIB_VARS['gcj'] = set(['CLASSPATH', 'JAVACFLAGS', 'GCJFLAGS']) ccroot.USELIB_VARS['gcj_program'] = set(['CLASSPATH', 'JAVACFLAGS', 'GCJLINKFLAGS']) ccroot.USELIB_VARS['gcj_shlib'] = set(['CLASSPATH', 'JAVACFLAGS', 'GCJLINKFLAGS']) feature('gcj_program', 'gcj_shlib')(ccroot.apply_link) feature('gcj_program', 'gcj_shlib')(ccroot.propagate_uselib_vars) @feature('gcj') @after('propagate_uselib_vars', 'apply_gcj') def set_gcj_classpath(self): lst = [isinstance(x, str) and x or x.abspath() for x in self.env.CLASSPATH] self.env.CLASSPATH = os.pathsep.join(lst) + os.pathsep @feature('gcj') @before('apply_java') def apply_gcj(self): if 'javac' in self.features: self.bld.fatal('feature gcj_native is not compatible with javac %r' % self) srcdir = getattr(self, 'srcdir', '')
tsk.env.CSTYPE = '/target:%s' % bintype tsk.env.OUT = '/out:%s' % tsk.outputs[0].abspath() inst_to = getattr(self, 'install_path', bintype == 'exe' and '${BINDIR}' or '${LIBDIR}') if inst_to: # note: we are making a copy, so the files added to cs_task.outputs won't be installed automatically mod = getattr(self, 'chmod', bintype == 'exe' and Utils.O755 or Utils.O644) self.install_task = self.bld.install_files(inst_to, self.cs_task.outputs[:], env=self.env, chmod=mod) feature('fs')(cs.use_cs) after_method('apply_fsc')(cs.use_cs) feature('fs')(cs.debug_cs) after_method('apply_fsc', 'use_cs')(cs.debug_cs) class fsc(Task.Task): """ Compile F# files """ color = 'YELLOW' run_str = '${FSC} ${CSTYPE} ${CSFLAGS} ${ASS_ST:ASSEMBLIES} ${RES_ST:RESOURCES} ${OUT} ${SRC}' def configure(conf):
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)
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)
tup=(filename,proc.returncode,stdout,stderr) self.generator.utest_result=tup testlock.acquire() try: bld=self.generator.bld Logs.debug("ut: %r",tup) try: bld.utest_results.append(tup) except AttributeError: bld.utest_results=[tup] finally: testlock.release() def summary(bld): lst=getattr(bld,'utest_results',[]) if lst: Logs.pprint('CYAN','execution summary') total=len(lst) tfail=len([x for x in lst if x[1]]) Logs.pprint('CYAN',' tests that pass %d/%d'%(total-tfail,total)) for(f,code,out,err)in lst: if not code: Logs.pprint('CYAN',' %s'%f) Logs.pprint('CYAN',' tests that fail %d/%d'%(tfail,total)) for(f,code,out,err)in lst: if code: Logs.pprint('CYAN',' %s'%f) def options(opt): opt.add_option('--alltests',action='store_true',default=False,help='Exec all unit tests',dest='all_tests') feature('test')(make_test) after('apply_link')(make_test)
srcdir = getattr(self, 'srcdir', '') if isinstance(srcdir, Node.Node): srcdir = [srcdir] for x in Utils.to_list(srcdir): if isinstance(x, Node.Node): y = x else: y = self.path.find_dir(x) if not y: self.bld.fatal('Could not find the folder %s from %s' % (x, self.path)) tmp.append(y) tsk.srcdir = tmp # reuse some code feature('scalac')(javaw.use_javac_files) after_method('apply_scalac')(javaw.use_javac_files) feature('scalac')(javaw.set_classpath) after_method('apply_scalac', 'use_scalac_files')(javaw.set_classpath) SOURCE_RE = '**/*.scala' class scalac(javaw.javac): color = 'GREEN' vars = ['CLASSPATH', 'SCALACFLAGS', 'SCALAC', 'OUTDIR'] def runnable_status(self): """ Wait for dependent tasks to be complete, then read the file system to find the input nodes. """
for y in names: node=x.find_node(y) if node: node.sig=Utils.h_file(node.abspath()) break else: continue break else: raise Errors.WafError('could not find library %r'%self.name) self.link_task=self.create_task('fake_%s'%self.lib_type,[],[node]) self.target=self.name 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(get_uselib_vars) feature('c','cxx','d','fc','javac','cs','uselib')(propagate_uselib_vars) after_method('process_use')(propagate_uselib_vars) feature('cshlib','cxxshlib')(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.fatal('Could not find the python module %r'%module_name) conf.end_msg(True) def configure(conf): 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) 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)
def getstr(varname): return getattr(Options.options, varname, getattr(conf.env, varname, '')) gsettingsschemadir = getstr('GSETTINGSSCHEMADIR') if not gsettingsschemadir: datadir = getstr('DATADIR') if not datadir: prefix = conf.env['PREFIX'] datadir = os.path.join(prefix, 'share') gsettingsschemadir = os.path.join(datadir, 'glib-2.0', 'schemas') conf.env['GSETTINGSSCHEMADIR'] = gsettingsschemadir def options(opt): opt.add_option( '--gsettingsschemadir', help='GSettings schema location [Default: ${datadir}/glib-2.0/schemas]', default='', dest='GSETTINGSSCHEMADIR') taskgen_method(add_marshal_file) before_method('process_source')(process_marshal) taskgen_method(add_enums_from_template) taskgen_method(add_enums) before_method('process_source')(process_enums) taskgen_method(add_settings_schemas) taskgen_method(add_settings_enums) feature('glib2')(process_settings)
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)
if isinstance(srcdir, Node.Node): srcdir = [srcdir] for x in Utils.to_list(srcdir): if isinstance(x, Node.Node): y = x else: y = self.path.find_dir(x) if not y: self.bld.fatal('Could not find the folder %s from %s' % (x, self.path)) tmp.append(y) tsk.srcdir = tmp # reuse some code feature('scalac')(javaw.use_javac_files) after_method('apply_scalac')(javaw.use_javac_files) feature('scalac')(javaw.set_classpath) after_method('apply_scalac', 'use_scalac_files')(javaw.set_classpath) SOURCE_RE = '**/*.scala' class scalac(javaw.javac): color = 'GREEN' vars = ['CLASSPATH', 'SCALACFLAGS', 'SCALAC', 'OUTDIR'] def runnable_status(self): """ Wait for dependent tasks to be complete, then read the file system to find the input nodes.
main_func_name=self.env.FC_MAIN) except self.errors.ConfigurationError: pass else: self.end_msg("ok ('%s', '%s', '%s-case')" % (u, du, c)) self.env.FORTRAN_MANGLING = (u, du, c) break else: self.end_msg(False) self.fatal('mangler not found') return (u, du, c) def set_lib_pat(self): self.env['fcshlib_PATTERN'] = self.env['pyext_PATTERN'] conf(fc_flags) conf(check_fortran) conf(fortran_modifier_darwin) conf(fortran_modifier_win32) conf(fortran_modifier_cygwin) conf(check_fortran_dummy_main) conf(is_link_verbose) conf(check_fortran_verbose_flag) conf(check_fortran_clib) feature('link_main_routines_func')(link_main_routines_tg_method) before_method('process_source')(link_main_routines_tg_method) conf(check_fortran_mangling) feature('pyext')(set_lib_pat) before_method('propagate_uselib_vars', 'apply_link')(set_lib_pat)
def check_jni_headers(conf): if not conf.env.CC_NAME and not conf.env.CXX_NAME: conf.fatal('load a compiler first (gcc, g++, ..)') if not conf.env.JAVA_HOME: conf.fatal('set JAVA_HOME in the system environment') javaHome=conf.env['JAVA_HOME'][0] dir=conf.root.find_dir(conf.env.JAVA_HOME[0]+'/include') f=dir.ant_glob('**/(jni|jni_md).h') incDirs=[x.parent.abspath()for x in f] dir=conf.root.find_dir(conf.env.JAVA_HOME[0]) f=dir.ant_glob('**/*jvm.(so|dll)') libDirs=[x.parent.abspath()for x in f]or[javaHome] for i,d in enumerate(libDirs): if conf.check(header_name='jni.h',define_name='HAVE_JNI_H',lib='jvm',libpath=d,includes=incDirs,uselib_store='JAVA',uselib='JAVA'): break else: conf.fatal('could not find lib jvm in %r (see config.log)'%libDirs) feature('javac')(apply_java) before('process_source')(apply_java) feature('javac')(use_javac_files) after('apply_java')(use_javac_files) feature('javac')(set_classpath) after('apply_java','propagate_uselib_vars','use_javac_files')(set_classpath) feature('jar')(jar_files) after('apply_java','use_javac_files')(jar_files) before('process_source')(jar_files) feature('jar')(use_jar_files) after('jar_files')(use_jar_files) conf(check_java_class) conf(check_jni_headers)
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)
incDirs = [x.parent.abspath() for x in f] dir = conf.root.find_dir(conf.env.JAVA_HOME[0]) f = dir.ant_glob('**/*jvm.(so|dll)') libDirs = [x.parent.abspath() for x in f] or [javaHome] for i, d in enumerate(libDirs): if conf.check(header_name='jni.h', define_name='HAVE_JNI_H', lib='jvm', libpath=d, includes=incDirs, uselib_store='JAVA', uselib='JAVA'): break else: conf.fatal('could not find lib jvm in %r (see config.log)' % libDirs) feature('javac')(apply_java) before_method('process_source')(apply_java) feature('javac')(use_javac_files) after_method('apply_java')(use_javac_files) feature('javac')(set_classpath) after_method('apply_java', 'propagate_uselib_vars', 'use_javac_files')(set_classpath) feature('jar')(jar_files) after_method('apply_java', 'use_javac_files')(jar_files) before_method('process_source')(jar_files) feature('jar')(use_jar_files) after_method('jar_files')(use_jar_files) conf(check_java_class) conf(check_jni_headers)
#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file import waflib.Tools.asm from waflib.TaskGen import feature def apply_nasm_vars(self): self.env.append_value('ASFLAGS', self.to_list(getattr(self, 'nasm_flags', []))) def configure(conf): nasm = conf.find_program(['nasm', 'yasm'], var='AS') conf.env.AS_TGT_F = ['-o'] conf.env.ASLNK_TGT_F = ['-o'] feature('asm')(apply_nasm_vars)
#! /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)
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)
x.logger.memhandler.flush() for x in tasks: if x.hasrun!=Task.SUCCESS: self.end_msg(kw.get('errmsg','no'),color='YELLOW') self.fatal(kw.get('fatalmsg',None)or'One of the tests has failed, see the config.log for more information') self.end_msg('ok') conf(parse_flags) conf(ret_msg) conf(validate_cfg) conf(exec_cfg) conf(check_cfg) conf(validate_c) conf(post_check) conf(check) feature('test_exec')(test_exec_fun) after('apply_link')(test_exec_fun) conf(run_c_code) conf(check_cxx) conf(check_cc) conf(define) conf(undefine) conf(define_cond) conf(is_defined) conf(get_define) conf(have_define) conf(write_config_header) conf(get_config_header) conf(cc_add_flags) conf(cxx_add_flags) conf(link_add_flags)
color='YELLOW' run_str='${MCS} ${CSTYPE} ${CSFLAGS} ${ASS_ST:ASSEMBLIES} ${RES_ST:RESOURCES} ${OUT} ${SRC}' def configure(conf): csc=getattr(Options.options,'cscbinary',None) if csc: conf.env.MCS=csc conf.find_program(['csc','mcs','gmcs'],var='MCS') conf.env.ASS_ST='/r:%s' conf.env.RES_ST='/resource:%s' conf.env.CS_NAME='csc' if str(conf.env.MCS).lower().find('mcs')>-1: conf.env.CS_NAME='mono' def options(opt): opt.add_option('--with-csc-binary',type='string',dest='cscbinary') class fake_csshlib(Task.Task): color='YELLOW' inst_to=None def runnable_status(self): for x in self.outputs: x.sig=Utils.h_file(x.abspath()) return Task.SKIP_ME def read_csshlib(self,name,paths=[]): return self(name=name,features='fake_lib',lib_paths=paths,lib_type='csshlib') feature('cs')(apply_cs) before_method('process_source')(apply_cs) feature('cs')(use_cs) after_method('apply_cs')(use_cs) feature('cs')(debug_cs) after_method('apply_cs','use_cs')(debug_cs) conf(read_csshlib)
node = x.find_node(y) if node: node.sig = Utils.h_file(node.abspath()) break else: continue break else: raise Errors.WafError('could not find library %r' % self.name) self.link_task = self.create_task('fake_%s' % self.lib_type, [], [node]) self.target = self.name 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(get_uselib_vars) feature('c', 'cxx', 'd', 'fc', 'javac', 'cs', 'uselib')(propagate_uselib_vars) after_method('process_use')(propagate_uselib_vars) feature('cshlib', 'cxxshlib')(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)
tsk.env.CSTYPE = "/target:%s" % bintype tsk.env.OUT = "/out:%s" % tsk.outputs[0].abspath() inst_to = getattr(self, "install_path", bintype == "exe" and "${BINDIR}" or "${LIBDIR}") if inst_to: # note: we are making a copy, so the files added to cs_task.outputs won't be installed automatically mod = getattr(self, "chmod", bintype == "exe" and Utils.O755 or Utils.O644) self.install_task = self.add_install_files( install_to=inst_to, install_from=self.cs_task.outputs[:], chmod=mod) feature("fs")(cs.use_cs) after_method("apply_fsc")(cs.use_cs) feature("fs")(cs.debug_cs) after_method("apply_fsc", "use_cs")(cs.debug_cs) class fsc(Task.Task): """ Compile F# files """ color = "YELLOW" run_str = "${FSC} ${CSTYPE} ${CSFLAGS} ${ASS_ST:ASSEMBLIES} ${RES_ST:RESOURCES} ${OUT} ${SRC}"