diff --git a/SConstruct b/SConstruct index 7c1164012..a94e8c667 100644 --- a/SConstruct +++ b/SConstruct @@ -16,8 +16,6 @@ Basic usage: """ from buildutils import * -import subst -import platform, sys, os if not COMMAND_LINE_TARGETS: # Print usage help @@ -42,10 +40,9 @@ if os.name == 'nt': else: extraEnvArgs['TARGET_ARCH'] = 'x86' -env = Environment(tools=['default', 'textfile'], +env = Environment(tools=['default', 'textfile', 'subst', 'recursiveInstall'], **extraEnvArgs) -env.AddMethod(RecursiveInstall) -subst.TOOL_SUBST(env) + add_RegressionTest(env) # ****************************************************** @@ -764,10 +761,6 @@ SConscript('build/tools/SConscript') inst = env.Install('$ct_datadir', mglob(env, pjoin('data','inputs'), 'cti', 'xml')) installTargets.extend(inst) -# Install exp3to2.sh (used by some of the tests) -inst = env.Install('$ct_bindir', pjoin('bin', 'exp3to2.sh')) -installTargets.extend(inst) - ### Meta-targets ### build_demos = Alias('demos', demoTargets) diff --git a/buildutils.py b/site_scons/buildutils.py similarity index 87% rename from buildutils.py rename to site_scons/buildutils.py index 28b660392..b143ee0f5 100644 --- a/buildutils.py +++ b/site_scons/buildutils.py @@ -1,7 +1,7 @@ import os -import shutil -import sys from os.path import join as pjoin +import sys +import platform import textwrap import re import subprocess @@ -377,62 +377,3 @@ def listify(value): else: # Already a sequence. Return as a list return list(value) - - -def RecursiveInstall(env, target, dir): - """ - This tool adds the builder: - - env.RecursiveInstall(target, path) - - This is useful for doing: - - k = env.RecursiveInstall(dir_target, dir_source) - - and if any thing in dir_source is updated the install is rerun - - It behaves similar to the env.Install builtin. However it expects - two directories and correctly sets up the dependencies between each - sub file instead of just between the two directories. - - Note in also traverses the in memory node tree for the source - directory and can detect things that are not built yet. Internally - we use the env.Glob function for this support. - - You can see the effect of this function by doing: - - scons --tree=all,prune - - and see the one to one correspondence between source and target - files within each directory. - """ - nodes = _recursive_install(env, dir) - - dir = env.Dir(dir).abspath - target = env.Dir(target).abspath - - l = len(dir) + 1 - - relnodes = [n.abspath[l:] for n in nodes] - - out = [] - for n in relnodes: - t = os.path.join(target, n) - s = os.path.join(dir, n) - out.extend(env.InstallAs(env.File(t), env.File(s))) - - return out - - -def _recursive_install(env, path): - """ Helper function for RecursiveInstall """ - nodes = env.Glob(os.path.join(path, '*'), strings=False) - nodes.extend(env.Glob(os.path.join(path, '*.*'), strings=False)) - out = [] - for n in nodes: - if n.isdir(): - out.extend(_recursive_install(env, n.abspath)) - else: - out.append(n) - - return out diff --git a/site_scons/site_tools/recursiveInstall.py b/site_scons/site_tools/recursiveInstall.py new file mode 100644 index 000000000..70b473ad8 --- /dev/null +++ b/site_scons/site_tools/recursiveInstall.py @@ -0,0 +1,67 @@ +import os + +def RecursiveInstall(env, target, dir): + """ + This tool adds the builder: + + env.RecursiveInstall(target, path) + + This is useful for doing: + + k = env.RecursiveInstall(dir_target, dir_source) + + and if any thing in dir_source is updated the install is rerun + + It behaves similar to the env.Install builtin. However it expects + two directories and correctly sets up the dependencies between each + sub file instead of just between the two directories. + + Note in also traverses the in memory node tree for the source + directory and can detect things that are not built yet. Internally + we use the env.Glob function for this support. + + You can see the effect of this function by doing: + + scons --tree=all,prune + + and see the one to one correspondence between source and target + files within each directory. + """ + nodes = _recursive_install(env, dir) + + dir = env.Dir(dir).abspath + target = env.Dir(target).abspath + + l = len(dir) + 1 + + relnodes = [n.abspath[l:] for n in nodes] + + out = [] + for n in relnodes: + t = os.path.join(target, n) + s = os.path.join(dir, n) + out.extend(env.InstallAs(env.File(t), env.File(s))) + + return out + + +def _recursive_install(env, path): + """ Helper function for RecursiveInstall """ + nodes = env.Glob(os.path.join(path, '*'), strings=False) + nodes.extend(env.Glob(os.path.join(path, '*.*'), strings=False)) + out = [] + for n in nodes: + if n.isdir(): + out.extend(_recursive_install(env, n.abspath)) + else: + out.append(n) + + return out + + +def generate(env, **kw): + env.AddMethod(RecursiveInstall) + + +def exists(env): + return True diff --git a/subst.py b/site_scons/site_tools/subst.py similarity index 98% rename from subst.py rename to site_scons/site_tools/subst.py index 136e9f51d..b4ede6a4f 100644 --- a/subst.py +++ b/site_scons/site_tools/subst.py @@ -194,9 +194,7 @@ def SubstHeader(env, target, source): SUBST_REPLACE=_SubstHeader_replace) -# Create builders -############################################################################## -def TOOL_SUBST(env): +def generate(env, **kw): # The generic builder subst = SCons.Action.Action(_subst_action, _subst_message) env['BUILDERS']['SubstGeneric'] = Builder(action=subst, @@ -205,3 +203,7 @@ def TOOL_SUBST(env): # Additional ones env.AddMethod(SubstFile) env.AddMethod(SubstHeader) + + +def exists(env): + return True