"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "engine/SCons/Action.py" between
scons-3.0.1.tar.gz and scons-3.0.2.tar.gz

About: SCons is a software construction tool (a Python script and a set of modules as a superior alternative to the classic "Make" build tool).

Action.py  (scons-3.0.1):Action.py  (scons-3.0.2)
skipping to change at line 79 skipping to change at line 79
There is a related independent ActionCaller class that looks like a There is a related independent ActionCaller class that looks like a
regular Action, and which serves as a wrapper for arbitrary functions 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 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 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 be executed, for example). Objects of this class are returned by an
ActionFactory class that provides a __call__() method as a convenient ActionFactory class that provides a __call__() method as a convenient
way for wrapping up the functions. way for wrapping up the functions.
""" """
# Copyright (c) 2001 - 2017 The SCons Foundation # Copyright (c) 2001 - 2018 The SCons Foundation
# #
# Permission is hereby granted, free of charge, to any person obtaining # Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the # a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including # "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, # without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to # distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to # permit persons to whom the Software is furnished to do so, subject to
# the following conditions: # the following conditions:
# #
# The above copyright notice and this permission notice shall be included # The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software. # in all copies or substantial portions of the Software.
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
__revision__ = "src/engine/SCons/Action.py 74b2c53bc42290e911b334a6b44f187da698a 668 2017/11/14 13:16:53 bdbaddog" __revision__ = "src/engine/SCons/Action.py 425375072d7b582a2df0db815c8eaeaa48946 8ab 2019-01-01 18:32:02 bdbaddog"
import os import os
import pickle import pickle
import re import re
import sys import sys
import subprocess import subprocess
import itertools import itertools
import inspect import inspect
from collections import OrderedDict
import SCons.Debug import SCons.Debug
from SCons.Debug import logInstanceCreation from SCons.Debug import logInstanceCreation
import SCons.Errors import SCons.Errors
import SCons.Util import SCons.Util
import SCons.Subst import SCons.Subst
# we use these a lot, so try to optimize them # we use these a lot, so try to optimize them
is_String = SCons.Util.is_String from SCons.Util import is_String, is_List
is_List = SCons.Util.is_List
class _null(object): class _null(object):
pass pass
print_actions = 1 print_actions = 1
execute_actions = 1 execute_actions = 1
print_actions_presub = 0 print_actions_presub = 0
# Use pickle protocol 1 when pickling functions for signature # Use pickle protocol 1 when pickling functions for signature
# otherwise python3 and python2 will yield different pickles # otherwise python3 and python2 will yield different pickles
skipping to change at line 255 skipping to change at line 255
contents.extend(b", ") contents.extend(b", ")
contents.extend(bytearray(str(len(code.co_cellvars)), 'utf-8')) contents.extend(bytearray(str(len(code.co_cellvars)), 'utf-8'))
contents.extend(b", ") contents.extend(b", ")
contents.extend(bytearray(str(len(code.co_freevars)), 'utf-8')) contents.extend(bytearray(str(len(code.co_freevars)), 'utf-8'))
# The code contents depends on any constants accessed by the # The code contents depends on any constants accessed by the
# function. Note that we have to call _object_contents on each # function. Note that we have to call _object_contents on each
# constants because the code object of nested functions can # constants because the code object of nested functions can
# show-up among the constants. # show-up among the constants.
z = [_object_contents(cc) for cc in code.co_consts if cc != docstring]
z = [_object_contents(cc) for cc in code.co_consts[1:]]
contents.extend(b',(') contents.extend(b',(')
contents.extend(bytearray(',', 'utf-8').join(z)) contents.extend(bytearray(',', 'utf-8').join(z))
contents.extend(b')') contents.extend(b')')
# The code contents depends on the variable names used to # The code contents depends on the variable names used to
# accessed global variable, as changing the variable name changes # accessed global variable, as changing the variable name changes
# the variable actually accessed and therefore changes the # the variable actually accessed and therefore changes the
# function result. # function result.
z= [bytearray(_object_contents(cc)) for cc in code.co_names] z= [bytearray(_object_contents(cc)) for cc in code.co_names]
contents.extend(b',(') contents.extend(b',(')
skipping to change at line 787 skipping to change at line 786
# It's either a string or something else. If it's a string, # It's either a string or something else. If it's a string,
# we still want to call str() because it might be a *Unicode* # we still want to call str() because it might be a *Unicode*
# string, which makes subprocess.Popen() gag. If it isn't a # string, which makes subprocess.Popen() gag. If it isn't a
# string or a list, then we just coerce it to a string, which # string or a list, then we just coerce it to a string, which
# is the proper way to handle Dir and File instances and will # is the proper way to handle Dir and File instances and will
# produce something reasonable for just about everything else: # produce something reasonable for just about everything else:
new_env[key] = str(value) new_env[key] = str(value)
kw['env'] = new_env kw['env'] = new_env
try: try:
return subprocess.Popen(cmd, **kw) pobj = subprocess.Popen(cmd, **kw)
except EnvironmentError as e: except EnvironmentError as e:
if error == 'raise': raise if error == 'raise': raise
# return a dummy Popen instance that only returns error # return a dummy Popen instance that only returns error
class dummyPopen(object): class dummyPopen(object):
def __init__(self, e): self.exception = e def __init__(self, e): self.exception = e
def communicate(self, input=None): return ('', '') def communicate(self, input=None): return ('', '')
def wait(self): return -self.exception.errno def wait(self): return -self.exception.errno
stdin = None stdin = None
class f(object): class f(object):
def read(self): return '' def read(self): return ''
def readline(self): return '' def readline(self): return ''
def __iter__(self): return iter(()) def __iter__(self): return iter(())
stdout = stderr = f() stdout = stderr = f()
return dummyPopen(e) pobj = dummyPopen(e)
finally:
# clean up open file handles stored in parent's kw
for k, v in kw.items():
if hasattr(v, 'close'):
v.close()
return pobj
class CommandAction(_ActionAction): class CommandAction(_ActionAction):
"""Class for command-execution actions.""" """Class for command-execution actions."""
def __init__(self, cmd, **kw): def __init__(self, cmd, **kw):
# Cmd can actually be a list or a single item; if it's a # Cmd can actually be a list or a single item; if it's a
# single item it should be the command string to execute; if a # single item it should be the command string to execute; if a
# list then it should be the words of the command string to # list then it should be the words of the command string to
# execute. Only a single command should be executed by this # execute. Only a single command should be executed by this
# object; lists of commands should be handled by embedding # object; lists of commands should be handled by embedding
# these objects in a ListAction object (which the Action() # these objects in a ListAction object (which the Action()
# factory above does). cmd will be passed to # factory above does). cmd will be passed to
# Environment.subst_list() for substituting environment # Environment.subst_list() for substituting environment
# variables. # variables.
if SCons.Debug.track_instances: logInstanceCreation(self, 'Action.Comman dAction') if SCons.Debug.track_instances: logInstanceCreation(self, 'Action.Comman dAction')
_ActionAction.__init__(self, **kw) _ActionAction.__init__(self, **kw)
if is_List(cmd): if is_List(cmd):
if [c for c in cmd if is_List(c)]: if [c for c in cmd if is_List(c)]:
raise TypeError("CommandAction should be given only " \ raise TypeError("CommandAction should be given only "
"a single command") "a single command")
self.cmd_list = cmd self.cmd_list = cmd
def __str__(self): def __str__(self):
if is_List(self.cmd_list): if is_List(self.cmd_list):
return ' '.join(map(str, self.cmd_list)) return ' '.join(map(str, self.cmd_list))
return str(self.cmd_list) return str(self.cmd_list)
def process(self, target, source, env, executor=None): def process(self, target, source, env, executor=None):
if executor: if executor:
result = env.subst_list(self.cmd_list, 0, executor=executor) result = env.subst_list(self.cmd_list, 0, executor=executor)
skipping to change at line 1269 skipping to change at line 1274
return stat return stat
return 0 return 0
def get_implicit_deps(self, target, source, env): def get_implicit_deps(self, target, source, env):
result = [] result = []
for act in self.list: for act in self.list:
result.extend(act.get_implicit_deps(target, source, env)) result.extend(act.get_implicit_deps(target, source, env))
return result return result
def get_varlist(self, target, source, env, executor=None): def get_varlist(self, target, source, env, executor=None):
result = SCons.Util.OrderedDict() result = OrderedDict()
for act in self.list: for act in self.list:
for var in act.get_varlist(target, source, env, executor): for var in act.get_varlist(target, source, env, executor):
result[var] = True result[var] = True
return list(result.keys()) return list(result.keys())
class ActionCaller(object): class ActionCaller(object):
"""A class for delaying calling an Action function with specific """A class for delaying calling an Action function with specific
(positional and keyword) arguments until the Action is actually (positional and keyword) arguments until the Action is actually
executed. executed.
 End of changes. 9 change blocks. 
11 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)