Allow variables to reference other variables in other layers

This commit is contained in:
Ben Jackson 2019-07-20 19:58:19 +01:00
commit d8d22b15bc
2 changed files with 6 additions and 4 deletions

View file

@ -113,9 +113,11 @@ class DebugSession( object ):
'gadgetDir': install.GetGadgetDir( VIMSPECTOR_HOME, install.GetOS() ) 'gadgetDir': install.GetGadgetDir( VIMSPECTOR_HOME, install.GetOS() )
} }
self._variables.update( self._variables.update(
utils.ParseVariables( adapter.get( 'variables', {} ) ) ) utils.ParseVariables( adapter.get( 'variables', {} ),
self._variables ) )
self._variables.update( self._variables.update(
utils.ParseVariables( configuration.get( 'variables', {} ) ) ) utils.ParseVariables( configuration.get( 'variables', {} ),
self._variables ) )
self._variables.update( launch_variables ) self._variables.update( launch_variables )
utils.ExpandReferencesInDict( configuration, self._variables ) utils.ExpandReferencesInDict( configuration, self._variables )

View file

@ -343,7 +343,7 @@ def ExpandReferencesInDict( obj, mapping, **kwargs ):
obj[ k ] = expand_refs_in_object( obj[ k ] ) obj[ k ] = expand_refs_in_object( obj[ k ] )
def ParseVariables( variables ): def ParseVariables( variables, mapping, **kwargs ):
new_variables = {} new_variables = {}
for n, v in variables.items(): for n, v in variables.items():
if isinstance( v, dict ): if isinstance( v, dict ):
@ -353,7 +353,7 @@ def ParseVariables( variables ):
new_v = v.copy() new_v = v.copy()
# Bit of a hack. Allows environment variables to be used. # Bit of a hack. Allows environment variables to be used.
ExpandReferencesInDict( new_v, {} ) ExpandReferencesInDict( new_v, mapping, **kwargs )
env = os.environ.copy() env = os.environ.copy()
env.update( new_v.get( 'env' ) or {} ) env.update( new_v.get( 'env' ) or {} )