summaryrefslogtreecommitdiffstats
path: root/SCons/Environment.py
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2020-12-20 23:37:56 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2020-12-20 23:37:56 (GMT)
commit78292be9cbb471101e6ed4ec5f6da0161730c656 (patch)
treee0ef841cc870866c5af965411b9222c455d8d3e7 /SCons/Environment.py
parent2b583646718acda52481b71f15c9a6723fb3eb81 (diff)
parent97dbf8d22b518a8f67cf670f8e3449990f3f5813 (diff)
downloadSCons-78292be9cbb471101e6ed4ec5f6da0161730c656.zip
SCons-78292be9cbb471101e6ed4ec5f6da0161730c656.tar.gz
SCons-78292be9cbb471101e6ed4ec5f6da0161730c656.tar.bz2
Merge remote-tracking branch 'upstream/master' into reimplement_soname_soversion
Diffstat (limited to 'SCons/Environment.py')
-rw-r--r--SCons/Environment.py359
1 files changed, 183 insertions, 176 deletions
diff --git a/SCons/Environment.py b/SCons/Environment.py
index 13eaf3c..55a5003 100644
--- a/SCons/Environment.py
+++ b/SCons/Environment.py
@@ -1,16 +1,6 @@
-"""SCons.Environment
-
-Base class for construction Environments. These are
-the primary objects used to communicate dependency and
-construction information to the build engine.
-
-Keyword arguments supplied when the construction Environment
-is created are construction variables used to initialize the
-Environment
-"""
-
+# MIT License
#
-# __COPYRIGHT__
+# Copyright 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,8 +21,14 @@ 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__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+"""Base class for construction Environments.
+
+These are the primary objects used to communicate dependency and
+construction information to the build engine.
+Keyword arguments supplied when the construction Environment is created
+are construction variables used to initialize the Environment.
+"""
import copy
import os
@@ -57,8 +53,27 @@ import SCons.SConf
import SCons.SConsign
import SCons.Subst
import SCons.Tool
-import SCons.Util
import SCons.Warnings
+from SCons.Util import (
+ AppendPath,
+ CLVar,
+ LogicalLines,
+ MethodWrapper,
+ PrependPath,
+ Split,
+ WhereIs,
+ flatten,
+ is_Dict,
+ is_List,
+ is_Sequence,
+ is_String,
+ is_Tuple,
+ md5,
+ semi_deepcopy,
+ semi_deepcopy_dict,
+ to_String_for_subst,
+ uniquer_hashables,
+)
class _Null:
pass
@@ -72,18 +87,17 @@ _warn_target_signatures_deprecated = True
CleanTargets = {}
CalculatorArgs = {}
-semi_deepcopy = SCons.Util.semi_deepcopy
-semi_deepcopy_dict = SCons.Util.semi_deepcopy_dict
-
def alias_builder(env, target, source):
pass
-AliasBuilder = SCons.Builder.Builder(action = alias_builder,
- target_factory = SCons.Node.Alias.default_ans.Alias,
- source_factory = SCons.Node.FS.Entry,
- multi = 1,
- is_explicit = None,
- name='AliasBuilder')
+AliasBuilder = SCons.Builder.Builder(
+ action=alias_builder,
+ target_factory=SCons.Node.Alias.default_ans.Alias,
+ source_factory=SCons.Node.FS.Entry,
+ multi=True,
+ is_explicit=None,
+ name='AliasBuilder',
+)
def apply_tools(env, tools, toolpath):
# Store the toolpath in the Environment.
@@ -94,7 +108,7 @@ def apply_tools(env, tools, toolpath):
return
# Filter out null tools from the list.
for tool in [_f for _f in tools if _f]:
- if SCons.Util.is_List(tool) or isinstance(tool, tuple):
+ if is_List(tool) or isinstance(tool, tuple):
toolname = tool[0]
toolargs = tool[1] # should be a dict of kw args
tool = env.Tool(toolname, **toolargs)
@@ -184,46 +198,15 @@ def _delete_duplicates(l, keep_last):
# Shannon at the following page (there called the "transplant" class):
#
# ASPN : Python Cookbook : Dynamically added methods to a class
-# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81732
+# https://code.activestate.com/recipes/81732/
#
# We had independently been using the idiom as BuilderWrapper, but
# factoring out the common parts into this base class, and making
# BuilderWrapper a subclass that overrides __call__() to enforce specific
# Builder calling conventions, simplified some of our higher-layer code.
-
-class MethodWrapper:
- """
- A generic Wrapper class that associates a method (which can
- actually be any callable) with an object. As part of creating this
- MethodWrapper object an attribute with the specified (by default,
- the name of the supplied method) is added to the underlying object.
- When that new "method" is called, our __call__() method adds the
- object as the first argument, simulating the Python behavior of
- supplying "self" on method calls.
-
- We hang on to the name by which the method was added to the underlying
- base class so that we can provide a method to "clone" ourselves onto
- a new underlying object being copied (without which we wouldn't need
- to save that info).
- """
- def __init__(self, object, method, name=None):
- if name is None:
- name = method.__name__
- self.object = object
- self.method = method
- self.name = name
- setattr(self.object, name, self)
-
- def __call__(self, *args, **kwargs):
- nargs = (self.object,) + args
- return self.method(*nargs, **kwargs)
-
- def clone(self, new_object):
- """
- Returns an object that re-binds the underlying "method" to
- the specified new object.
- """
- return self.__class__(new_object, self.method, self.name)
+#
+# Note: MethodWrapper moved to SCons.Util as it was needed there
+# and otherwise we had a circular import problem.
class BuilderWrapper(MethodWrapper):
"""
@@ -248,11 +231,11 @@ class BuilderWrapper(MethodWrapper):
if source is _null:
source = target
target = None
- if target is not None and not SCons.Util.is_List(target):
+ if target is not None and not is_List(target):
target = [target]
- if source is not None and not SCons.Util.is_List(source):
+ if source is not None and not is_List(source):
source = [source]
- return MethodWrapper.__call__(self, target, source, *args, **kw)
+ return super().__call__(target, source, *args, **kw)
def __repr__(self):
return '<BuilderWrapper %s>' % repr(self.name)
@@ -465,24 +448,24 @@ class SubstitutionEnvironment:
if not args:
return []
- args = SCons.Util.flatten(args)
+ args = flatten(args)
nodes = []
for v in args:
- if SCons.Util.is_String(v):
+ if is_String(v):
n = None
for l in lookup_list:
n = l(v)
if n is not None:
break
if n is not None:
- if SCons.Util.is_String(n):
+ if is_String(n):
# n = self.subst(n, raw=1, **kw)
kw['raw'] = 1
n = self.subst(n, **kw)
if node_factory:
n = node_factory(n)
- if SCons.Util.is_List(n):
+ if is_List(n):
nodes.extend(n)
else:
nodes.append(n)
@@ -490,7 +473,7 @@ class SubstitutionEnvironment:
# v = node_factory(self.subst(v, raw=1, **kw))
kw['raw'] = 1
v = node_factory(self.subst(v, **kw))
- if SCons.Util.is_List(v):
+ if is_List(v):
nodes.extend(v)
else:
nodes.append(v)
@@ -526,7 +509,7 @@ class SubstitutionEnvironment:
nkw = {}
for k, v in kw.items():
k = self.subst(k, raw, target, source)
- if SCons.Util.is_String(v):
+ if is_String(v):
v = self.subst(v, raw, target, source)
nkw[k] = v
return nkw
@@ -545,7 +528,7 @@ class SubstitutionEnvironment:
"""Substitute a path list, turning EntryProxies into Nodes
and leaving Nodes (and other objects) as-is."""
- if not SCons.Util.is_List(path):
+ if not is_List(path):
path = [path]
def s(obj):
@@ -558,23 +541,23 @@ class SubstitutionEnvironment:
try:
get = obj.get
except AttributeError:
- obj = SCons.Util.to_String_for_subst(obj)
+ obj = to_String_for_subst(obj)
else:
obj = get()
return obj
r = []
for p in path:
- if SCons.Util.is_String(p):
+ if is_String(p):
p = self.subst(p, target=target, source=source, conv=s)
- if SCons.Util.is_List(p):
+ if is_List(p):
if len(p) == 1:
p = p[0]
else:
# We have an object plus a string, or multiple
# objects that we need to smush together. No choice
# but to make them into a string.
- p = ''.join(map(SCons.Util.to_String_for_subst, p))
+ p = ''.join(map(to_String_for_subst, p))
else:
p = s(p)
r.append(p)
@@ -592,7 +575,7 @@ class SubstitutionEnvironment:
}
# if the command is a list, assume it's been quoted
# othewise force a shell
- if not SCons.Util.is_List(command): kw['shell'] = True
+ if not is_List(command): kw['shell'] = True
# run constructed command
p = SCons.Action._subproc(self, command, **kw)
out,err = p.communicate()
@@ -642,32 +625,38 @@ class SubstitutionEnvironment:
else:
overrides[key] = SCons.Subst.scons_subst_once(value, self, key)
env = OverrideEnvironment(self, overrides)
- if merges: env.MergeFlags(merges)
+ if merges:
+ env.MergeFlags(merges)
return env
def ParseFlags(self, *flags):
- """
- Parse the set of flags and return a dict with the flags placed
- in the appropriate entry. The flags are treated as a typical
- set of command-line flags for a GNU-like toolchain and used to
- populate the entries in the dict immediately below. If one of
- the flag strings begins with a bang (exclamation mark), it is
- assumed to be a command and the rest of the string is executed;
+ """Return a dict of parsed flags.
+
+ Parse ``flags`` and return a dict with the flags distributed into
+ the appropriate construction variable names. The flags are treated
+ as a typical set of command-line flags for a GNU-like toolchain,
+ such as might have been generated by one of the \*-config scripts,
+ and used to populate the entries based on knowledge embedded in
+ this method - the choices are not expected to be portable to other
+ toolchains.
+
+ If one of the ``flags`` strings begins with a bang (exclamation mark),
+ it is assumed to be a command and the rest of the string is executed;
the result of that evaluation is then added to the dict.
"""
dict = {
- 'ASFLAGS' : SCons.Util.CLVar(''),
- 'CFLAGS' : SCons.Util.CLVar(''),
- 'CCFLAGS' : SCons.Util.CLVar(''),
- 'CXXFLAGS' : SCons.Util.CLVar(''),
+ 'ASFLAGS' : CLVar(''),
+ 'CFLAGS' : CLVar(''),
+ 'CCFLAGS' : CLVar(''),
+ 'CXXFLAGS' : CLVar(''),
'CPPDEFINES' : [],
- 'CPPFLAGS' : SCons.Util.CLVar(''),
+ 'CPPFLAGS' : CLVar(''),
'CPPPATH' : [],
- 'FRAMEWORKPATH' : SCons.Util.CLVar(''),
- 'FRAMEWORKS' : SCons.Util.CLVar(''),
+ 'FRAMEWORKPATH' : CLVar(''),
+ 'FRAMEWORKS' : CLVar(''),
'LIBPATH' : [],
'LIBS' : [],
- 'LINKFLAGS' : SCons.Util.CLVar(''),
+ 'LINKFLAGS' : CLVar(''),
'RPATH' : [],
}
@@ -676,7 +665,7 @@ class SubstitutionEnvironment:
if not arg:
return
- if not SCons.Util.is_String(arg):
+ if not is_String(arg):
for t in arg: do_parse(t)
return
@@ -741,6 +730,9 @@ class SubstitutionEnvironment:
t = ('-arch', arg)
dict['CCFLAGS'].append(t)
dict['LINKFLAGS'].append(t)
+ elif append_next_arg_to == '--param':
+ t = ('--param', arg)
+ dict['CCFLAGS'].append(t)
else:
dict[append_next_arg_to].append(arg)
append_next_arg_to = None
@@ -792,11 +784,13 @@ class SubstitutionEnvironment:
dict['FRAMEWORKPATH'].append(arg[2:])
else:
append_next_arg_to = 'FRAMEWORKPATH'
- elif arg in ['-mno-cygwin',
- '-pthread',
- '-openmp',
- '-fmerge-all-constants',
- '-fopenmp']:
+ elif arg in [
+ '-mno-cygwin',
+ '-pthread',
+ '-openmp',
+ '-fmerge-all-constants',
+ '-fopenmp',
+ ]:
dict['CCFLAGS'].append(arg)
dict['LINKFLAGS'].append(arg)
elif arg == '-mwindows':
@@ -810,7 +804,16 @@ class SubstitutionEnvironment:
elif arg[0] == '+':
dict['CCFLAGS'].append(arg)
dict['LINKFLAGS'].append(arg)
- elif arg in ['-include', '-imacros', '-isysroot', '-isystem', '-iquote', '-idirafter', '-arch']:
+ elif arg in [
+ '-include',
+ '-imacros',
+ '-isysroot',
+ '-isystem',
+ '-iquote',
+ '-idirafter',
+ '-arch',
+ '--param',
+ ]:
append_next_arg_to = arg
else:
dict['CCFLAGS'].append(arg)
@@ -819,24 +822,30 @@ class SubstitutionEnvironment:
do_parse(arg)
return dict
- def MergeFlags(self, args, unique=1, dict=None):
- """
- Merge the dict in args into the construction variables of this
- env, or the passed-in dict. If args is not a dict, it is
- converted into a dict using ParseFlags. If unique is not set,
- the flags are appended rather than merged.
- """
+ def MergeFlags(self, args, unique=True):
+ """Merge flags into construction variables.
+
+ Merges the flags from ``args`` into this construction environent.
+ If ``args`` is not a dict, it is first converted to a dictionary with
+ flags distributed into appropriate construction variables.
+ See :meth:`ParseFlags`.
+
+ Args:
+ args: flags to merge
+ unique: merge flags rather than appending (default: True)
- if dict is None:
- dict = self
- if not SCons.Util.is_Dict(args):
+ """
+ if not is_Dict(args):
args = self.ParseFlags(args)
+
if not unique:
self.Append(**args)
- return self
+ return
+
for key, value in args.items():
if not value:
continue
+ value = Split(value)
try:
orig = self[key]
except KeyError:
@@ -873,7 +882,6 @@ class SubstitutionEnvironment:
if v not in t:
t.insert(0, v)
self[key] = t
- return self
def default_decide_source(dependency, target, prev_ni, repo_node=None):
@@ -961,7 +969,7 @@ class Base(SubstitutionEnvironment):
platform = self._dict.get('PLATFORM', None)
if platform is None:
platform = SCons.Platform.Platform()
- if SCons.Util.is_String(platform):
+ if is_String(platform):
platform = SCons.Platform.Platform(platform)
self._dict['PLATFORM'] = str(platform)
platform(self)
@@ -1012,7 +1020,8 @@ class Base(SubstitutionEnvironment):
self._dict[key] = val
# Finally, apply any flags to be merged in
- if parse_flags: self.MergeFlags(parse_flags)
+ if parse_flags:
+ self.MergeFlags(parse_flags)
#######################################################################
# Utility methods that are primarily for internal use by SCons.
@@ -1089,7 +1098,7 @@ class Base(SubstitutionEnvironment):
# claim they can scan the same suffix, earlier scanners
# in the list will overwrite later scanners, so that
# the result looks like a "first match" to the user.
- if not SCons.Util.is_List(scanners):
+ if not is_List(scanners):
scanners = [scanners]
else:
scanners = scanners[:] # copy so reverse() doesn't mod original
@@ -1164,9 +1173,7 @@ class Base(SubstitutionEnvironment):
#######################################################################
def Append(self, **kw):
- """Append values to existing construction variables
- in an Environment.
- """
+ """Append values to existing construction variables in an Environment."""
kw = copy_non_reserved_keywords(kw)
for key, val in kw.items():
# It would be easier on the eyes to write this using
@@ -1174,13 +1181,13 @@ class Base(SubstitutionEnvironment):
# but Python 1.5.2 apparently doesn't let you use "continue"
# within try:-except: blocks, so we have to nest our code.
try:
- if key == 'CPPDEFINES' and SCons.Util.is_String(self._dict[key]):
+ if key == 'CPPDEFINES' and is_String(self._dict[key]):
self._dict[key] = [self._dict[key]]
orig = self._dict[key]
except KeyError:
# No existing variable in the environment, so just set
# it to the new value.
- if key == 'CPPDEFINES' and SCons.Util.is_String(val):
+ if key == 'CPPDEFINES' and is_String(val):
self._dict[key] = [val]
else:
self._dict[key] = val
@@ -1219,7 +1226,7 @@ class Base(SubstitutionEnvironment):
else:
# The original looks like a dictionary, so update it
# based on what we think the value looks like.
- if SCons.Util.is_List(val):
+ if is_List(val):
if key == 'CPPDEFINES':
tmp = []
for (k, v) in orig.items():
@@ -1237,7 +1244,7 @@ class Base(SubstitutionEnvironment):
try:
update_dict(val)
except (AttributeError, TypeError, ValueError):
- if SCons.Util.is_Dict(val):
+ if is_Dict(val):
for k, v in val.items():
orig[k] = v
else:
@@ -1247,7 +1254,7 @@ class Base(SubstitutionEnvironment):
# allow Dirs and strings beginning with # for top-relative
# Note this uses the current env's fs (in self).
def _canonicalize(self, path):
- if not SCons.Util.is_String(path): # typically a Dir
+ if not is_String(path): # typically a Dir
path = str(path)
if path and path[0] == '#':
path = str(self.fs.Dir(path))
@@ -1269,8 +1276,7 @@ class Base(SubstitutionEnvironment):
if envname in self._dict and name in self._dict[envname]:
orig = self._dict[envname][name]
- nv = SCons.Util.AppendPath(orig, newpath, sep, delete_existing,
- canonicalize=self._canonicalize)
+ nv = AppendPath(orig, newpath, sep, delete_existing, canonicalize=self._canonicalize)
if envname not in self._dict:
self._dict[envname] = {}
@@ -1285,30 +1291,30 @@ class Base(SubstitutionEnvironment):
"""
kw = copy_non_reserved_keywords(kw)
for key, val in kw.items():
- if SCons.Util.is_List(val):
+ if is_List(val):
val = _delete_duplicates(val, delete_existing)
if key not in self._dict or self._dict[key] in ('', None):
self._dict[key] = val
- elif SCons.Util.is_Dict(self._dict[key]) and \
- SCons.Util.is_Dict(val):
+ elif is_Dict(self._dict[key]) and \
+ is_Dict(val):
self._dict[key].update(val)
- elif SCons.Util.is_List(val):
+ elif is_List(val):
dk = self._dict[key]
if key == 'CPPDEFINES':
tmp = []
for i in val:
- if SCons.Util.is_List(i):
+ if is_List(i):
if len(i) >= 2:
tmp.append((i[0], i[1]))
else:
tmp.append((i[0],))
- elif SCons.Util.is_Tuple(i):
+ elif is_Tuple(i):
tmp.append(i)
else:
tmp.append((i,))
val = tmp
# Construct a list of (key, value) tuples.
- if SCons.Util.is_Dict(dk):
+ if is_Dict(dk):
tmp = []
for (k, v) in dk.items():
if v is not None:
@@ -1316,23 +1322,23 @@ class Base(SubstitutionEnvironment):
else:
tmp.append((k,))
dk = tmp
- elif SCons.Util.is_String(dk):
+ elif is_String(dk):
dk = [(dk,)]
else:
tmp = []
for i in dk:
- if SCons.Util.is_List(i):
+ if is_List(i):
if len(i) >= 2:
tmp.append((i[0], i[1]))
else:
tmp.append((i[0],))
- elif SCons.Util.is_Tuple(i):
+ elif is_Tuple(i):
tmp.append(i)
else:
tmp.append((i,))
dk = tmp
else:
- if not SCons.Util.is_List(dk):
+ if not is_List(dk):
dk = [dk]
if delete_existing:
dk = [x for x in dk if x not in val]
@@ -1341,22 +1347,22 @@ class Base(SubstitutionEnvironment):
self._dict[key] = dk + val
else:
dk = self._dict[key]
- if SCons.Util.is_List(dk):
+ if is_List(dk):
if key == 'CPPDEFINES':
tmp = []
for i in dk:
- if SCons.Util.is_List(i):
+ if is_List(i):
if len(i) >= 2:
tmp.append((i[0], i[1]))
else:
tmp.append((i[0],))
- elif SCons.Util.is_Tuple(i):
+ elif is_Tuple(i):
tmp.append(i)
else:
tmp.append((i,))
dk = tmp
# Construct a list of (key, value) tuples.
- if SCons.Util.is_Dict(val):
+ if is_Dict(val):
tmp = []
for (k, v) in val.items():
if v is not None:
@@ -1364,7 +1370,7 @@ class Base(SubstitutionEnvironment):
else:
tmp.append((k,))
val = tmp
- elif SCons.Util.is_String(val):
+ elif is_String(val):
val = [(val,)]
if delete_existing:
dk = list(filter(lambda x, val=val: x not in val, dk))
@@ -1383,9 +1389,9 @@ class Base(SubstitutionEnvironment):
self._dict[key] = dk + [val]
else:
if key == 'CPPDEFINES':
- if SCons.Util.is_String(dk):
+ if is_String(dk):
dk = [dk]
- elif SCons.Util.is_Dict(dk):
+ elif is_Dict(dk):
tmp = []
for (k, v) in dk.items():
if v is not None:
@@ -1393,12 +1399,12 @@ class Base(SubstitutionEnvironment):
else:
tmp.append((k,))
dk = tmp
- if SCons.Util.is_String(val):
+ if is_String(val):
if val in dk:
val = []
else:
val = [val]
- elif SCons.Util.is_Dict(val):
+ elif is_Dict(val):
tmp = []
for i,j in val.items():
if j is not None:
@@ -1453,7 +1459,8 @@ class Base(SubstitutionEnvironment):
clone.Replace(**new)
# Finally, apply any flags to be merged in
- if parse_flags: clone.MergeFlags(parse_flags)
+ if parse_flags:
+ clone.MergeFlags(parse_flags)
if SCons.Debug.track_instances: logInstanceCreation(self, 'Environment.EnvironmentClone')
return clone
@@ -1492,7 +1499,7 @@ class Base(SubstitutionEnvironment):
def Decider(self, function):
copy_function = self._copy2_from_cache
if function in ('MD5', 'content'):
- if not SCons.Util.md5:
+ if not md5:
raise UserError("MD5 signatures are not available in this version of Python.")
function = self._changed_content
elif function == 'MD5-timestamp':
@@ -1520,7 +1527,7 @@ class Base(SubstitutionEnvironment):
progs (str or list): one or more command names to check for
"""
- if not SCons.Util.is_List(progs):
+ if not is_List(progs):
progs = [progs]
for prog in progs:
path = self.WhereIs(prog)
@@ -1610,7 +1617,7 @@ class Base(SubstitutionEnvironment):
if name[:len(prefix)] == prefix and name[-len(suffix):] == suffix:
return path
- def ParseConfig(self, command, function=None, unique=1):
+ def ParseConfig(self, command, function=None, unique=True):
"""
Use the specified function to parse the output of the command
in order to modify the current environment. The 'command' can
@@ -1625,12 +1632,12 @@ class Base(SubstitutionEnvironment):
def parse_conf(env, cmd, unique=unique):
return env.MergeFlags(cmd, unique)
function = parse_conf
- if SCons.Util.is_List(command):
+ if is_List(command):
command = ' '.join(command)
command = self.subst(command)
return function(self, self.backtick(command))
- def ParseDepends(self, filename, must_exist=None, only_one=0):
+ def ParseDepends(self, filename, must_exist=None, only_one=False):
"""
Parse a mkdep-style file for explicit dependencies. This is
completely abusable, and should be unnecessary in the "normal"
@@ -1643,7 +1650,7 @@ class Base(SubstitutionEnvironment):
filename = self.subst(filename)
try:
with open(filename, 'r') as fp:
- lines = SCons.Util.LogicalLines(fp).readlines()
+ lines = LogicalLines(fp).readlines()
except IOError:
if must_exist:
raise
@@ -1725,14 +1732,14 @@ class Base(SubstitutionEnvironment):
else:
# The original looks like a dictionary, so update it
# based on what we think the value looks like.
- if SCons.Util.is_List(val):
+ if is_List(val):
for v in val:
orig[v] = None
else:
try:
update_dict(val)
except (AttributeError, TypeError, ValueError):
- if SCons.Util.is_Dict(val):
+ if is_Dict(val):
for k, v in val.items():
orig[k] = v
else:
@@ -1755,7 +1762,7 @@ class Base(SubstitutionEnvironment):
if envname in self._dict and name in self._dict[envname]:
orig = self._dict[envname][name]
- nv = SCons.Util.PrependPath(orig, newpath, sep, delete_existing,
+ nv = PrependPath(orig, newpath, sep, delete_existing,
canonicalize=self._canonicalize)
if envname not in self._dict:
@@ -1771,16 +1778,16 @@ class Base(SubstitutionEnvironment):
"""
kw = copy_non_reserved_keywords(kw)
for key, val in kw.items():
- if SCons.Util.is_List(val):
+ if is_List(val):
val = _delete_duplicates(val, not delete_existing)
if key not in self._dict or self._dict[key] in ('', None):
self._dict[key] = val
- elif SCons.Util.is_Dict(self._dict[key]) and \
- SCons.Util.is_Dict(val):
+ elif is_Dict(self._dict[key]) and \
+ is_Dict(val):
self._dict[key].update(val)
- elif SCons.Util.is_List(val):
+ elif is_List(val):
dk = self._dict[key]
- if not SCons.Util.is_List(dk):
+ if not is_List(dk):
dk = [dk]
if delete_existing:
dk = [x for x in dk if x not in val]
@@ -1789,7 +1796,7 @@ class Base(SubstitutionEnvironment):
self._dict[key] = val + dk
else:
dk = self._dict[key]
- if SCons.Util.is_List(dk):
+ if is_List(dk):
# By elimination, val is not a list. Since dk is a
# list, wrap val in a list first.
if delete_existing:
@@ -1854,7 +1861,7 @@ class Base(SubstitutionEnvironment):
return self.fs.Dir(self.subst(tp)).srcnode().get_abspath()
def Tool(self, tool, toolpath=None, **kw):
- if SCons.Util.is_String(tool):
+ if is_String(tool):
tool = self.subst(tool)
if toolpath is None:
toolpath = self.get('toolpath', [])
@@ -1870,17 +1877,17 @@ class Base(SubstitutionEnvironment):
path = self['ENV']['PATH']
except KeyError:
pass
- elif SCons.Util.is_String(path):
+ elif is_String(path):
path = self.subst(path)
if pathext is None:
try:
pathext = self['ENV']['PATHEXT']
except KeyError:
pass
- elif SCons.Util.is_String(pathext):
+ elif is_String(pathext):
pathext = self.subst(pathext)
- prog = SCons.Util.CLVar(self.subst(prog)) # support "program --with-args"
- path = SCons.Util.WhereIs(prog[0], path, pathext, reject)
+ prog = CLVar(self.subst(prog)) # support "program --with-args"
+ path = WhereIs(prog[0], path, pathext, reject)
if path: return path
return None
@@ -1894,7 +1901,7 @@ class Base(SubstitutionEnvironment):
def Action(self, *args, **kw):
def subst_string(a, self=self):
- if SCons.Util.is_String(a):
+ if is_String(a):
a = self.subst(a)
return a
nargs = list(map(subst_string, args))
@@ -1923,7 +1930,7 @@ class Base(SubstitutionEnvironment):
def Alias(self, target, source=[], action=None, **kw):
tlist = self.arg2nodes(target, self.ans.Alias)
- if not SCons.Util.is_List(source):
+ if not is_List(source):
source = [source]
source = [_f for _f in source if _f]
@@ -2071,7 +2078,7 @@ class Base(SubstitutionEnvironment):
"""
"""
s = self.subst(name)
- if SCons.Util.is_Sequence(s):
+ if is_Sequence(s):
result=[]
for e in s:
result.append(self.fs.Dir(e, *args, **kw))
@@ -2080,7 +2087,7 @@ class Base(SubstitutionEnvironment):
def PyPackageDir(self, modulename):
s = self.subst(modulename)
- if SCons.Util.is_Sequence(s):
+ if is_Sequence(s):
result=[]
for e in s:
result.append(self.fs.PyPackageDir(e))
@@ -2109,7 +2116,7 @@ class Base(SubstitutionEnvironment):
"""
"""
s = self.subst(name)
- if SCons.Util.is_Sequence(s):
+ if is_Sequence(s):
result=[]
for e in s:
result.append(self.fs.Entry(e, *args, **kw))
@@ -2137,7 +2144,7 @@ class Base(SubstitutionEnvironment):
"""
"""
s = self.subst(name)
- if SCons.Util.is_Sequence(s):
+ if is_Sequence(s):
result=[]
for e in s:
result.append(self.fs.File(e, *args, **kw))
@@ -2150,11 +2157,11 @@ class Base(SubstitutionEnvironment):
return SCons.Node.FS.find_file(file, tuple(nodes))
def Flatten(self, sequence):
- return SCons.Util.flatten(sequence)
+ return flatten(sequence)
def GetBuildPath(self, files):
result = list(map(str, self.arg2nodes(files, self.fs.Entry)))
- if SCons.Util.is_List(files):
+ if is_List(files):
return result
else:
return result[0]
@@ -2218,7 +2225,7 @@ class Base(SubstitutionEnvironment):
def Scanner(self, *args, **kw):
nargs = []
for arg in args:
- if SCons.Util.is_String(arg):
+ if is_String(arg):
arg = self.subst(arg)
nargs.append(arg)
nkw = self.subst_kw(kw)
@@ -2266,9 +2273,9 @@ class Base(SubstitutionEnvironment):
In all cases, the function returns a list of Nodes and strings."""
- if SCons.Util.is_List(arg):
+ if is_List(arg):
return list(map(self.subst, arg))
- elif SCons.Util.is_String(arg):
+ elif is_String(arg):
return self.subst(arg).split()
else:
return [self.subst(arg)]
@@ -2312,7 +2319,7 @@ class Base(SubstitutionEnvironment):
"""
from SCons.Tool import install
if install._UNIQUE_INSTALLED_FILES is None:
- install._UNIQUE_INSTALLED_FILES = SCons.Util.uniquer_hashables(install._INSTALLED_FILES)
+ install._UNIQUE_INSTALLED_FILES = uniquer_hashables(install._INSTALLED_FILES)
return install._UNIQUE_INSTALLED_FILES
@@ -2356,7 +2363,7 @@ class OverrideEnvironment(Base):
# Environment they are being constructed with and so will not
# have access to overrided values. So we rebuild them with the
# OverrideEnvironment so they have access to overrided values.
- if isinstance(attr, (MethodWrapper, BuilderWrapper)):
+ if isinstance(attr, MethodWrapper):
return attr.clone(self)
else:
return attr