diff options
author | William Deegan <bill@baddogconsulting.com> | 2019-08-13 21:10:11 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2019-08-13 21:10:11 (GMT) |
commit | f0af89667e26fc615ff041110b47a54f3d3c2f4c (patch) | |
tree | 2da1c76650fc044fd9b3bc6d630150eb64ee0c6b | |
parent | 9d64fe83cfc525f4696ca1974242d1d5f2e2fff4 (diff) | |
download | SCons-f0af89667e26fc615ff041110b47a54f3d3c2f4c.zip SCons-f0af89667e26fc615ff041110b47a54f3d3c2f4c.tar.gz SCons-f0af89667e26fc615ff041110b47a54f3d3c2f4c.tar.bz2 |
Updates to make progress on subst_list functionality
-rw-r--r-- | src/engine/SCons/EnvironmentValue.py | 4 | ||||
-rw-r--r-- | src/engine/SCons/EnvironmentValues.py | 53 |
2 files changed, 35 insertions, 22 deletions
diff --git a/src/engine/SCons/EnvironmentValue.py b/src/engine/SCons/EnvironmentValue.py index ab284ca..ce61f00 100644 --- a/src/engine/SCons/EnvironmentValue.py +++ b/src/engine/SCons/EnvironmentValue.py @@ -60,6 +60,7 @@ class SubstModes(object): NORMAL = 0 RAW = 1 FOR_SIGNATURE = 2 + SUBST_LIST = 3 class ValueTypes(object): @@ -330,7 +331,8 @@ class EnvironmentValue(object): elif '.' in value or '[' in value: all_dependencies.append((ValueTypes.EVALUABLE, value, index)) else: - all_dependencies.append((ValueTypes.CALLABLE,v[2:-1], index)) + # We will get here if we have ${AAA} and AAA equates to a non-callable (string) + all_dependencies.append((ValueTypes.VARIABLE_OR_CALLABLE, v[2:-1], index)) elif '.' in v: all_dependencies.append((ValueTypes.EVALUABLE, v[1:], index)) else: diff --git a/src/engine/SCons/EnvironmentValues.py b/src/engine/SCons/EnvironmentValues.py index 848fb89..5dec65f 100644 --- a/src/engine/SCons/EnvironmentValues.py +++ b/src/engine/SCons/EnvironmentValues.py @@ -5,6 +5,7 @@ from SCons.Util import is_String, is_Sequence, CLVar from SCons.Subst import CmdStringHolder, create_subst_target_source_dict, raise_exception from SCons.EnvironmentValue import EnvironmentValue, ValueTypes, separate_args, SubstModes import SCons.Environment +# import pysnooper # AllowableExceptions = (IndexError, NameError) @@ -223,6 +224,7 @@ class EnvironmentValues(object): debug("After resolving unknown types:") EnvironmentValue.debug_print_parsed_parts(parsed_values) + # @pysnooper.snoop() def evaluate_parsed_values(self, parsed_values, string_values, source, target, gvars, lvars, mode, conv=None): """ Walk the list of parsed values and evaluate each in turn. Possible return values for each are: @@ -512,14 +514,15 @@ class EnvironmentValues(object): :param lvars: Specify local variables to evaluation the variable with. Usually this is provided by executor. :return: expanded string """ - - for_signature = mode == SubstModes.FOR_SIGNATURE - # subst called with plain string, just return it. if '$' not in substString: - return substString + if mode != SubstModes.SUBST_LIST: + return substString + else: + return [(substString, ValueTypes.STRING)] - # TODO: Case to shortcut. substString = "$VAR" and env['VAR'] = simple string. This happens enough to make it worth optimizing + # TODO: Case to shortcut. substString = "$VAR" and env['VAR'] = simple string. + # This happens enough to make it worth optimizing # if ' ' not in substString and substString[0]=='$' and # TODO:Figure out how to handle this properly. May involve seeing if source & targets is specified. Or checking @@ -529,7 +532,7 @@ class EnvironmentValues(object): ignore_undefined = False use_cache_item = 0 - if for_signature: + if mode == SubstModes.FOR_SIGNATURE: use_cache_item = 1 if not gvars: @@ -580,7 +583,9 @@ class EnvironmentValues(object): gvars, lvars, mode, conv) # Now handle subst mode during string expansion. - if for_signature: + if mode == SubstModes.SUBST_LIST: + return string_values + elif mode == SubstModes.FOR_SIGNATURE: string_values = remove_escaped_items_from_list(string_values) elif mode == SubstModes.NORMAL: string_values = [(s, t) for (s, t) in string_values if s not in ('$(', '$)')] @@ -653,8 +658,6 @@ class EnvironmentValues(object): second dimension is "words" in the command line) """ - for_signature = mode == SubstModes.FOR_SIGNATURE - # TODO: Fill in gvars, lvars as env.Subst() does.. if 'TARGET' not in lvars: d = create_subst_target_source_dict(target, source) @@ -684,6 +687,8 @@ class EnvironmentValues(object): for element in listSubstVal: # TODO: Implement splitting into multiple commands if there's a NEWLINE in any element. + # TODO: Properly handle escaping $( $) which can cross recursive evaluation. + # Currently causing infinite recursion # for a in args: # if a[0] in ' \t\n\r\f\v': @@ -700,24 +705,30 @@ class EnvironmentValues(object): retval.append([]) e_value = EnvironmentValue(element) - this_value = EnvironmentValues.subst(element, env, mode=mode, + this_value = EnvironmentValues.subst(element, env, mode=SubstModes.SUBST_LIST, target=target, source=source, gvars=gvars, lvars=lvars, conv=conv) + + # TODO: Now we're getting back a list of string values, we need to re-build the string/lines and do the + # right thing with string escaping + + retval[retval_index].extend([s for (s, t) in this_value if s != '']) # Now we need to determine if we need to recurse/evaluate this_value - if '$' not in this_value: - # no more evaluation needed - args = [a for a in separate_args.findall(this_value) if not a.isspace()] + if False: + if '$' not in this_value: + # no more evaluation needed + args = [a for a in separate_args.findall(this_value) if not a.isspace()] - retval[retval_index].extend(args) - else: - # Need to handle multiple levels of recursion, also it's possible - # that escaping could span several levels of recursion so $( at top , and $) - # several levels lower. (This would be unwise.. do we need to enable this) - this_value_2 = EnvironmentValues.subst_list(this_value, env, mode, target, source, gvars, lvars, conv) + retval[retval_index].extend(args) + else: + # Need to handle multiple levels of recursion, also it's possible + # that escaping could span several levels of recursion so $( at top , and $) + # several levels lower. (This would be unwise.. do we need to enable this) + this_value_2 = EnvironmentValues.subst_list(this_value, env, mode, target, source, gvars, lvars, conv) - debug("need to recurse") - raise Exception("need to recurse in subst_list: [%s]->{%s}" % (this_value, this_value_2)) + debug("need to recurse") + raise Exception("need to recurse in subst_list: [%s]->{%s}" % (this_value, this_value_2)) debug("subst_list:%s", retval[retval_index]) |