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 - 2017 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 74b2c53bc42290e911b334a6b44f187da698a668 2017/11/14 13:16:53 bdbaddog" 
 34   
 35  import collections 
 36   
 37  import SCons.Errors 
 38  import SCons.Node 
 39  import SCons.Util 
 40   
41 -class AliasNameSpace(collections.UserDict):
42 - def Alias(self, name, **kw):
43 if isinstance(name, SCons.Node.Alias.Alias): 44 return name 45 try: 46 a = self[name] 47 except KeyError: 48 a = SCons.Node.Alias.Alias(name, **kw) 49 self[name] = a 50 return a
51
52 - def lookup(self, name, **kw):
53 try: 54 return self[name] 55 except KeyError: 56 return None
57
58 -class AliasNodeInfo(SCons.Node.NodeInfoBase):
59 __slots__ = ('csig',) 60 current_version_id = 2 61 field_list = ['csig']
62 - def str_to_node(self, s):
63 return default_ans.Alias(s)
64
65 - def __getstate__(self):
66 """ 67 Return all fields that shall be pickled. Walk the slots in the class 68 hierarchy and add those to the state dictionary. If a '__dict__' slot is 69 available, copy all entries to the dictionary. Also include the version 70 id, which is fixed for all instances of a class. 71 """ 72 state = getattr(self, '__dict__', {}).copy() 73 for obj in type(self).mro(): 74 for name in getattr(obj,'__slots__',()): 75 if hasattr(self, name): 76 state[name] = getattr(self, name) 77 78 state['_version_id'] = self.current_version_id 79 try: 80 del state['__weakref__'] 81 except KeyError: 82 pass 83 84 return state
85
86 - def __setstate__(self, state):
87 """ 88 Restore the attributes from a pickled state. 89 """ 90 # TODO check or discard version 91 del state['_version_id'] 92 for key, value in state.items(): 93 if key not in ('__weakref__',): 94 setattr(self, key, value)
95 96
97 -class AliasBuildInfo(SCons.Node.BuildInfoBase):
98 __slots__ = () 99 current_version_id = 2
100
101 -class Alias(SCons.Node.Node):
102 103 NodeInfo = AliasNodeInfo 104 BuildInfo = AliasBuildInfo 105
106 - def __init__(self, name):
107 SCons.Node.Node.__init__(self) 108 self.name = name 109 self.changed_since_last_build = 1 110 self.store_info = 0
111
112 - def str_for_display(self):
113 return '"' + self.__str__() + '"'
114
115 - def __str__(self):
116 return self.name
117
118 - def make_ready(self):
119 self.get_csig()
120 121 really_build = SCons.Node.Node.build 122 is_up_to_date = SCons.Node.Node.children_are_up_to_date 123
124 - def is_under(self, dir):
125 # Make Alias nodes get built regardless of 126 # what directory scons was run from. Alias nodes 127 # are outside the filesystem: 128 return 1
129
130 - def get_contents(self):
131 """The contents of an alias is the concatenation 132 of the content signatures of all its sources.""" 133 childsigs = [n.get_csig() for n in self.children()] 134 return ''.join(childsigs)
135
136 - def sconsign(self):
137 """An Alias is not recorded in .sconsign files""" 138 pass
139 140 # 141 # 142 # 143
144 - def build(self):
145 """A "builder" for aliases.""" 146 pass
147
148 - def convert(self):
149 try: del self.builder 150 except AttributeError: pass 151 self.reset_executor() 152 self.build = self.really_build
153
154 - def get_csig(self):
155 """ 156 Generate a node's content signature, the digested signature 157 of its content. 158 159 node - the node 160 cache - alternate node to use for the signature cache 161 returns - the content signature 162 """ 163 try: 164 return self.ninfo.csig 165 except AttributeError: 166 pass 167 168 contents = self.get_contents() 169 csig = SCons.Util.MD5signature(contents) 170 self.get_ninfo().csig = csig 171 return csig
172 173 default_ans = AliasNameSpace() 174 175 SCons.Node.arg2nodes_lookups.append(default_ans.lookup) 176 177 # Local Variables: 178 # tab-width:4 179 # indent-tabs-mode:nil 180 # End: 181 # vim: set expandtab tabstop=4 shiftwidth=4: 182