6 This creates a hash of global Aliases (dummy targets).
11 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation
13 # Permission is hereby granted, free of charge, to any person obtaining
14 # a copy of this software and associated documentation files (the
15 # "Software"), to deal in the Software without restriction, including
16 # without limitation the rights to use, copy, modify, merge, publish,
17 # distribute, sublicense, and/or sell copies of the Software, and to
18 # permit persons to whom the Software is furnished to do so, subject to
19 # the following conditions:
21 # The above copyright notice and this permission notice shall be included
22 # in all copies or substantial portions of the Software.
24 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
25 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
26 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 __revision__ = "src/engine/SCons/Node/Alias.py 3842 2008/12/20 22:59:52 scons"
42 class AliasNameSpace(UserDict.UserDict):
43 def Alias(self, name, **kw):
44 if isinstance(name, SCons.Node.Alias.Alias):
49 a = apply(SCons.Node.Alias.Alias, (name,), kw)
53 def lookup(self, name, **kw):
59 class AliasNodeInfo(SCons.Node.NodeInfoBase):
60 current_version_id = 1
62 def str_to_node(self, s):
63 return default_ans.Alias(s)
65 class AliasBuildInfo(SCons.Node.BuildInfoBase):
66 current_version_id = 1
68 class Alias(SCons.Node.Node):
70 NodeInfo = AliasNodeInfo
71 BuildInfo = AliasBuildInfo
73 def __init__(self, name):
74 SCons.Node.Node.__init__(self)
77 def str_for_display(self):
78 return '"' + self.__str__() + '"'
86 really_build = SCons.Node.Node.build
87 is_up_to_date = SCons.Node.Node.children_are_up_to_date
89 def is_under(self, dir):
90 # Make Alias nodes get built regardless of
91 # what directory scons was run from. Alias nodes
92 # are outside the filesystem:
95 def get_contents(self):
96 """The contents of an alias is the concatenation
97 of the content signatures of all its sources."""
98 childsigs = map(lambda n: n.get_csig(), self.children())
99 return string.join(childsigs, '')
102 """An Alias is not recorded in .sconsign files"""
109 def changed_since_last_build(self, target, prev_ni):
110 cur_csig = self.get_csig()
112 return cur_csig != prev_ni.csig
113 except AttributeError:
117 """A "builder" for aliases."""
121 try: del self.builder
122 except AttributeError: pass
123 self.reset_executor()
124 self.build = self.really_build
128 Generate a node's content signature, the digested signature
132 cache - alternate node to use for the signature cache
133 returns - the content signature
136 return self.ninfo.csig
137 except AttributeError:
140 contents = self.get_contents()
141 csig = SCons.Util.MD5signature(contents)
142 self.get_ninfo().csig = csig
145 default_ans = AliasNameSpace()
147 SCons.Node.arg2nodes_lookups.append(default_ans.lookup)