Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51041 - in sandbox/SCons: libs tools/scons
From: loonycyborg_at_[hidden]
Date: 2009-02-05 18:41:50


Author: loonycyborg
Date: 2009-02-05 18:41:49 EST (Thu, 05 Feb 2009)
New Revision: 51041
URL: http://svn.boost.org/trac/boost/changeset/51041

Log:
Refactoring.

Text files modified:
   sandbox/SCons/libs/SConscript | 13 ++++---------
   sandbox/SCons/tools/scons/boost-build-variants.py | 40 ++++++++++++++++++++++++++++------------
   2 files changed, 32 insertions(+), 21 deletions(-)

Modified: sandbox/SCons/libs/SConscript
==============================================================================
--- sandbox/SCons/libs/SConscript (original)
+++ sandbox/SCons/libs/SConscript 2009-02-05 18:41:49 EST (Thu, 05 Feb 2009)
@@ -3,30 +3,25 @@
 env.Append(
     CPPPATH = "#/",
     CPPDEFINES = ["BOOST_ALL_NO_LIB=1"],
- CCFLAGS = Split("$VARIANT_CCFLAGS $THREADING_CCFLAGS"),
- LINKFLAGS = Split("$VARIANT_LINKFLAGS $THREADING_LINKFLAGS"),
     )
 
 sconscripts = Glob("*/build/SConscript")
 env.AppendUnique(CPPDEFINES = ["${LINK_DYNAMIC and 'BOOST_' + BOOST_LIB + '_DYN_LINK=1' or []}"])
 for variant in env["variant"]:
- env["VARIANT_CCFLAGS"] = env.get(variant.upper() + "_CCFLAGS")
- env["VARIANT_LINKFLAGS"] = env.get(variant.upper() + "_LINKFLAGS")
     env.SetProperty(profile = False)
     if variant == "release":
- env.SetProperty(optimize = "speed")
+ env.SetProperty(optimize = "speed", debug = False)
     elif variant == "debug":
- env.SetProperty(optimize = "no")
+ env.SetProperty(optimize = "no", debug = True)
     elif variant == "profile":
- env.SetProperty(optimize = "speed", profile = True)
+ env.SetProperty(optimize = "speed", profile = True, debug = True)
     for linking in env["link"]:
         if linking == "dynamic":
             env["LINK_DYNAMIC"] = True
         else:
             env["LINK_DYNAMIC"] = False
         for threading in env["threading"]:
- env["THREADING_CCFLAGS"] = env.get("THREADING_" + threading.upper() + "_CCFLAGS")
- env["THREADING_LINKFLAGS"] = env.get("THREADING_" + threading.upper() + "_LINKFLAGS")
+ env.SetProperty(threading = threading)
             for sconscript in sconscripts:
                 lib = str(sconscript.get_dir().up())
                 target_dir = "#/bin.SCons/" + lib + "/" + variant + "/" + linking + "/threading-" + threading

Modified: sandbox/SCons/tools/scons/boost-build-variants.py
==============================================================================
--- sandbox/SCons/tools/scons/boost-build-variants.py (original)
+++ sandbox/SCons/tools/scons/boost-build-variants.py 2009-02-05 18:41:49 EST (Thu, 05 Feb 2009)
@@ -1,24 +1,43 @@
 # vi: syntax=python:et:ts=4
 from SCons.Script import Split
+import traceback
 
 class gcc_features:
     def optimize(self, env, optimize):
- env.AppendUnique(CCFLAGS = "$OPTIMIZE_CCFLAGS")
         if not optimize or optimize == "no":
- env.Replace(OPTIMIZE_CCFLAGS = "-O0")
+ env._AppendFeatureFlag(CCFLAGS = "-O0 -fno-inline")
         elif optimize == "speed":
- env.Replace(OPTIMIZE_CCFLAGS = "-O3 -finline-functions -Wno-inline")
+ env._AppendFeatureFlag(CCFLAGS = "-O3 -finline-functions -Wno-inline")
         elif optimize == "space":
- env.Replace(OPTIMIZE_CCFLAGS = "-Os")
+ env._AppendFeatureFlag(CCFLAGS = "-Os")
         else:
- env.Replace(OPTIMIZE_CCFLAGS = "")
+ env._AppendFeatureFlag(CCFLAGS = "")
 
     def profile(self, env, profile):
- env.AppendUnique(CCFLAGS = "$PROFILE_CCFLAGS", LINKFLAGS = "$PROFILE_LINKFLAGS")
         if profile:
- env.Replace(PROFILE_CCFLAGS = "-pg", PROFILE_LINKFLAGS = "-pg")
+ env._AppendFeatureFlag(CCFLAGS = "-pg", LINKFLAGS = "-pg")
         else:
- env.Replace(PROFILE_CCFLAGS = "", PROFILE_LINKFLAGS = "")
+ env._AppendFeatureFlag(CCFLAGS = "", LINKFLAGS = "")
+
+ def threading(self, env, threading):
+ if threading == "multi":
+ env._AppendFeatureFlag(CCFLAGS = "-pthread", LINKFLAGS = "-pthread")
+ else:
+ env._AppendFeatureFlag(CCFLAGS = "", LINKFLAGS = "")
+
+ def debug(self, env, debug):
+ if debug:
+ env._AppendFeatureFlag(CCFLAGS = "-g", CPPDEFINES = [])
+ else:
+ env._AppendFeatureFlag(CCFLAGS = "", CPPDEFINES = "NDEBUG")
+
+def _AppendFeatureFlag(env, **kw):
+ stack = traceback.extract_stack(limit = 3)
+ feature = stack[0][2].upper()
+ for (key, val) in kw.items():
+ feature_var = feature + "_" + key
+ env.AppendUnique(**{ key : "$" + feature_var })
+ env[feature_var] = val
 
 features = gcc_features()
 
@@ -32,7 +51,4 @@
 def generate(env):
     env["CXXFLAGS"] = Split("-ftemplate-depth-128 -Wall")
     env.AddMethod(SetProperty)
- env["THREADING_MULTI_CCFLAGS"] = "-pthread"
- env["THREADING_MULTI_LINKFLAGS"] = "-pthread"
- env["DEBUG_CCFLAGS"] = Split("-g -fno-inline")
- env["RELEASE_CCFLAGS"] = Split("-DNDEBUG")
+ env.AddMethod(_AppendFeatureFlag)


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk