[Scons-dev] Can Node.FS.Base.Rfindalldirs return uniquified results?

Simon Tegelid simon at tegelid.se
Tue Oct 27 07:45:11 EDT 2015


Hi,

Node.FS.Base.Rfindalldirs is used for include flag generation and lookup of
directories from *PATH vars. It might occur duplicate paths of various
reasons (eg. after variable substitution) in the return value from
Rfindalldirs. Wouldn't it be neat to uniqify that list to avoid duplicate
include flags for example?

diff --git a/scons-local-2.3.4/SCons/Node/FS.py
b/scons-local-2.3.4/SCons/Node/FS.py
index 4b95613..41dd8c7 100644
--- a/scons-local-2.3.4/SCons/Node/FS.py
+++ b/scons-local-2.3.4/SCons/Node/FS.py
@@ -847,9 +847,15 @@ class Base(SCons.Node.Node):
                 dir = create_dir_relative_to_self(path)
                 result.extend(dir.get_all_rdirs())

-        memo_dict[pathlist] = result
-
-        return result
+        seen = set()
+        uniqresult = []
+        for r in result:
+            if r.path not in seen:
+                uniqresult.append(r)
+                seen.add(r.path)
+        memo_dict[pathlist] = uniqresult
+
+        return uniqresult

     def RDirs(self, pathlist):
         """Search for a list of directories in the Repository list."""

-- 
Simon Tegelid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/scons-dev/attachments/20151027/91bb49b8/attachment.html>


More information about the Scons-dev mailing list