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
The generic base class for build information for a Node.

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) source code
 
get_text_contents(self) 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
 
store_info(self)
Make the build signature permanent (that is, store it in the .sconsign file or equivalent).
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
 
changed_timestamp_then_content(self, target, prev_ni) source code
 
changed_timestamp_newer(self, target, prev_ni) source code
 
changed_timestamp_match(self, target, prev_ni) source code
 
decide_source(self, target, prev_ni)
Must be overridden in a specific subclass to return True if this Node (a dependency) has changed since the last time it was used to build the specified target. prev_ni is this Node's state (for example, its file timestamp, length, maybe content signature) as of the last time the target was built.
source code
 
decide_target(self, target, prev_ni) source code
 
changed_since_last_build(self, target, prev_ni)
Must be overridden in a specific subclass to return True if this Node (a dependency) has changed since the last time it was used to build the specified target. prev_ni is this Node's state (for example, its file timestamp, length, maybe content signature) as of the last time the target was built.
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
 
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, __str__, for_signature, get_abspath, get_dir, get_path, get_subst_proxy, get_suffix, 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, 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, do_not_store_info, 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, state_has_changed

Inherited from Node (private): _add_child, _children_get, _children_reset

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

Class Variables [hide private]
  memoizer_counters = []
  md5_chunksize = 64
  convert_copy_attrs = ['bsources', 'bimplicit', 'bdepends', 'ba...
  convert_sig_attrs = ['bsourcesigs', 'bimplicitsigs', 'bdepends...

Inherited from Node: __metaclass__

Instance Variables [hide private]

Inherited from Base: fs, name, suffix

Properties [hide private]

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

store_info(self)

source code 
Make the build signature permanent (that is, store it in the .sconsign file or equivalent).
Overrides: Node.store_info
(inherited documentation)

get_stored_info(self)

source code 
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.
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 *.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?
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

changed_since_last_build(self, target, prev_ni)

source code 

Must be overridden in a specific subclass to return True if this Node (a dependency) has changed since the last time it was used to build the specified target. prev_ni is this Node's state (for example, its file timestamp, length, maybe content signature) as of the last time the target was built.

Note that this method is called through the dependency, not the target, because a dependency Node must be able to use its own logic to decide if it changed. For example, File Nodes need to obey if we're configured to use timestamps, but Python Value Nodes never use timestamps and always use the content. If this method were called through the target, then each Node's implementation of this method would have to have more complicated logic to handle all the different Node types on which it might depend.

Overrides: Node.changed_since_last_build
(inherited documentation)

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 
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.


Class Variable Details [hide private]

convert_copy_attrs

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

convert_sig_attrs

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