wscript (1116B)
1 #! /usr/bin/env python 2 # encoding: utf-8 3 # Thomas Nagy, 2011 (ita) 4 5 """ 6 Map a compilation failure to a success status. People playing with C++ templates 7 might need this. 8 """ 9 10 top = '.' 11 out = 'build' 12 13 def options(opt): 14 opt.load('compiler_cxx') 15 16 def configure(conf): 17 conf.load('compiler_cxx') 18 19 def build(bld): 20 bld.objects(source='success.cpp', target='ok') 21 bld.objects(source='fail.cpp', target='fail', features='fail') 22 23 ################################################################## 24 # the feature 'fail' is defined below 25 26 from waflib.Tools.cxx import cxx 27 28 # our task class 29 class cxxfail(cxx): 30 def run(self): 31 ret = super(cxxfail, self).run() 32 self.outputs[0].write('just a simulation') 33 return not ret 34 35 # @extension would apply this to all through TaskGen.mappings 36 def one_more_mapping(self, node): 37 return self.create_compiled_task('cxxfail', node) 38 39 from waflib.TaskGen import feature, before 40 @before('process_source') 41 @feature('fail') 42 def remap_failure_to_success(self): 43 # override 44 self.mappings = dict(self.mappings) 45 # then change the extension processing 46 self.mappings['.cpp'] = one_more_mapping 47