6565_log = fancylogger .getLogger ('easyconfig.format.one' , fname = False )
6666
6767
68- def dump_dependency (dep , toolchain ):
68+ def dump_dependency (dep , toolchain , toolchain_hierarchy = None ):
6969 """Dump parsed dependency in tuple format"""
70+ if not toolchain_hierarchy :
71+ toolchain_hierarchy = [toolchain ]
7072
7173 if dep ['external_module' ]:
7274 res = "(%s, EXTERNAL_MODULE)" % quote_py_str (dep ['full_mod_name' ])
7375 else :
7476 # minimal spec: (name, version)
7577 tup = (dep ['name' ], dep ['version' ])
76- if dep ['toolchain' ] != toolchain :
78+ if all ( dep ['toolchain' ] != subtoolchain for subtoolchain in toolchain_hierarchy ) :
7779 if dep [SYSTEM_TOOLCHAIN_NAME ]:
7880 tup += (dep ['versionsuffix' ], True )
7981 else :
@@ -260,7 +262,7 @@ def _find_param_with_comments(self, key, val, templ_const, templ_val):
260262
261263 return res
262264
263- def _find_defined_params (self , ecfg , keyset , default_values , templ_const , templ_val ):
265+ def _find_defined_params (self , ecfg , keyset , default_values , templ_const , templ_val , toolchain_hierarchy = None ):
264266 """
265267 Determine parameters in the dumped easyconfig file which have a non-default value.
266268 """
@@ -279,12 +281,18 @@ def _find_defined_params(self, ecfg, keyset, default_values, templ_const, templ_
279281 # the way that builddependencies are constructed with multi_deps
280282 # we just need to dump the first entry without the dependencies
281283 # that are listed in multi_deps
282- valstr = [dump_dependency (d , ecfg ['toolchain' ]) for d in val [0 ]
283- if d ['name' ] not in ecfg ['multi_deps' ]]
284+ valstr = [
285+ dump_dependency (d , ecfg ['toolchain' ], toolchain_hierarchy = toolchain_hierarchy )
286+ for d in val [0 ] if d ['name' ] not in ecfg ['multi_deps' ]
287+ ]
284288 else :
285- valstr = [[dump_dependency (d , ecfg ['toolchain' ]) for d in dep ] for dep in val ]
289+ valstr = [
290+ [dump_dependency (d , ecfg ['toolchain' ], toolchain_hierarchy = toolchain_hierarchy )
291+ for d in dep ] for dep in val
292+ ]
286293 else :
287- valstr = [dump_dependency (d , ecfg ['toolchain' ]) for d in val ]
294+ valstr = [dump_dependency (d , ecfg ['toolchain' ], toolchain_hierarchy = toolchain_hierarchy )
295+ for d in val ]
288296 elif key == 'toolchain' :
289297 valstr = "{'name': '%(name)s', 'version': '%(version)s'}" % ecfg [key ]
290298 else :
@@ -299,20 +307,22 @@ def _find_defined_params(self, ecfg, keyset, default_values, templ_const, templ_
299307
300308 return eclines , printed_keys
301309
302- def dump (self , ecfg , default_values , templ_const , templ_val ):
310+ def dump (self , ecfg , default_values , templ_const , templ_val , toolchain_hierarchy = None ):
303311 """
304312 Dump easyconfig in format v1.
305313
306314 :param ecfg: EasyConfig instance
307315 :param default_values: default values for easyconfig parameters
308316 :param templ_const: known template constants
309317 :param templ_val: known template values
318+ :param toolchain_hierarchy: hierarchy of toolchains for easyconfig
310319 """
311320 # include header comments first
312321 dump = self .comments ['header' ][:]
313322
314323 # print easyconfig parameters ordered and in groups specified above
315- params , printed_keys = self ._find_defined_params (ecfg , GROUPED_PARAMS , default_values , templ_const , templ_val )
324+ params , printed_keys = self ._find_defined_params (ecfg , GROUPED_PARAMS , default_values , templ_const , templ_val ,
325+ toolchain_hierarchy = toolchain_hierarchy )
316326 dump .extend (params )
317327
318328 # print other easyconfig parameters at the end
0 commit comments