summaryrefslogtreecommitdiff
path: root/src/engine/SCons/Subst.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2017-09-28 12:18:58 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2017-09-28 12:18:58 +0200
commitbaee03c569c91b745a1e025660b19a718db16e7d (patch)
tree1aaa25835bd24c5c95649cd8ab34d97bafded599 /src/engine/SCons/Subst.py
parent4c7fed99e5554ba71d62987c0ec5f1302011b122 (diff)
New upstream version 3.0.0upstream/3.0.0
Diffstat (limited to 'src/engine/SCons/Subst.py')
-rw-r--r--src/engine/SCons/Subst.py39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/engine/SCons/Subst.py b/src/engine/SCons/Subst.py
index 28445a3..90c12a0 100644
--- a/src/engine/SCons/Subst.py
+++ b/src/engine/SCons/Subst.py
@@ -5,7 +5,7 @@ SCons string substitution.
"""
#
-# 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
@@ -26,7 +26,7 @@ SCons string substitution.
# 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/Subst.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/engine/SCons/Subst.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
import collections
import re
@@ -338,24 +338,28 @@ SUBST_RAW = 1
SUBST_SIG = 2
_rm = re.compile(r'\$[()]')
-_remove = re.compile(r'\$\([^\$]*(\$[^\)][^\$]*)*\$\)')
+_rm_split = re.compile(r'(\$[()])')
# Indexed by the SUBST_* constants above.
-_regex_remove = [ _rm, None, _remove ]
+_regex_remove = [ _rm, None, _rm_split ]
def _rm_list(list):
return [l for l in list if not l in ('$(', '$)')]
def _remove_list(list):
result = []
- do_append = result.append
+ depth = 0
for l in list:
if l == '$(':
- do_append = lambda x: None
+ depth += 1
elif l == '$)':
- do_append = result.append
- else:
- do_append(l)
+ depth -= 1
+ if depth < 0:
+ break
+ elif depth == 0:
+ result.append(l)
+ if depth != 0:
+ return None
return result
# Indexed by the SUBST_* constants above.
@@ -438,14 +442,14 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, gvars={
return s
else:
key = s[1:]
- if key[0] == '{' or key.find('.') >= 0:
+ if key[0] == '{' or '.' in key:
if key[0] == '{':
key = key[1:-1]
try:
s = eval(key, self.gvars, lvars)
except KeyboardInterrupt:
raise
- except Exception, e:
+ except Exception as e:
if e.__class__ in AllowableExceptions:
return ''
raise_exception(e, lvars['TARGETS'], s)
@@ -562,12 +566,19 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, gvars={
except KeyError:
pass
+ res = result
if is_String(result):
# Remove $(-$) pairs and any stuff in between,
# if that's appropriate.
remove = _regex_remove[mode]
if remove:
- result = remove.sub('', result)
+ if mode == SUBST_SIG:
+ result = _list_remove[mode](remove.split(result))
+ if result is None:
+ raise SCons.Errors.UserError("Unbalanced $(/$) in: " + res)
+ result = ' '.join(result)
+ else:
+ result = remove.sub('', result)
if mode != SUBST_RAW:
# Compress strings of white space characters into
# a single space.
@@ -576,6 +587,8 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, gvars={
remove = _list_remove[mode]
if remove:
result = remove(result)
+ if result is None:
+ raise SCons.Errors.UserError("Unbalanced $(/$) in: " + str(res))
return result
@@ -652,7 +665,7 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, gv
s = eval(key, self.gvars, lvars)
except KeyboardInterrupt:
raise
- except Exception, e:
+ except Exception as e:
if e.__class__ in AllowableExceptions:
return
raise_exception(e, lvars['TARGETS'], s)