summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-11-12 13:43:54 (GMT)
committerSteven Knight <knight@baldmt.com>2002-11-12 13:43:54 (GMT)
commit889f0c7238da15a89be500e40ce9f73102e31b8c (patch)
tree92ed84c42045815814f2cb39fc39e7c5984c5bb7 /src/engine/SCons
parent1cfff0b089cc56024ed5ea71c33ad843373bb9fc (diff)
downloadSCons-889f0c7238da15a89be500e40ce9f73102e31b8c.zip
SCons-889f0c7238da15a89be500e40ce9f73102e31b8c.tar.gz
SCons-889f0c7238da15a89be500e40ce9f73102e31b8c.tar.bz2
Add the ParseConfig() method. (Steve Leblanc)
Diffstat (limited to 'src/engine/SCons')
-rw-r--r--src/engine/SCons/Script/SConscript.py3
-rw-r--r--src/engine/SCons/Util.py47
2 files changed, 49 insertions, 1 deletions
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 2802e8f..3d4a6f7 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -331,6 +331,7 @@ def BuildDefaultGlobals():
globals['Library'] = SCons.Defaults.StaticLibrary
globals['Local'] = Local
globals['Object'] = SCons.Defaults.StaticObject
+ globals['Options'] = Options
globals['Repository'] = SCons.Node.FS.default_fs.Repository
globals['SetBuildSignatureType'] = SetBuildSignatureType
globals['SetContentSignatureType'] = SetContentSignatureType
@@ -338,6 +339,7 @@ def BuildDefaultGlobals():
globals['StaticObject'] = SCons.Defaults.StaticObject
globals['SharedLibrary'] = SCons.Defaults.SharedLibrary
globals['SharedObject'] = SCons.Defaults.SharedObject
+ globals['ParseConfig'] = SCons.Util.ParseConfig
globals['Platform'] = SCons.Platform.Platform
globals['Program'] = SCons.Defaults.Program
globals['Return'] = Return
@@ -348,5 +350,4 @@ def BuildDefaultGlobals():
globals['Split'] = SCons.Util.Split
globals['Tool'] = SCons.Tool.Tool
globals['WhereIs'] = SCons.Util.WhereIs
- globals['Options'] = Options
return globals
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 3a39c4e..5c2fd26 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -523,3 +523,50 @@ else:
if stat.S_IMODE(st[stat.ST_MODE]) & 0111:
return f
return None
+
+def ParseConfig(env, command, function=None):
+ """Use the specified function to parse the output of the command in order
+ to modify the specified environment. The 'command' can be a string or a
+ list of strings representing a command and it's arguments. 'Function' is
+ an optional argument that takes the environment and the output of the
+ command. If no function is specified, the output will be treated as the
+ output of a typical 'X-config' command (i.e. gtk-config) and used to set
+ the CPPPATH, LIBPATH, LIBS, and CCFLAGS variables.
+ """
+ # the default parse function
+ def parse_conf(env, output):
+ env_dict = env.Dictionary()
+ static_libs = []
+
+ # setup all the dictionary options
+ if not env_dict.has_key('CPPPATH'):
+ env_dict['CPPPATH'] = []
+ if not env_dict.has_key('LIBPATH'):
+ env_dict['LIBPATH'] = []
+ if not env_dict.has_key('LIBS'):
+ env_dict['LIBS'] = []
+ if not env_dict.has_key('CCFLAGS') or env_dict['CCFLAGS'] == "":
+ env_dict['CCFLAGS'] = []
+
+ params = string.split(output)
+ for arg in params:
+ switch = arg[0:1]
+ opt = arg[1:2]
+ if switch == '-':
+ if opt == 'L':
+ env_dict['LIBPATH'].append(arg[2:])
+ elif opt == 'l':
+ env_dict['LIBS'].append(arg[2:])
+ elif opt == 'I':
+ env_dict['CPPPATH'].append(arg[2:])
+ else:
+ env_dict['CCFLAGS'].append(arg)
+ else:
+ static_libs.append(arg)
+ return static_libs
+
+ if function is None:
+ function = parse_conf
+ if type(command) is type([]):
+ command = string.join(command)
+ return function(env, os.popen(command).read())