Package SCons :: Module Action
[hide private]
[frames] | no frames]

Module Action

source code

SCons.Action

This encapsulates information about executing any sort of action that can build one or more target Nodes (typically files) from one or more source Nodes (also typically files) given a specific Environment.

The base class here is ActionBase. The base class supplies just a few OO utility methods and some generic methods for displaying information about an Action in response to the various commands that control printing.

A second-level base class is _ActionAction. This extends ActionBase by providing the methods that can be used to show and perform an action. True Action objects will subclass _ActionAction; Action factory class objects will subclass ActionBase.

The heavy lifting is handled by subclasses for the different types of actions we might execute:

CommandAction CommandGeneratorAction FunctionAction ListAction

The subclasses supply the following public interface methods used by other modules:

__call__()
THE public interface, "calling" an Action object executes the command or Python function. This also takes care of printing a pre-substitution command for debugging purposes.
get_contents()
Fetches the "contents" of an Action for signature calculation plus the varlist. This is what gets MD5 checksummed to decide if a target needs to be rebuilt because its action changed.
genstring()
Returns a string representation of the Action without command substitution, but allows a CommandGeneratorAction to generate the right action based on the specified target, source and env. This is used by the Signature subsystem (through the Executor) to obtain an (imprecise) representation of the Action operation for informative purposes.

Subclasses also supply the following methods for internal use within this module:

__str__()
Returns a string approximation of the Action; no variable substitution is performed.
execute()
The internal method that really, truly, actually handles the execution of a command or Python function. This is used so that the __call__() methods can take care of displaying any pre-substitution representations, and then execute an action without worrying about the specific Actions involved.
get_presig()
Fetches the "contents" of a subclass for signature calculation. The varlist is added to this to produce the Action's contents.
strfunction()
Returns a substituted string representation of the Action. This is used by the _ActionAction.show() command to display the command/function that will be executed to generate the target(s).

There is a related independent ActionCaller class that looks like a regular Action, and which serves as a wrapper for arbitrary functions that we want to let the user specify the arguments to now, but actually execute later (when an out-of-date check determines that it's needed to be executed, for example). Objects of this class are returned by an ActionFactory class that provides a __call__() method as a convenient way for wrapping up the functions.

Classes [hide private]
  _null
  ActionBase
Base class for all types of action objects that can be held by other objects (Builders, Executors, etc.) This provides the common methods for manipulating and combining those actions.
  _ActionAction
Base class for actions that create output objects.
  CommandAction
Class for command-execution actions.
  CommandGeneratorAction
Class for command-generator actions.
  LazyAction
  FunctionAction
Class for Python function actions.
  ListAction
Class for lists of other actions.
  ActionCaller
A class for delaying calling an Action function with specific (positional and keyword) arguments until the Action is actually executed.
  ActionFactory
A factory class that will wrap up an arbitrary function as an SCons-executable Action object.
Functions [hide private]
 
rfile(n) source code
 
default_exitstatfunc(s) source code
 
remove_set_lineno_codes(x) source code
 
_callable_contents(obj)
Return the signature contents of a callable Python object.
source code
 
_object_contents(obj)
Return the signature contents of any Python object.
source code
 
_code_contents(code)
Return the signature contents of a code object.
source code
 
_function_contents(func)
Return the signature contents of a function.
source code
 
_actionAppend(act1, act2) source code
 
_do_create_keywords(args, kw)
This converts any arguments after the action argument into their equivalent keywords and adds them to the kw argument.
source code
 
_do_create_action(act, kw)
This is the actual "implementation" for the Action factory method, below. This handles the fact that passing lists to Action() itself has different semantics than passing lists as elements of lists.
source code
 
_do_create_list_action(act, kw)
A factory for list actions. Convert the input list into Actions and then wrap them in a ListAction.
source code
 
Action(act, *args, **kw)
A factory for action objects.
source code
 
_string_from_cmd_list(cmd_list)
Takes a list of command line arguments and returns a pretty representation for printing.
source code
 
get_default_ENV(env) source code
 
_subproc(scons_env, cmd, error='ignore', **kw)
Do common setup for a subprocess.Popen() call
source code
Variables [hide private]
  __revision__ = 'src/engine/SCons/Action.py rel_2.4.1:3453:73fe...
  print_actions = 1
  execute_actions = 1
  print_actions_presub = 0
  SET_LINENO = dis.SET_LINENO
  HAVE_ARGUMENT = dis.HAVE_ARGUMENT
  strip_quotes = re.compile(r'^[\'"](.*)[\'"]$')
  default_ENV = None
hash(x)
  __package__ = 'SCons'
Function Details [hide private]

_object_contents(obj)

source code 

Return the signature contents of any Python object.

We have to handle the case where object contains a code object since it can be pickled directly.

_code_contents(code)

source code 

Return the signature contents of a code object.

By providing direct access to the code object of the function, Python makes this extremely easy. Hooray!

Unfortunately, older versions of Python include line number indications in the compiled byte code. Boo! So we remove the line number byte codes to prevent recompilations from moving a Python function.

_do_create_action(act, kw)

source code 

This is the actual "implementation" for the Action factory method, below. This handles the fact that passing lists to Action() itself has different semantics than passing lists as elements of lists.

The former will create a ListAction, the latter will create a CommandAction by converting the inner list elements to strings.


Variables Details [hide private]

__revision__

Value:
'src/engine/SCons/Action.py rel_2.4.1:3453:73fefd3ea0b0 2015/11/09 03:\
25:05 bdbaddog'