summaryrefslogtreecommitdiff
path: root/engine/SCons/Environment.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2017-09-28 10:21:25 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2017-09-28 10:21:25 +0200
commit4f3ca5f60f4de1aca6e3b9d7f30467ba0f724c27 (patch)
treed47e14dc637e15861e9ba7d65e5f4aae5d79df6d /engine/SCons/Environment.py
parent3765e33b76c51c81dd7bbbfacab0c4e76a1713cb (diff)
parent7c651e273c4db37f4babd91aaecf26800c50dd79 (diff)
Updated version 3.0.0 from 'upstream/3.0.0'
with Debian dir f5f84710e04b09c178d76c96bcda7517932c0c17
Diffstat (limited to 'engine/SCons/Environment.py')
-rw-r--r--engine/SCons/Environment.py80
1 files changed, 47 insertions, 33 deletions
diff --git a/engine/SCons/Environment.py b/engine/SCons/Environment.py
index 78fe327..64210aa 100644
--- a/engine/SCons/Environment.py
+++ b/engine/SCons/Environment.py
@@ -10,7 +10,7 @@ Environment
"""
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -31,7 +31,7 @@ Environment
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Environment.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/engine/SCons/Environment.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
import copy
@@ -128,7 +128,7 @@ future_reserved_construction_var_names = [
def copy_non_reserved_keywords(dict):
result = semi_deepcopy(dict)
- for k in result.keys():
+ for k in list(result.keys()):
if k in reserved_construction_var_names:
msg = "Ignoring attempt to set reserved variable `$%s'"
SCons.Warnings.warn(SCons.Warnings.ReservedVariableWarning, msg % k)
@@ -147,7 +147,7 @@ def _set_future_reserved(env, key, value):
def _set_BUILDERS(env, key, value):
try:
bd = env._dict[key]
- for k in bd.keys():
+ for k in list(bd.keys()):
del bd[k]
except KeyError:
bd = BuilderDict(kwbd, env)
@@ -167,7 +167,7 @@ def _set_SCANNERS(env, key, value):
def _delete_duplicates(l, keep_last):
"""Delete duplicates from a sequence, keeping the first or last."""
- seen={}
+ seen=set()
result=[]
if keep_last: # reverse in & out, then keep first
l.reverse()
@@ -175,7 +175,7 @@ def _delete_duplicates(l, keep_last):
try:
if i not in seen:
result.append(i)
- seen[i]=1
+ seen.add(i)
except TypeError:
# probably unhashable. Just keep it.
result.append(i)
@@ -342,7 +342,7 @@ def is_valid_construction_var(varstr):
class SubstitutionEnvironment(object):
"""Base class for different flavors of construction environments.
- This class contains a minimal set of methods that handle contruction
+ This class contains a minimal set of methods that handle construction
variable expansion and conversion of strings to Nodes, which may or
may not be actually useful as a stand-alone class. Which methods
ended up in this class is pretty arbitrary right now. They're
@@ -396,8 +396,8 @@ class SubstitutionEnvironment(object):
# gotten better than dict.has_key() in Python 2.5.)
self._special_set_keys = list(self._special_set.keys())
- def __cmp__(self, other):
- return cmp(self._dict, other._dict)
+ def __eq__(self, other):
+ return self._dict == other._dict
def __delitem__(self, key):
special = self._special_del.get(key)
@@ -589,7 +589,7 @@ class SubstitutionEnvironment(object):
out,err = p.communicate()
status = p.wait()
if err:
- sys.stderr.write(unicode(err))
+ sys.stderr.write(u"" + err)
if status:
raise OSError("'%s' exited %d" % (command, status))
return out
@@ -1185,7 +1185,7 @@ class Base(SubstitutionEnvironment):
if SCons.Util.is_List(val):
if key == 'CPPDEFINES':
tmp = []
- for (k, v) in orig.iteritems():
+ for (k, v) in orig.items():
if v is not None:
tmp.append((k, v))
else:
@@ -1273,7 +1273,7 @@ class Base(SubstitutionEnvironment):
# Construct a list of (key, value) tuples.
if SCons.Util.is_Dict(dk):
tmp = []
- for (k, v) in dk.iteritems():
+ for (k, v) in dk.items():
if v is not None:
tmp.append((k, v))
else:
@@ -1321,7 +1321,7 @@ class Base(SubstitutionEnvironment):
# Construct a list of (key, value) tuples.
if SCons.Util.is_Dict(val):
tmp = []
- for (k, v) in val.iteritems():
+ for (k, v) in val.items():
if v is not None:
tmp.append((k, v))
else:
@@ -1330,7 +1330,7 @@ class Base(SubstitutionEnvironment):
elif SCons.Util.is_String(val):
val = [(val,)]
if delete_existing:
- dk = filter(lambda x, val=val: x not in val, dk)
+ dk = list(filter(lambda x, val=val: x not in val, dk))
self._dict[key] = dk + val
else:
dk = [x for x in dk if x not in val]
@@ -1339,7 +1339,7 @@ class Base(SubstitutionEnvironment):
# By elimination, val is not a list. Since dk is a
# list, wrap val in a list first.
if delete_existing:
- dk = filter(lambda x, val=val: x not in val, dk)
+ dk = list(filter(lambda x, val=val: x not in val, dk))
self._dict[key] = dk + [val]
else:
if not val in dk:
@@ -1350,7 +1350,7 @@ class Base(SubstitutionEnvironment):
dk = [dk]
elif SCons.Util.is_Dict(dk):
tmp = []
- for (k, v) in dk.iteritems():
+ for (k, v) in dk.items():
if v is not None:
tmp.append((k, v))
else:
@@ -1363,7 +1363,7 @@ class Base(SubstitutionEnvironment):
val = [val]
elif SCons.Util.is_Dict(val):
tmp = []
- for i,j in val.iteritems():
+ for i,j in val.items():
if j is not None:
tmp.append((i,j))
else:
@@ -1771,7 +1771,7 @@ class Base(SubstitutionEnvironment):
return os.path.join(dir, new_prefix+name+new_suffix)
def SetDefault(self, **kw):
- for k in kw.keys():
+ for k in list(kw.keys()):
if k in self._dict:
del kw[k]
self.Replace(**kw)
@@ -1833,7 +1833,7 @@ class Base(SubstitutionEnvironment):
uniq = {}
for executor in [n.get_executor() for n in nodes]:
uniq[executor] = 1
- for executor in uniq.keys():
+ for executor in list(uniq.keys()):
executor.add_pre_action(action)
return nodes
@@ -1843,7 +1843,7 @@ class Base(SubstitutionEnvironment):
uniq = {}
for executor in [n.get_executor() for n in nodes]:
uniq[executor] = 1
- for executor in uniq.keys():
+ for executor in list(uniq.keys()):
executor.add_post_action(action)
return nodes
@@ -1983,6 +1983,15 @@ class Base(SubstitutionEnvironment):
return result
return self.fs.Dir(s, *args, **kw)
+ def PyPackageDir(self, modulename):
+ s = self.subst(modulename)
+ if SCons.Util.is_Sequence(s):
+ result=[]
+ for e in s:
+ result.append(self.fs.PyPackageDir(e))
+ return result
+ return self.fs.PyPackageDir(s)
+
def NoClean(self, *targets):
"""Tags a target so that it will not be cleaned by -c"""
tlist = []
@@ -2180,13 +2189,16 @@ class Base(SubstitutionEnvironment):
"""This function converts a string or list into a list of strings
or Nodes. This makes things easier for users by allowing files to
be specified as a white-space separated list to be split.
+
The input rules are:
- A single string containing names separated by spaces. These will be
split apart at the spaces.
- A single Node instance
- A list containing either strings or Node instances. Any strings
in the list are not split at spaces.
+
In all cases, the function returns a list of Nodes and strings."""
+
if SCons.Util.is_List(arg):
return list(map(self.subst, arg))
elif SCons.Util.is_String(arg):
@@ -2246,7 +2258,7 @@ class Base(SubstitutionEnvironment):
while (node != node.srcnode()):
node = node.srcnode()
return node
- sources = map( final_source, sources );
+ sources = list(map( final_source, sources ));
# remove duplicates
return list(set(sources))
@@ -2368,19 +2380,21 @@ class OverrideEnvironment(Base):
Environment = Base
-# An entry point for returning a proxy subclass instance that overrides
-# the subst*() methods so they don't actually perform construction
-# variable substitution. This is specifically intended to be the shim
-# layer in between global function calls (which don't want construction
-# variable substitution) and the DefaultEnvironment() (which would
-# substitute variables if left to its own devices)."""
-#
-# We have to wrap this in a function that allows us to delay definition of
-# the class until it's necessary, so that when it subclasses Environment
-# it will pick up whatever Environment subclass the wrapper interface
-# might have assigned to SCons.Environment.Environment.
def NoSubstitutionProxy(subject):
+ """
+ An entry point for returning a proxy subclass instance that overrides
+ the subst*() methods so they don't actually perform construction
+ variable substitution. This is specifically intended to be the shim
+ layer in between global function calls (which don't want construction
+ variable substitution) and the DefaultEnvironment() (which would
+ substitute variables if left to its own devices).
+
+ We have to wrap this in a function that allows us to delay definition of
+ the class until it's necessary, so that when it subclasses Environment
+ it will pick up whatever Environment subclass the wrapper interface
+ might have assigned to SCons.Environment.Environment.
+ """
class _NoSubstitutionProxy(Environment):
def __init__(self, subject):
self.__dict__['__subject'] = subject
@@ -2389,7 +2403,7 @@ def NoSubstitutionProxy(subject):
def __setattr__(self, name, value):
return setattr(self.__dict__['__subject'], name, value)
def executor_to_lvars(self, kwdict):
- if kwdict.has_key('executor'):
+ if 'executor' in kwdict:
kwdict['lvars'] = kwdict['executor'].get_lvars()
del kwdict['executor']
else: