import os, os.path, sys
+import tempfile
from SCons.Script import *
import SCons.Scanner.C
elif line.startswith('}') and name and start:
tests[name] = (start, linenr)
return tests
-
+
def CompileCheck(target, source, env):
tests = scanTests(file(source[0].abspath))
- errf = os.popen(env.subst('$CXXCOM -DCOMPILE_CHECK 2>&1', source=source, target=target))
+ cenv = env.Clone()
+ cenv.Append( CPPDEFINES = { 'COMPILE_CHECK': '' } )
+ out = tempfile.TemporaryFile()
+ cenv['SPAWN'] = lambda sh, escape, cmd, args, env, pspawn=cenv['PSPAWN'], out=out: \
+ pspawn(sh, escape, cmd, args, env, out, out)
+ Action('$CXXCOM').execute(target, source, cenv)
passedTests = {}
delay_name = None
- for error in errf:
+ out.seek(0)
+ for error in out.read().splitlines():
elts = error.split(':',2)
if len(elts) != 3 : continue
filename, line, message = elts
builder = env.Builder(
action = CompileCheck,
- suffix = '.tsto',
+ suffix = '.checked',
src_suffix = '.cc',
source_scanner = SCons.Scanner.C.CScanner(),
single_source=1