Skip to content
Snippets Groups Projects
Commit a9827902 authored by sbund's avatar sbund
Browse files

Moved satscons into SatLib library

parent dad19b5c
No related branches found
No related tags found
No related merge requests found
import SCons.Script.SConscript
import SCons.Defaults
import os.path
import os
def BoostUnitTests(env, target, source, test_sources=None, **kw):
path, name = os.path.split(target)
if test_sources:
if type(test_sources) is not type([]):
test_sources = [ test_sources ]
else:
test_sources = []
testEnv = env.Copy(**kw)
testEnv.Append(LIBS = '$BOOSTTESTLIB')
testRunner = testEnv.Program('test', env.Object(source) + test_sources)
return env.Alias(target, env.Command(os.path.join(path,'.'+name+'.stamp'), testRunner,
[ './$SOURCE $BOOSSTTESTARGS', 'touch $TARGET' ]))
def dispatcher(*arg,**kw):
return BoostUnitTests(*arg,**kw)
def generate(env):
env['BOOSTTESTLIB'] = 'boost_unit_test_framework'
env['BOOSTTESTARGS'] = [ '--build_info=yes', '--log_level=test_suite' ]
env.__class__.BoostUnitTests = dispatcher
def exists(env):
return 1
import SCons.Script.SConscript
import SCons.Builder
import SCons.Defaults
import os.path
def replace_ext(n,ext):
base,ext = os.path.splitext(n)
return base+ext
def Doxygen(env, target, source, image):
path, name = os.path.split(str(target))
stamp = os.path.join(path, '.'+name+'.stamp')
alias = env.Alias(target,
[ env.Command(os.path.splitext(img)[0]+".png", img,
[ 'TERM=dumb make -f imgconvert.mak $TARGET' ])
for img in image ] +
[ env.Command(stamp, source,
[ '$DOXYGENCOM',
'cd doc/html && (sed -ne \'1,/<table>/p\' <annotated.html && grep -F \'<tr>\' <annotated.html | sort -ft\'>\' -k4 && sed -ne \'/<\\/table>/,$$p\' <annotated.html) >annotated.html.new && mv annotated.html.new annotated.html',
'touch $TARGET' ],
source_scanner = SCons.Defaults.ObjSourceScan) ])
env.Clean(stamp, target)
return alias
def generate(env):
env['DOXYGENCOM'] = 'doxygen'
env.__class__.Doxygen = Doxygen
def exists(env):
return 1
import fnmatch
import os
def glob(match):
"""Similar to glob.glob, except globs SCons nodes, and thus sees
generated files and files from build directories. Basically, it sees
anything SCons knows about. A key subtlety is that since this function
operates on generated nodes as well as source nodes on the filesystem,
it needs to be called after builders that generate files you want to
include."""
def fn_filter(node):
fn = str(node)
return fnmatch.fnmatch(os.path.basename(fn), match)
here = Dir('.')
children = here.all_children()
nodes = map(File, filter(fn_filter, children))
node_srcs = [n.srcnode() for n in nodes]
src = here.srcnode()
if src is not here:
src_children = map(File, filter(fn_filter, src.all_children()))
for s in src_children:
if s not in node_srcs:
nodes.append(File(os.path.basename(str(s))))
return nodes
import SCons.Defaults
import md5, os.path
import SCons.Action, SCons.Builder, SCons.Util, SCons.Errors, SCons.Environment
PDFLaTeXAction = SCons.Action.CommandAction("$PDFLATEXCOM")
# copied from Action.py ... changed to tage explicit path-names as
# target/source instead of node objects
def my_executeCommand(cmd_list, target, source, env):
import SCons.Util
escape = env.get('ESCAPE', lambda x: x)
if env.has_key('SHELL'): shell = env['SHELL']
else: raise SCons.Errors.UserError('Missing SHELL construction variable.')
if env.has_key('PIPE_BUILD'):
pipe_build = 1
if env.has_key('PSPAWN'): pspawn = env['PSPAWN']
else: raise SCons.Errors.UserError('Missing PSPAWN construction variable.')
if env.has_key('PSTDOUT'): pstdout = env['PSTDOUT']
else: raise SCons.Errors.UserError('Missing PSTDOUT construction variable.')
if env.has_key('PSTDERR'): pstderr = env['PSTDERR']
else: raise SCons.Errors.UserError('Missing PSTDOUT construction variable.')
else:
pipe_build = 0
if env.has_key('SPAWN'): spawn = env['SPAWN']
else: raise SCons.Errors.UserError('Missing SPAWN construction variable.')
# Here, replaced the source and target argumnets with a dict argument
cmd_list = env.subst_list(cmd_list, 0, dict = { 'TARGET': target, 'TARGETS': [ target ],
'SOURCE': source, 'SOURCES': [ source ] })
for cmd_line in cmd_list:
if len(cmd_line):
try: ENV = env['ENV']
except KeyError:
global default_ENV
if not default_ENV:
import SCons.Environment
default_ENV = SCons.Environment.Environment()['ENV']
ENV = default_ENV
for key, value in ENV.items():
if SCons.Util.is_List(value):
value = SCons.Util.flatten(value)
ENV[key] = string.join(map(str, value), os.pathsep)
elif not SCons.Util.is_String(value):
ENV[key] = str(value)
cmd_line = SCons.Util.escape_list(cmd_line, escape)
if pipe_build: ret = pspawn( shell, escape, cmd_line[0], cmd_line,
ENV, pstdout, pstderr )
else: ret = spawn(shell, escape, cmd_line[0], cmd_line, ENV)
if ret: return ret
return 0
def TeXchecksum(files):
m = md5.new()
for f in files:
try:
m.update(file(f,"rb").read())
except IOError: pass
return m.digest()
def TeXPdfAction(target, source, env):
src = os.path.abspath(str(source[0]))
path, pdf = os.path.split(str(target[0]))
base, ext = os.path.splitext(pdf)
cwd = os.getcwd()
if path: os.chdir(path)
checkfiles = [ base + ext for ext in env["TEXCHECKEXT"] ]
checksum = TeXchecksum(checkfiles)
rv = 0
for i in range(env["TEXMAXRECURSE"]+1):
if i==env["TEXMAXRECURSE"]:
print "\nWARNING: TeX recursion depth exceeded. They generated file may not be final.\n"
break
rv = my_executeCommand("$PDFLATEXCOM", pdf, src, env)
if rv: break
new_checksum = TeXchecksum(checkfiles)
if new_checksum == checksum: break
checksum = new_checksum
os.chdir(cwd)
return rv
class TeXPdfBuilder(SCons.Builder.BuilderBase) :
def __call__(self, env, target = None, source = SCons.Builder._null, **kw):
tlist = SCons.Builder.BuilderBase.__call__(self, env, target, source, **kw)
exts = env["TEXCHECKEXT"] + env["TEXCLEANEXT"]
for t in tlist:
base, ext = os.path.splitext(str(t))
for ext in exts:
env.Clean(t,base+ext)
return tlist
def generate(env):
env['TEXCHECKEXT'] = [ '.aux', '.toc' ]
env['TEXCLEANEXT'] = [ '.log', '.dvi' ]
env['TEXMAXRECURSE'] = 5
env['BUILDERS']['PDF'] = TeXPdfBuilder(action = TeXPdfAction, suffix='.pdf')
def exists(env):
return 1
import SCons.Options, SCons.SConf, SCons.Environment
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment