From d61d41a786854e69ea14512a902c830d44a47412 Mon Sep 17 00:00:00 2001 From: Jim Bosch Date: Tue, 17 Apr 2012 10:00:36 -0400 Subject: [PATCH] allow CCFLAGS to be passed on command line or through construction variable; default is now '-O2 -g' --- SConscript | 9 +++++++-- SConstruct | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/SConscript b/SConscript index f79b1243..10f97d1a 100644 --- a/SConscript +++ b/SConscript @@ -176,9 +176,12 @@ def setupOptions(): metavar="DIR", help="location of Boost libraries") AddOption("--rpath", dest="custom_rpath", type="string", action="append", help="runtime link paths to add to libraries and executables; may be passed more than once") + variables = Variables() + variables.Add("CCFLAGS", default=os.environ.get("CCFLAGS", "-O2 -g"), help="compiler flags") + return variables -def makeEnvironment(): - env = Environment() +def makeEnvironment(variables): + env = Environment(variables=variables) if os.environ.has_key("PATH"): env["ENV"]["PATH"] = os.environ["PATH"] if os.environ.has_key("LD_LIBRARY_PATH"): @@ -187,6 +190,8 @@ def makeEnvironment(): env["ENV"]["DYLD_LIBRARY_PATH"] = os.environ["DYLD_LIBRARY_PATH"] if os.environ.has_key("PYTHONPATH"): env["ENV"]["PYTHONPATH"] = os.environ["PYTHONPATH"] + if os.environ.has_key("CCFLAGS"): + env.AppendUnique(CCFLAGS = os.environ["CCFLAGS"]) custom_rpath = GetOption("custom_rpath") if custom_rpath is not None: env.AppendUnique(RPATH=custom_rpath) diff --git a/SConstruct b/SConstruct index 4faa2670..aa3d8de1 100644 --- a/SConstruct +++ b/SConstruct @@ -1,9 +1,9 @@ # -*- python -*- setupOptions, makeEnvironment, setupTargets, checks = SConscript("SConscript") -setupOptions() +variables = setupOptions() -env = makeEnvironment() +env = makeEnvironment(variables) env.AppendUnique(CPPPATH="#.") if not GetOption("help") and not GetOption("clean"):