Refactor Main.py's Alias lookup to allow customized Alias (sub-)classes. (Stanislav...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 18 Mar 2005 22:40:53 +0000 (22:40 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 18 Mar 2005 22:40:53 +0000 (22:40 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1259 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Node/Alias.py
src/engine/SCons/Script/Main.py

index a934bf47087c5f441f6251d69b37374767814526..d6edd56dde97a35dafb63fd60225a1bcd3ed3c4c 100644 (file)
@@ -25,6 +25,10 @@ RELEASE 0.97 - XXX
   - Allow Tools found on a toolpath to import Python modules from
     their local directory.
 
+  From Stanislav Baranov:
+
+  - Make it possible to support with custom Alias (sub-)classes.
+
   From Timothee Besset:
 
   - Add support for Objective C/C++ .m and .mm file suffixes (for
index c3618382d6c242508e48b61f3dad054872c3aee6..2730abfeb4df798835a4182cc5f202874c332e31 100644 (file)
@@ -49,7 +49,7 @@ class AliasNameSpace(UserDict.UserDict):
             self[name] = a
         return a
 
-    def lookup(self, name):
+    def lookup(self, name, **kw):
         try:
             return self[name]
         except KeyError:
index f66f214fc0d452695870043549b97d98fd03328b..494fbc92e8bbd7fa22a9d21c85f9af925d3162ae 100644 (file)
@@ -1014,7 +1014,17 @@ def _main(args, parser):
         if isinstance(x, SCons.Node.Node):
             node = x
         else:
-            node = SCons.Node.Alias.default_ans.lookup(x)
+            node = None
+            # Why would ltop be None? Unfortunately this happens.
+            if ltop == None: ltop = ''
+            # Curdir becomes important when SCons is called with -u, -C,
+            # or similar option that changes directory, and so the paths
+            # of targets given on the command line need to be adjusted.
+            curdir = os.path.join(os.getcwd(), str(ltop))
+            for lookup in SCons.Node.arg2nodes_lookups:
+                node = lookup(x, curdir=curdir)
+                if node != None:
+                    break
             if node is None:
                 node = fs.Entry(x, directory=ltop, create=1)
         if ttop and not node.is_under(ttop):
@@ -1024,7 +1034,7 @@ def _main(args, parser):
                 node = None
         return node
 
-    nodes = filter(lambda x: x is not None, map(Entry, targets))
+    nodes = filter(None, map(Entry, targets))
 
     task_class = BuildTask     # default action is to build targets
     opening_message = "Building targets ..."