diff options
author | William Deegan <bill@baddogconsulting.com> | 2017-10-01 01:13:07 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2017-10-01 01:13:07 (GMT) |
commit | f7a846e6c44b3ae20f8575c9823fc7cbe6d920d7 (patch) | |
tree | 4a8006806329a4ca1f1549c0c817f79b88e292ff | |
parent | e1bc907a9213468a27b67a715b46524009daf6fb (diff) | |
download | SCons-f7a846e6c44b3ae20f8575c9823fc7cbe6d920d7.zip SCons-f7a846e6c44b3ae20f8575c9823fc7cbe6d920d7.tar.gz SCons-f7a846e6c44b3ae20f8575c9823fc7cbe6d920d7.tar.bz2 |
add fix for mistaking $$( for $( and breaking subst. Reported by Noah Hoffman noah.hoffman at gmail.com in: https://pairlist4.pair.net/pipermail/scons-users/2017-September/006352.html
-rw-r--r-- | src/CHANGES.txt | 6 | ||||
-rw-r--r-- | src/engine/SCons/Subst.py | 17 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 0e742ec..3b717ff 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -15,6 +15,12 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fixed a regression in scons-3.0.0 where "from __future__ import print_function" was imposed on the scope where SConstruct is executed, breaking existing builds using PY 2.7. + From William Deegan: + - Fix broken subst logic where a string with "$$(abc)" was being treated as "$(abc) and the + logic for removing the signature escapes was then failing because there was no closing "$)". + This was introduced by a pull request to allow recursive variable evaluations to yield a string + such as "$( $( some stuff $) $)". + RELEASE 3.0.0 - Mon, 18 Sep 2017 08:32:04 -0700 NOTE: This is a major release. You should expect that some targets may rebuild when upgrading. diff --git a/src/engine/SCons/Subst.py b/src/engine/SCons/Subst.py index a68b54d..68d247f 100644 --- a/src/engine/SCons/Subst.py +++ b/src/engine/SCons/Subst.py @@ -338,7 +338,10 @@ SUBST_RAW = 1 SUBST_SIG = 2 _rm = re.compile(r'\$[()]') -_rm_split = re.compile(r'(\$[()])') + +# Note the pattern below only matches $( or $) when there is no +# preceeding $. (Thus the (?<!\$)) +_rm_split = re.compile(r'(?<!\$)(\$[()])') # Indexed by the SUBST_* constants above. _regex_remove = [ _rm, None, _rm_split ] @@ -437,7 +440,11 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, gvars={ if s0 != '$': return s if s1 == '$': - return '$' + # In this case keep the double $'s which we'll later + # swap for a single dollar sign as we need to retain + # this information to properly avoid matching "$("" when + # the actual text was "$$("" (or "$)"" when "$$)"" ) + return '$$' elif s1 in '()': return s else: @@ -583,6 +590,12 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, gvars={ # Compress strings of white space characters into # a single space. result = _space_sep.sub(' ', result).strip() + + # Now replace escaped $'s currently "$$" + # This is needed because we now retain $$ instead of + # replacing them during substition to avoid + # improperly trying to escape "$$(" as being "$(" + result = result.replace('$$','$') elif is_Sequence(result): remove = _list_remove[mode] if remove: |