Package SCons :: Package Node :: Module FS :: Class File
[hide private]
[frames] | no frames]

Class File

source code

object --+        
         |        
      Node --+    
             |    
          Base --+
                 |
                File

A class for files in a file system.
Nested Classes [hide private]
  NodeInfo
The generic base class for signature information for a Node.
  BuildInfo
This is info loaded from sconsign.

Inherited from Node: Attrs

Instance Methods [hide private]
 
diskcheck_match(self) source code
 
__init__(self, name, directory, fs)
Initialize a generic Node.FS.Base object.
source code
 
Entry(self, name)
Create an entry node named 'name' relative to the directory of this file.
source code
 
Dir(self, name, create=True)
Create a directory node named 'name' relative to the directory of this file.
source code
 
Dirs(self, pathlist)
Create a list of directories relative to the SConscript directory of this file.
source code
 
File(self, name)
Create a file node named 'name' relative to the directory of this file.
source code
 
_morph(self)
Turn a file system node into a File object.
source code
 
scanner_key(self) source code
 
get_contents(self)
Fetch the contents of the entry.
source code
 
get_text_contents(self)
This attempts to figure out what the encoding of the text is based upon the BOM bytes, and then decodes the contents so that it's a valid python string.
source code
 
get_content_hash(self)
Compute and return the MD5 hash for this file.
source code
 
get_size(self) source code
 
get_timestamp(self) source code
 
convert_old_entry(self, old_entry) source code
 
get_stored_info(self) source code
 
get_stored_implicit(self)
Fetch the stored implicit dependencies
source code
 
rel_path(self, other) source code
 
_get_found_includes_key(self, env, scanner, path) source code
 
get_found_includes(self, env, scanner, path)
Return the included implicit dependencies in this file. Cache results so we only scan the file once per path regardless of how many times this information is requested.
source code
 
_createDir(self) source code
 
push_to_cache(self)
Try to push the node into a cache
source code
 
retrieve_from_cache(self)
Try to retrieve the node's content from a cache
source code
 
visited(self)
Called just after this node has been visited (with or without a build).
source code
 
release_target_info(self)
Called just after this node has been marked up-to-date or was built completely.
source code
 
find_src_builder(self) source code
 
has_src_builder(self)
Return whether this Node has a source builder or not.
source code
 
alter_targets(self)
Return any corresponding targets in a variant directory.
source code
 
_rmv_existing(self) source code
 
make_ready(self)
Get a Node ready for evaluation.
source code
 
prepare(self)
Prepare for this file to be created.
source code
 
remove(self)
Remove this file.
source code
 
do_duplicate(self, src) source code
 
exists(self)
Does this node exists?
source code
 
get_max_drift_csig(self)
Returns the content signature currently stored for this node if it's been unmodified longer than the max_drift value, or the max_drift value is 0. Returns None otherwise.
source code
 
get_csig(self)
Generate a node's content signature, the digested signature of its content.
source code
 
builder_set(self, builder) source code
 
built(self)
Called just after this File 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.
source code
 
changed_content(self, target, prev_ni) source code
 
changed_state(self, target, prev_ni) source code
 
_build_dependency_map(self, binfo)
Build mapping from file -> signature
source code
 
_get_previous_signatures(self, dmap)
Return a list of corresponding csigs from previous build in order of the node/files in children.
source code
 
changed_timestamp_then_content(self, target, prev_ni, node=None)
Used when decider for file is Timestamp-MD5
source code
 
changed_timestamp_newer(self, target, prev_ni) source code
 
changed_timestamp_match(self, target, prev_ni)
Return True if the timestamps don't match or if there is no previous timestamp :param target: :param prev_ni: Information about the node from the previous build :return:
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
 
rfile(self) source code
 
find_repo_file(self)
For this node, find if there exists a corresponding file in one or more repositories :return: list of corresponding files in repositories
source code
 
rstr(self)
A Node.FS.Base object's string representation is its path name.
source code
 
get_cachedir_csig(self)
Fetch a Node's content signature for purposes of computing another Node's cachesig.
source code
 
get_contents_sig(self)
A helper method for get_cachedir_bsig.
source code
 
get_cachedir_bsig(self)
Return the signature for a cached file, including its children.
source code

Inherited from Base: RDirs, Rfindalldirs, __getattr__, __lt__, __str__, for_signature, get_abspath, get_dir, get_internal_path, get_labspath, get_path, get_path_elements, get_subst_proxy, get_suffix, get_tpath, getmtime, getsize, is_under, isdir, isfile, islink, must_be_same, rentry, rexists, set_local, set_src_builder, src_builder, srcnode, stat, str_for_display, target_from_source

Inherited from Base (private): _Rfindalldirs_key, _get_str, _glob1, _save_str

Inherited from Node: Decider, GetTag, Tag, add_dependency, add_ignore, add_prerequisite, add_source, add_to_implicit, add_to_waiting_parents, add_to_waiting_s_e, add_wkid, all_children, build, children, children_are_up_to_date, clear, clear_memoized_values, del_binfo, disambiguate, env_set, executor_cleanup, explain, get_binfo, get_build_env, get_build_scanner_path, get_builder, get_env, get_env_scanner, get_executor, get_implicit_deps, get_ninfo, get_source_scanner, get_state, get_string, get_target_scanner, has_builder, has_explicit_builder, is_derived, is_literal, missing, multiple_side_effect_has_builder, new_binfo, new_ninfo, postprocess, render_include_tree, reset_executor, scan, select_scanner, set_always_build, set_executor, set_explicit, set_nocache, set_noclean, set_precious, set_pseudo, set_specific_source, set_state

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

Class Variables [hide private]
  md5_chunksize = 64
  convert_copy_attrs = ['bsources', 'bimplicit', 'bdepends', 'ba...
  convert_sig_attrs = ['bsourcesigs', 'bimplicitsigs', 'bdepends...
  __dmap_cache = {}
  __dmap_sig_cache = {}
Instance Variables [hide private]

Inherited from Base: fs

Properties [hide private]
  _sconsign
  cachedir_csig
  cachesig
  contentsig
  dirname
  entries
  on_disk_entries
  released_target_info
  repositories
  root
  scanner_paths
  searched
  srcdir
  variant_dirs

Inherited from Base: cwd, dir, duplicate, name, sbuilder

Inherited from Node: 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, name, directory, fs)
(Constructor)

source code 

Initialize a generic Node.FS.Base object.

Call the superclass initialization, take care of setting up our relative and absolute paths, identify our parent directory, and indicate that this node should use signatures.

Overrides: object.__init__
(inherited documentation)

scanner_key(self)

source code 
Overrides: Node.scanner_key

get_contents(self)

source code 
Fetch the contents of the entry.
Overrides: Node.get_contents
(inherited documentation)

get_size(self)

source code 
Decorators:
  • @SCons.Memoize.CountMethodCall

get_timestamp(self)

source code 
Decorators:
  • @SCons.Memoize.CountMethodCall

get_stored_info(self)

source code 
Decorators:
  • @SCons.Memoize.CountMethodCall
Overrides: Node.get_stored_info

get_stored_implicit(self)

source code 
Fetch the stored implicit dependencies
Overrides: Node.get_stored_implicit
(inherited documentation)

get_found_includes(self, env, scanner, path)

source code 
Return the included implicit dependencies in this file. Cache results so we only scan the file once per path regardless of how many times this information is requested.
Decorators:
  • @SCons.Memoize.CountDictCall(_get_found_includes_key)
Overrides: Node.get_found_includes

push_to_cache(self)

source code 
Try to push the node into a cache
Overrides: Node.push_to_cache

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.

Overrides: Node.retrieve_from_cache

visited(self)

source code 
Called just after this node has been visited (with or without a build).
Overrides: Node.visited
(inherited documentation)

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.

We'd like to remove a lot more attributes like self.sources and self.sources_set, but they might get used in a next build step. For example, during configuration the source files for a built E{*}.o file are used to figure out which linker to use for the resulting Program (gcc vs. g++)! That's why we check for the 'keep_targetinfo' attribute, config Nodes and the Interactive mode just don't allow an early release of most variables.

In the same manner, we can't simply remove the self.attributes here. The smart linking relies on the shared flag, and some parts of the java Tool use it to transport information about nodes...

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

Overrides: Node.release_target_info

has_src_builder(self)

source code 

Return whether this Node has a source builder or not.

If this Node doesn't have an explicit source code builder, this is where we figure out, on the fly, if there's a transparent source code builder for it.

Note that if we found a source builder, we also set the self.builder attribute, so that all of the methods that actually build this file don't have to do anything different.

alter_targets(self)

source code 
Return any corresponding targets in a variant directory.
Overrides: Node.alter_targets

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.

Overrides: Node.make_ready
(inherited documentation)

prepare(self)

source code 
Prepare for this file to be created.
Overrides: Node.prepare

remove(self)

source code 
Remove this file.
Overrides: Node.remove

exists(self)

source code 
Does this node exists?
Decorators:
  • @SCons.Memoize.CountMethodCall
Overrides: Node.exists
(inherited documentation)

get_csig(self)

source code 

Generate a node's content signature, the digested signature of its content.

node - the node cache - alternate node to use for the signature cache returns - the content signature

Overrides: Node.get_csig

builder_set(self, builder)

source code 
Overrides: Node.builder_set

built(self)

source code 

Called just after this File node is successfully built.

Just like for 'release_target_info' we try to release some more target node attributes in order to minimize the overall memory consumption.

@see: release_target_info

Overrides: Node.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.

For File nodes this is basically a wrapper around Node.changed(), but we allow the return value to get cached after the reference to the Executor got released in release_target_info().

@see: Node.changed()

Overrides: Node.changed

_build_dependency_map(self, binfo)

source code 

Build mapping from file -> signature

Args:
self - self binfo - buildinfo from node being considered
Returns:
dictionary of file->signature mappings

_get_previous_signatures(self, dmap)

source code 

Return a list of corresponding csigs from previous build in order of the node/files in children.

Args:
self - self dmap - Dictionary of file -> csig
Returns:
List of csigs for provided list of children

changed_timestamp_then_content(self, target, prev_ni, node=None)

source code 

Used when decider for file is Timestamp-MD5

NOTE: If the timestamp hasn't changed this will skip md5'ing the
      file and just copy the prev_ni provided.  If the prev_ni
      is wrong. It will propagate it.
      See: https://github.com/SCons/scons/issues/2980

Args:
    self - dependency
    target - target
    prev_ni - The NodeInfo object loaded from previous builds .sconsign
    node - Node instance.  This is the only changed* function which requires
           node to function. So if we detect that it's not passed.
           we throw DeciderNeedsNode, and caller should handle this and pass node.

Returns: 
    Boolean - Indicates if node(File) has changed.

is_up_to_date(self)

source code 
Default check for whether the Node is current: unknown Node subtypes are always out of date, so they will always get built.
Overrides: Node.is_up_to_date
(inherited documentation)

rfile(self)

source code 
Decorators:
  • @SCons.Memoize.CountMethodCall
Overrides: Base.rfile

rstr(self)

source code 
A Node.FS.Base object's string representation is its path name.
Overrides: Base.__str__
(inherited documentation)

get_cachedir_csig(self)

source code 

Fetch a Node's content signature for purposes of computing another Node's cachesig.

This is a wrapper around the normal get_csig() method that handles the somewhat obscure case of using CacheDir with the -n option. Any files that don't exist would normally be "built" by fetching them from the cache, but the normal get_csig() method will try to open up the local file, which doesn't exist because the -n option meant we didn't actually pull the file from cachedir. But since the file does actually exist in the cachedir, we can use its contents for the csig.

Overrides: Node.get_cachedir_csig

get_contents_sig(self)

source code 

A helper method for get_cachedir_bsig.

It computes and returns the signature for this node's contents.

get_cachedir_bsig(self)

source code 

Return the signature for a cached file, including its children.

It adds the path of the cached file to the cache signature, because multiple targets built by the same action will all have the same build signature, and we have to differentiate them somehow.

Signature should normally be string of hex digits.


Class Variable Details [hide private]

convert_copy_attrs

Value:
['bsources', 'bimplicit', 'bdepends', 'bact', 'bactsig', 'ninfo']

convert_sig_attrs

Value:
['bsourcesigs', 'bimplicitsigs', 'bdependsigs']