From b5cb47e6e915d32815a9367e0074a2b44bae28ef Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 10 Mar 2018 13:59:48 -0800 Subject: Add logic to strip function all arguments attributes and array references when deciding what variables the statement depends on. So TARGET.abspath yields TARGET, TARGETS[0] yields TARGETS --- src/engine/SCons/EnvironmentValue.py | 16 ++++++++++++---- src/engine/SCons/EnvironmentValueTests.py | 9 ++++++++- src/engine/SCons/EnvironmentValues.md | 4 +++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/engine/SCons/EnvironmentValue.py b/src/engine/SCons/EnvironmentValue.py index 72a3555..593097a 100644 --- a/src/engine/SCons/EnvironmentValue.py +++ b/src/engine/SCons/EnvironmentValue.py @@ -260,6 +260,14 @@ class EnvironmentValue(object): # depends upon self.depends_on.add(function_name) for p in parameters: + # TODO: Should we strip attribute and array selectors from parameters? + # TARGET[0] -> TARGET, TARGET.abspath -> TARGET + + if '.' in p: + p = p.split('.',1)[0] + if '[' in p: + p = p.split('[',1)[0] + self.depends_on.add(p) return parameters @@ -302,9 +310,9 @@ class EnvironmentValue(object): value = v[2:-1] if '(' in value: - # Parse call to see if we can determine other dependencies from parameters - self._parse_function_call_dependencies(value) - all_dependencies.append((ValueTypes.FUNCTION_CALL, value, index)) + # Parse call to see if we can determine other dependencies from parameters + self._parse_function_call_dependencies(value) + all_dependencies.append((ValueTypes.FUNCTION_CALL, value, index)) elif '.' in value or '[' in value: all_dependencies.append((ValueTypes.EVALUABLE, value, index)) else: @@ -317,13 +325,13 @@ class EnvironmentValue(object): self.all_dependencies = all_dependencies - # Dump out debug info self.debug_print_parsed_parts(all_dependencies) depend_list = [v for (t,v,i) in all_dependencies if t in (ValueTypes.VARIABLE_OR_CALLABLE, ValueTypes.VARIABLE, ValueTypes.CALLABLE)] self.depends_on = self.depends_on.union(set(depend_list)) + @staticmethod def debug_print_parsed_parts(all_dependencies): diff --git a/src/engine/SCons/EnvironmentValueTests.py b/src/engine/SCons/EnvironmentValueTests.py index cf05ca2..b9a54c7 100644 --- a/src/engine/SCons/EnvironmentValueTests.py +++ b/src/engine/SCons/EnvironmentValueTests.py @@ -28,8 +28,15 @@ class TestEnvironmentValue(unittest.TestCase): self.assertEqual(avenv.depends_on.difference(SCons.Environment.reserved_construction_var_names_set), set(['__mycall']),"Check that all reserved contruction var names are in depends list") - import pdb; pdb.set_trace() + xx = EnvironmentValue('${__mycall(TARGETS.abspath)}') + self.assertEqual(xx.depends_on, ['__mycall','TARGETS'], + "Check function parsing strips attribute references off arguments") + + yy = EnvironmentValue('${__mycall(TARGETS[3])}') + self.assertEqual(yy.depends_on,['__mycall','TARGETS'], + "Check function parsing strips array indexes off arguments") + def test_parse_simple_values(self): one = EnvironmentValue('$LDMODULE -o $TARGET $LDMODULEFLAGS $__LDMODULEVERSIONFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS') diff --git a/src/engine/SCons/EnvironmentValues.md b/src/engine/SCons/EnvironmentValues.md index 233096d..db5da83 100644 --- a/src/engine/SCons/EnvironmentValues.md +++ b/src/engine/SCons/EnvironmentValues.md @@ -123,4 +123,6 @@ * ${VALUE} - env.Subst * ${VALUE.method} - Evaluable * Whitespace? - * Escape? \ No newline at end of file + * Escape? + * Check if the variable is one of the reserved construction variables. (We need to be sure we don't cache these) + \ No newline at end of file -- cgit v0.12