build: smarter list splitting
authorAndrew Tridgell <tridge@samba.org>
Sun, 7 Mar 2010 04:17:46 +0000 (15:17 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 6 Apr 2010 10:26:42 +0000 (20:26 +1000)
buildtools/wafsamba/samba_pidl.py
buildtools/wafsamba/samba_utils.py
buildtools/wafsamba/wafsamba.py

index a108e0399141cb4117721bdf9af2852f1b47b169..42652b66d74233503bed7793620a6597b0c1e7df 100644 (file)
@@ -85,7 +85,7 @@ Build.BuildContext.SAMBA_PIDL_TDR = SAMBA_PIDL_TDR
 #################################################################
 # define a set of Samba PIDL targets
 def SAMBA_PIDL_LIST(bld, name, source,options=''):
-    for p in source.split():
+    for p in to_list(source):
         bld.SAMBA_PIDL(name, p, options)
 Build.BuildContext.SAMBA_PIDL_LIST = SAMBA_PIDL_LIST
 
index 333477e4998f1671dad62f247becdbcad3220be4..6fef84f2daba84090f693cde0edde4e72f704265 100644 (file)
@@ -6,6 +6,7 @@ from TaskGen import feature, before
 from Configure import conf
 from Logs import debug
 from TaskGen import extension
+import shlex
 
 LIB_PATH="shared"
 
@@ -109,7 +110,7 @@ Build.BuildContext.ASSERT = ASSERT
 # create a list of files by pre-pending each with a subdir name
 def SUBDIR(bld, subdir, list):
     ret = ''
-    for l in list.split():
+    for l in to_list(list):
         ret = ret + subdir + '/' + l + ' '
     return ret
 Build.BuildContext.SUBDIR = SUBDIR
@@ -117,7 +118,7 @@ Build.BuildContext.SUBDIR = SUBDIR
 ##############################################
 # remove .. elements from a path list
 def NORMPATH(bld, ilist):
-    return " ".join([os.path.normpath(p) for p in ilist.split(" ")])
+    return " ".join([os.path.normpath(p) for p in to_list(ilist)])
 Build.BuildContext.NORMPATH = NORMPATH
 
 #######################################################
@@ -229,3 +230,9 @@ def dbg(self):
        if self.target == 'HEIMDAL_HEIM_ASN1':
                print "@@@@@@@@@@@@@@2", self.includes, self.env._CCINCFLAGS
 
+
+def to_list(str):
+    '''Split a list, preserving quoted strings and existing lists'''
+    if isinstance(str, list):
+        return str
+    return shlex.split(str)
index 7686a891b222f4fad88ed8ded9e8c863f27281f6..30324f7d7a1a9c61b95efa88c6863579b267b64d 100644 (file)
@@ -27,12 +27,6 @@ def SAMBA_BUILD_ENV(conf):
     if not os.path.exists(libpath):
         os.mkdir(libpath)
 
-##############################################
-# remove .. elements from a path list
-def NORMPATH(bld, ilist):
-    return " ".join([os.path.normpath(p) for p in ilist.split(" ")])
-Build.BuildContext.NORMPATH = NORMPATH
-
 ################################################################
 # add an init_function to the list for a subsystem
 def ADD_INIT_FUNCTION(bld, subsystem, init_function):
@@ -102,7 +96,7 @@ def ADD_DEPENDENCIES(bld, name, deps):
     lib_deps = LOCAL_CACHE(bld, 'LIB_DEPS')
     if not name in lib_deps:
         lib_deps[name] = {}
-    list = deps.split()
+    list = to_list(deps)
     list2 = []
     for d in list:
         lib_deps[name][d] = True;
@@ -161,9 +155,9 @@ def ADD_DEPENDENCIES(bld, name, deps):
         if recurse and (d in lib_deps):
             rec_deps = ' '.join(lib_deps[d].keys())
             (rec_sysdeps, rec_localdeps, rec_add_objects) = ADD_DEPENDENCIES(bld, d, rec_deps)
-            sysdeps.extend(rec_sysdeps.split())
-            localdeps.extend(rec_localdeps.split())
-            add_objects.extend(rec_add_objects.split())
+            sysdeps.extend(to_list(rec_sysdeps))
+            localdeps.extend(to_list(rec_localdeps))
+            add_objects.extend(to_list(rec_add_objects))
 
     debug('deps: Dependencies for %s: sysdeps: %u  localdeps: %u  add_objects=%u' % (
             name, len(sysdeps), len(localdeps), len(add_objects)))
@@ -175,7 +169,7 @@ def ADD_DEPENDENCIES(bld, name, deps):
 def SAMBA_LIBRARY_INCLUDE_LIST(bld, deps):
     ret = bld.curdir + ' '
     cache = LOCAL_CACHE(bld, 'INCLUDE_LIST')
-    for l in deps.split():
+    for l in to_list(deps):
         if l in cache:
             ret = ret + cache[l] + ' '
     if 'EXTRA_INCLUDES' in bld.env:
@@ -272,7 +266,7 @@ def SAMBA_BINARY(bld, binname, source,
 
     cache = LOCAL_CACHE(bld, 'INIT_FUNCTIONS')
     if modules is not None:
-        for m in modules.split():
+        for m in to_list(modules):
             bld.ASSERT(m in cache,
                        "No init_function defined for module '%s' in binary '%s'" % (m, binname))
             cflags += ' -DSTATIC_%s_MODULES="%s"' % (m, cache[m])