3 # Copyright The SCons Foundation
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 This creates a hash of global Aliases (dummy targets).
34 from SCons
.Util
import hash_signature
36 class AliasNameSpace(collections
.UserDict
):
37 def Alias(self
, name
, **kw
):
38 if isinstance(name
, SCons
.Node
.Alias
.Alias
):
43 a
= SCons
.Node
.Alias
.Alias(name
, **kw
)
47 def lookup(self
, name
, **kw
):
53 class AliasNodeInfo(SCons
.Node
.NodeInfoBase
):
55 current_version_id
= 2
57 def str_to_node(self
, s
):
58 return default_ans
.Alias(s
)
60 class AliasBuildInfo(SCons
.Node
.BuildInfoBase
):
62 current_version_id
= 2
64 class Alias(SCons
.Node
.Node
):
66 NodeInfo
= AliasNodeInfo
67 BuildInfo
= AliasBuildInfo
69 def __init__(self
, name
) -> None:
72 self
.changed_since_last_build
= 1
75 def str_for_display(self
):
76 return '"' + self
.__str
__() + '"'
78 def __str__(self
) -> str:
81 def make_ready(self
) -> None:
84 really_build
= SCons
.Node
.Node
.build
85 is_up_to_date
= SCons
.Node
.Node
.children_are_up_to_date
87 def is_under(self
, dir) -> bool:
88 # Make Alias nodes get built regardless of
89 # what directory scons was run from. Alias nodes
90 # are outside the filesystem:
93 def get_contents(self
):
94 """The contents of an alias is the concatenation
95 of the content signatures of all its sources."""
96 childsigs
= [n
.get_csig() for n
in self
.children()]
97 return ''.join(childsigs
)
99 def sconsign(self
) -> None:
100 """An Alias is not recorded in .sconsign files"""
107 def build(self
) -> None:
108 """A "builder" for aliases."""
111 def convert(self
) -> None:
112 try: del self
.builder
113 except AttributeError: pass
114 self
.reset_executor()
115 self
.build
= self
.really_build
119 Generate a node's content signature, the digested signature
123 cache - alternate node to use for the signature cache
124 returns - the content signature
127 return self
.ninfo
.csig
128 except AttributeError:
131 contents
= self
.get_contents()
132 csig
= hash_signature(contents
)
133 self
.get_ninfo().csig
= csig
136 default_ans
= AliasNameSpace()
138 SCons
.Node
.arg2nodes_lookups
.append(default_ans
.lookup
)
142 # indent-tabs-mode:nil
144 # vim: set expandtab tabstop=4 shiftwidth=4: