Package SCons :: Package Node :: Module Alias
[hide private]
[frames] | no frames]

Source Code for Module SCons.Node.Alias

  1   
  2  """scons.Node.Alias 
  3   
  4  Alias nodes. 
  5   
  6  This creates a hash of global Aliases (dummy targets). 
  7   
  8  """ 
  9   
 10  # 
 11  # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation 
 12  # 
 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: 
 20  # 
 21  # The above copyright notice and this permission notice shall be included 
 22  # in all copies or substantial portions of the Software. 
 23  # 
 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. 
 31  # 
 32   
 33  __revision__ = "src/engine/SCons/Node/Alias.py 2928 2008/04/29 22:44:09 knight" 
 34   
 35  import string 
 36  import UserDict 
 37   
 38  import SCons.Errors 
 39  import SCons.Node 
 40  import SCons.Util 
 41   
42 -class AliasNameSpace(UserDict.UserDict):
43 - def Alias(self, name, **kw):
44 if isinstance(name, SCons.Node.Alias.Alias): 45 return name 46 try: 47 a = self[name] 48 except KeyError: 49 a = apply(SCons.Node.Alias.Alias, (name,), kw) 50 self[name] = a 51 return a
52
53 - def lookup(self, name, **kw):
54 try: 55 return self[name] 56 except KeyError: 57 return None
58
59 -class AliasNodeInfo(SCons.Node.NodeInfoBase):
60 current_version_id = 1 61 field_list = ['csig']
62 - def str_to_node(self, s):
63 return default_ans.Alias(s)
64
65 -class AliasBuildInfo(SCons.Node.BuildInfoBase):
66 current_version_id = 1
67
68 -class Alias(SCons.Node.Node):
69 70 NodeInfo = AliasNodeInfo 71 BuildInfo = AliasBuildInfo 72
73 - def __init__(self, name):
74 SCons.Node.Node.__init__(self) 75 self.name = name
76
77 - def __str__(self):
78 return self.name
79
80 - def make_ready(self):
81 self.get_csig()
82 83 really_build = SCons.Node.Node.build 84 is_up_to_date = SCons.Node.Node.children_are_up_to_date 85
86 - def is_under(self, dir):
87 # Make Alias nodes get built regardless of 88 # what directory scons was run from. Alias nodes 89 # are outside the filesystem: 90 return 1
91
92 - def get_contents(self):
93 """The contents of an alias is the concatenation 94 of the content signatures of all its sources.""" 95 childsigs = map(lambda n: n.get_csig(), self.children()) 96 return string.join(childsigs, '')
97
98 - def sconsign(self):
99 """An Alias is not recorded in .sconsign files""" 100 pass
101 102 # 103 # 104 # 105
106 - def changed_since_last_build(self, target, prev_ni):
107 cur_csig = self.get_csig() 108 try: 109 return cur_csig != prev_ni.csig 110 except AttributeError: 111 return 1
112
113 - def build(self):
114 """A "builder" for aliases.""" 115 pass
116
117 - def convert(self):
118 try: del self.builder 119 except AttributeError: pass 120 self.reset_executor() 121 self.build = self.really_build
122
123 - def get_csig(self):
124 """ 125 Generate a node's content signature, the digested signature 126 of its content. 127 128 node - the node 129 cache - alternate node to use for the signature cache 130 returns - the content signature 131 """ 132 try: 133 return self.ninfo.csig 134 except AttributeError: 135 pass 136 137 contents = self.get_contents() 138 csig = SCons.Util.MD5signature(contents) 139 self.get_ninfo().csig = csig 140 return csig
141 142 default_ans = AliasNameSpace() 143 144 SCons.Node.arg2nodes_lookups.append(default_ans.lookup) 145