1 import os, os.path, sys
2 from SCons.Script import *
11 if line.startswith('COMPILE_FAIL(') and ')' in line:
12 name = line.split('(',1)[-1].split(')',1)[0]
14 elif line.startswith('}') and name and start:
15 tests[name] = (start, linenr)
18 def CompileCheck(target, source, env):
19 tests = scanTests(file(source[0].abspath))
20 errf = os.popen(env.subst('$CXXCOM -DCOMPILE_CHECK 2>&1', source=source, target=target))
23 elts = error.split(':',2)
24 if len(elts) != 3 : continue
25 filename, line, message = elts
26 if not os.path.exists(filename) : continue
28 except ValueError : continue
29 filename = os.path.abspath(filename)
30 if filename != source[0].abspath : continue
32 for name,lines in tests.iteritems():
33 if line >= lines[0] and line <= lines[1]:
35 print "Passed test '%s': %s" % (name, message.strip())
36 failedTests = set(tests.iterkeys()) - set(passedTests.iterkeys())
38 for test in failedTests:
39 print "Test '%s' FAILED" % test
41 print "*** %d tests FAILED" % len(failedTests)
42 if os.path.exists(target[0].abspath):
43 os.unlink(target[0].abspath)
45 file(target[0].abspath,"w").close()
48 CompileCheck = Action(CompileCheck)
52 builder = env.Builder(
53 action = CompileCheck,
56 source_scanner = SCons.Scanner.C.CScanner(),
60 env.Append(BUILDERS = { 'CompileCheck': builder })