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

Class CacheDir

source code

object --+
         |
        CacheDir

Instance Methods [hide private]
 
__init__(self, path)
Initialize a CacheDir object.
source code
 
_readconfig3(self, path)
Python3 version of reading the cache config.
source code
 
_readconfig2(self, path)
Python2 version of reading cache config.
source code
 
CacheDebug(self, fmt, target, cachefile) source code
 
is_enabled(self) source code
 
is_readonly(self) source code
 
cachepath(self, node) source code
 
retrieve(self, node)
This method is called from multiple threads in a parallel build, so only do thread safe stuff here. Do thread unsafe stuff in built().
source code
 
push(self, node) source code
 
push_if_forced(self, node) source code

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

Properties [hide private]
  hit_ratio
  misses

Inherited from object: __class__

Method Details [hide private]

__init__(self, path)
(Constructor)

source code 

Initialize a CacheDir object.

The cache configuration is stored in the object. It is read from the config file in the supplied path if one exists, if not the config file is created and the default config is written, as well as saved in the object.

Overrides: object.__init__

_readconfig3(self, path)

source code 

Python3 version of reading the cache config.

If directory or config file do not exist, create. Take advantage of Py3 capability in os.makedirs() and in file open(): just try the operation and handle failure appropriately.

Omit the check for old cache format, assume that's old enough there will be none of those left to worry about.

Parameters:
  • path - path to the cache directory

_readconfig2(self, path)

source code 

Python2 version of reading cache config.

See if there is a config file in the cache directory. If there is, use it. If there isn't, and the directory exists and isn't empty, produce a warning. If the directory does not exist or is empty, write a config file.

Parameters:
  • path - path to the cache directory

retrieve(self, node)

source code 

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

Note that there's a special trick here with the execute flag (one that's not normally done for other actions). Basically if the user requested a no_exec (-n) build, then SCons.Action.execute_actions is set to 0 and when any action is called, it does its showing but then just returns zero instead of actually calling the action execution operation. The problem for caching is that if the file does NOT exist in cache then the CacheRetrieveString won't return anything to show for the task, but the Action.__call__ won't call CacheRetrieveFunc; instead it just returns zero, which makes the code below think that the file was successfully retrieved from the cache, therefore it doesn't do any subsequent building. However, the CacheRetrieveString didn't print anything because it didn't actually exist in the cache, and no more build actions will be performed, so the user just sees nothing. The fix is to tell Action.__call__ to always execute the CacheRetrieveFunc and then have the latter explicitly check SCons.Action.execute_actions itself.


Property Details [hide private]

hit_ratio

Get Method:
unreachable.hit_ratio(self)

misses

Get Method:
unreachable.misses(self)