add fix for mistaking $$( for $( and breaking subst. Reported by Noah Hoffman noah...
authorWilliam Deegan <bill@baddogconsulting.com>
Sun, 1 Oct 2017 01:13:07 +0000 (18:13 -0700)
committerWilliam Deegan <bill@baddogconsulting.com>
Sun, 1 Oct 2017 01:13:07 +0000 (18:13 -0700)
src/CHANGES.txt
src/engine/SCons/Subst.py

index 0e742ec5ee26d81ab6afd05b065543d08fc7e9ae..3b717ff81419f3eeac6c1bc779a3675392a65e58 100644 (file)
@@ -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.
index a68b54dbc855a35633b9dbba485ac51949a4e8ea..68d247f8986da20c337d796bd6f27d4f4f7da0d2 100644 (file)
@@ -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: