SCons :: Node :: Node :: Class Node
[hide private]
[frames] | no frames]

Class Node

source code

object --+
         |
        Node
Known Subclasses:

The base Node class, for entities that we know how to build, or use to build other Nodes.
Nested Classes [hide private]
  Attrs
  BuildInfo
The generic base class for build information for a Node.
  NodeInfo
The generic base class for signature information for a Node.
Instance Methods [hide private]
 
Decider(self, function) source code
 
GetTag(self, key)
Return a user-defined tag.
source code
 
Tag(self, key, value)
Add a user-defined tag.
source code
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
_add_child(self, collection, set, child)
Adds 'child' to 'collection', first checking 'set' to see if it's already present.
source code
 
_children_get(self) source code
 
_children_reset(self) source code
 
_get_scanner(self, env, initial_scanner, root_node_scanner, kw) source code
 
add_dependency(self, depend)
Adds dependencies.
source code
 
add_ignore(self, depend)
Adds dependencies to ignore.
source code
 
add_prerequisite(self, prerequisite)
Adds prerequisites
source code
 
add_source(self, source)
Adds sources.
source code
 
add_to_implicit(self, deps) source code
 
add_to_waiting_parents(self, node)
Returns the number of nodes added to our waiting parents list: 1 if we add a unique waiting parent, 0 if not. (Note that the returned values are intended to be used to increment a reference count, so don't think you can "clean up" this function by using True and False instead...)
source code
 
add_to_waiting_s_e(self, node) source code
 
add_wkid(self, wkid)
Add a node to the list of kids waiting to be evaluated
source code
 
all_children(self, scan=1)
Return a list of all the node's direct children.
source code
 
alter_targets(self)
Return a list of alternate targets for this Node.
source code
 
build(self, **kw)
Actually build the node.
source code
 
builder_set(self, builder) source code
 
built(self)
Called just after this node is successfully built.
source code
 
changed(self, node=None, allowcache=False)
Returns if the node is up-to-date with respect to the BuildInfo stored last time it was built. The default behavior is to compare it against our own previously stored BuildInfo, but the stored BuildInfo from another Node (typically one in a Repository) can be used instead.
source code
 
children(self, scan=1)
Return a list of the node's direct children, minus those that are ignored by this node.
source code
 
children_are_up_to_date(self)
Alternate check for whether the Node is current: If all of our children were up-to-date, then this Node was up-to-date, too.
source code
 
clear(self)
Completely clear a Node of all its cached state (so that it can be re-evaluated by interfaces that do continuous integration builds).
source code
 
clear_memoized_values(self) source code
 
del_binfo(self)
Delete the build info from this node.
source code
 
disambiguate(self, must_exist=None) source code
 
env_set(self, env, safe=0) source code
 
executor_cleanup(self)
Let the executor clean up any cached information.
source code
 
exists(self)
Does this node exists?
source code
 
explain(self) source code
 
for_signature(self)
Return a string representation of the Node that will always be the same for this particular Node, no matter what. This is by contrast to the __str__() method, which might, for instance, return a relative path for a file Node. The purpose of this method is to generate a value to be used in signature calculation for the command line used to build a target, and we use this method instead of str() to avoid unnecessary rebuilds. This method does not need to return something that would actually work in a command line; it can return any kind of nonsense, so long as it does not change.
source code
 
get_abspath(self)
Return an absolute path to the Node. This will return simply str(Node) by default, but for Node types that have a concept of relative path, this might return something different.
source code
 
get_binfo(self)
Fetch a node's build information.
source code
 
get_build_env(self)
Fetch the appropriate Environment to build this node.
source code
 
get_build_scanner_path(self, scanner)
Fetch the appropriate scanner path for this node.
source code
 
get_builder(self, default_builder=None)
Return the set builder, or a specified default value
source code
 
get_cachedir_csig(self) source code
 
get_contents(self)
Fetch the contents of the entry.
source code
 
get_csig(self) source code
 
get_env(self) source code
 
get_env_scanner(self, env, kw={}) source code
 
get_executor(self, create=1)
Fetch the action executor for this node. Create one if there isn't already one, and requested to do so.
source code
 
get_found_includes(self, env, scanner, path)
Return the scanned include lines (implicit dependencies) found in this node.
source code
 
get_implicit_deps(self, env, initial_scanner, path_func, kw={})
Return a list of implicit dependencies for this node.
source code
 
get_ninfo(self) source code
 
get_source_scanner(self, node)
Fetch the source scanner for the specified node
source code
 
get_state(self) source code
 
get_stored_implicit(self)
Fetch the stored implicit dependencies
source code
 
get_stored_info(self) source code
 
get_string(self, for_signature)
This is a convenience function designed primarily to be used in command generators (i.e., CommandGeneratorActions or Environment variables that are callable), which are called with a for_signature argument that is nonzero if the command generator is being called to generate a signature for the command line, which determines if we should rebuild or not.
source code
 
get_subst_proxy(self)
This method is expected to return an object that will function exactly like this Node, except that it implements any additional special features that we would like to be in effect for Environment variable substitution. The principle use is that some Nodes would like to implement a __getattr__() method, but putting that in the Node type itself has a tendency to kill performance. We instead put it in a proxy and return it from this method. It is legal for this method to return self if no new functionality is needed for Environment substitution.
source code
 
get_suffix(self) source code
 
get_target_scanner(self) source code
 
has_builder(self)
Return whether this Node has a builder or not.
source code
 
has_explicit_builder(self)
Return whether this Node has an explicit builder
source code
 
is_derived(self)
Returns true if this node is derived (i.e. built).
source code
 
is_literal(self)
Always pass the string representation of a Node to the command interpreter literally.
source code
 
is_up_to_date(self)
Default check for whether the Node is current: unknown Node subtypes are always out of date, so they will always get built.
source code
 
make_ready(self)
Get a Node ready for evaluation.
source code
 
missing(self) source code
 
multiple_side_effect_has_builder(self)
Return whether this Node has a builder or not.
source code
 
new_binfo(self) source code
 
new_ninfo(self) source code
 
postprocess(self)
Clean up anything we don't need to hang onto after we've been built.
source code
 
prepare(self)
Prepare for this Node to be built.
source code
 
push_to_cache(self)
Try to push a node into a cache
source code
 
release_target_info(self)
Called just after this node has been marked up-to-date or was built completely.
source code
 
remove(self)
Remove this Node: no-op by default.
source code
 
render_include_tree(self)
Return a text representation, suitable for displaying to the user, of the include tree for the sources of this node.
source code
 
reset_executor(self)
Remove cached executor; forces recompute when needed.
source code
 
retrieve_from_cache(self)
Try to retrieve the node's content from a cache
source code
 
rexists(self)
Does this node exist locally or in a repositiory?
source code
 
scan(self)
Scan this node's dependents for implicit dependencies.
source code
 
scanner_key(self) source code
 
select_scanner(self, scanner)
Selects a scanner for this Node.
source code
 
set_always_build(self, always_build=1)
Set the Node's always_build value.
source code
 
set_executor(self, executor)
Set the action executor for this node.
source code
 
set_explicit(self, is_explicit) source code
 
set_nocache(self, nocache=1)
Set the Node's nocache value.
source code
 
set_noclean(self, noclean=1)
Set the Node's noclean value.
source code
 
set_precious(self, precious=1)
Set the Node's precious value.
source code
 
set_pseudo(self, pseudo=True)
Set the Node's precious value.
source code
 
set_specific_source(self, source) source code
 
set_state(self, state) source code
 
visited(self)
Called just after this node has been visited (with or without a build).
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  _func_exists
  _func_get_contents
  _func_is_derived
  _func_rexists
  _func_target_from_source
  _memo
  _specific_sources
  _tags
  always_build
  attributes
  binfo
  builder
  cached
  changed_since_last_build
  depends
  depends_set
  env
  executor
  ignore
  ignore_set
  implicit
  implicit_set
  includes
  is_explicit
  linked
  ninfo
  nocache
  noclean
  precious
  prerequisites
  pseudo
  ref_count
  side_effect
  side_effects
  sources
  sources_set
  state
  store_info
  waiting_parents
  waiting_s_e
  wkids

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: object.__init__
(inherited documentation)

_children_get(self)

source code 
Decorators:
  • @SCons.Memoize.CountMethodCall

build(self, **kw)

source code 

Actually build the node.

This is called by the Taskmaster after it's decided that the Node is out-of-date and must be rebuilt, and after the prepare() method has gotten everything, uh, prepared.

This method is called from multiple threads in a parallel build, so only do thread safe stuff here. Do thread unsafe stuff in built().

changed(self, node=None, allowcache=False)

source code 

Returns if the node is up-to-date with respect to the BuildInfo stored last time it was built. The default behavior is to compare it against our own previously stored BuildInfo, but the stored BuildInfo from another Node (typically one in a Repository) can be used instead.

Note that we now always check every dependency. We used to short-circuit the check by returning as soon as we detected any difference, but we now rely on checking every dependency to make sure that any necessary Node information (for example, the content signature of an #included .h file) is updated.

The allowcache option was added for supporting the early release of the executor/builder structures, right after a File target was built. When set to true, the return value of this changed method gets cached for File nodes. Like this, the executor isn't needed any longer for subsequent calls to changed().

@see: FS.File.changed(), FS.File.release_target_info()

children_are_up_to_date(self)

source code 

Alternate check for whether the Node is current: If all of our children were up-to-date, then this Node was up-to-date, too.

The SCons.Node.Alias and SCons.Node.Python.Value subclasses rebind their current() method to this method.

get_binfo(self)

source code 

Fetch a node's build information.

node - the node whose sources will be collected cache - alternate node to use for the signature cache returns - the build signature

This no longer handles the recursive descent of the node's children's signatures. We expect that they're already built and updated by someone else, if that's what's wanted.

get_build_env(self)

source code 
Fetch the appropriate Environment to build this node.
Decorators:
  • @SCons.Memoize.CountMethodCall

get_found_includes(self, env, scanner, path)

source code 

Return the scanned include lines (implicit dependencies) found in this node.

The default is no implicit dependencies. We expect this method to be overridden by any subclass that can be scanned for implicit dependencies.

get_implicit_deps(self, env, initial_scanner, path_func, kw={})

source code 

Return a list of implicit dependencies for this node.

This method exists to handle recursive invocation of the scanner on the implicit dependencies returned by the scanner, if the scanner's recursive flag says that we should.

get_source_scanner(self, node)

source code 

Fetch the source scanner for the specified node

NOTE: "self" is the target being built, "node" is the source file for which we want to fetch the scanner.

Implies self.has_builder() is true; again, expect to only be called from locations where this is already verified.

This function may be called very often; it attempts to cache the scanner found to improve performance.

get_string(self, for_signature)

source code 

This is a convenience function designed primarily to be used in command generators (i.e., CommandGeneratorActions or Environment variables that are callable), which are called with a for_signature argument that is nonzero if the command generator is being called to generate a signature for the command line, which determines if we should rebuild or not.

Such command generators should use this method in preference to str(Node) when converting a Node to a string, passing in the for_signature parameter, such that we will call Node.for_signature() or str(Node) properly, depending on whether we are calculating a signature or actually constructing a command line.

has_builder(self)

source code 

Return whether this Node has a builder or not.

In Boolean tests, this turns out to be a lot more efficient than simply examining the builder attribute directly ("if node.builder: ..."). When the builder attribute is examined directly, it ends up calling __getattr__ for both the __len__ and __nonzero__ attributes on instances of our Builder Proxy class(es), generating a bazillion extra calls and slowing things down immensely.

has_explicit_builder(self)

source code 

Return whether this Node has an explicit builder

This allows an internal Builder created by SCons to be marked non-explicit, so that it can be overridden by an explicit builder that the user supplies (the canonical example being directories).

is_derived(self)

source code 

Returns true if this node is derived (i.e. built).

This should return true only for nodes whose path should be in the variant directory when duplicate=0 and should contribute their build signatures when they are used as source files to other derived files. For example: source with source builders are not derived in this sense, and hence should not return true.

make_ready(self)

source code 

Get a Node ready for evaluation.

This is called before the Taskmaster decides if the Node is up-to-date or not. Overriding this method allows for a Node subclass to be disambiguated if necessary, or for an implicit source builder to be attached.

multiple_side_effect_has_builder(self)

source code 

Return whether this Node has a builder or not.

In Boolean tests, this turns out to be a lot more efficient than simply examining the builder attribute directly ("if node.builder: ..."). When the builder attribute is examined directly, it ends up calling __getattr__ for both the __len__ and __nonzero__ attributes on instances of our Builder Proxy class(es), generating a bazillion extra calls and slowing things down immensely.

prepare(self)

source code 

Prepare for this Node to be built.

This is called after the Taskmaster has decided that the Node is out-of-date and must be rebuilt, but before actually calling the method to build the Node.

This default implementation checks that explicit or implicit dependencies either exist or are derived, and initializes the BuildInfo structure that will hold the information about how this node is, uh, built.

(The existence of source files is checked separately by the Executor, which aggregates checks for all of the targets built by a specific action.)

Overriding this method allows for for a Node subclass to remove the underlying file from the file system. Note that subclass methods should call this base class method to get the child check and the BuildInfo structure.

release_target_info(self)

source code 

Called just after this node has been marked up-to-date or was built completely.

This is where we try to release as many target node infos as possible for clean builds and update runs, in order to minimize the overall memory consumption.

By purging attributes that aren't needed any longer after a Node (=File) got built, we don't have to care that much how many KBytes a Node actually requires...as long as we free the memory shortly afterwards.

@see: built() and File.release_target_info()

retrieve_from_cache(self)

source code 

Try to retrieve the node's content from a cache

This method is called from multiple threads in a parallel build, so only do thread safe stuff here. Do thread unsafe stuff in built().

Returns true if the node was successfully retrieved.

select_scanner(self, scanner)

source code 

Selects a scanner for this Node.

This is a separate method so it can be overridden by Node subclasses (specifically, Node.FS.Dir) that must use their own Scanner and don't select one the Scanner.Selector that's configured for the target.