@@ -1451,13 +1451,16 @@ def get_module_avail(module_name):
14511451 return module_name in sys .modules .keys ()
14521452
14531453
1454- def get_autodetected_MUTS (mbeds_list ):
1454+ def get_autodetected_MUTS (mbeds_list , platform_name_filter = None ):
14551455 """ Function detects all connected to host mbed-enabled devices and generates artificial MUTS file.
14561456 If function fails to auto-detect devices it will return empty dictionary.
14571457
14581458 if get_module_avail('mbed_lstools'):
14591459 mbeds = mbed_lstools.create()
14601460 mbeds_list = mbeds.list_mbeds()
1461+
1462+ @param mbeds_list list of mbeds captured from mbed_lstools
1463+ @param platform_name You can filter 'platform_name' with list of filtered targets from 'platform_name_filter'
14611464 """
14621465 result = {} # Should be in muts_all.json format
14631466 # Align mbeds_list from mbed_lstools to MUT file format (JSON dictionary with muts)
@@ -1476,7 +1479,11 @@ def get_autodetected_MUTS(mbeds_list):
14761479 return result
14771480
14781481
1479- def get_autodetected_TEST_SPEC (mbeds_list , use_default_toolchain = True , use_supported_toolchains = False , toolchain_filter = None ):
1482+ def get_autodetected_TEST_SPEC (mbeds_list ,
1483+ use_default_toolchain = True ,
1484+ use_supported_toolchains = False ,
1485+ toolchain_filter = None ,
1486+ platform_name_filter = None ):
14801487 """ Function detects all connected to host mbed-enabled devices and generates artificial test_spec file.
14811488 If function fails to auto-detect devices it will return empty 'targets' test_spec description.
14821489
@@ -1488,23 +1495,24 @@ def get_autodetected_TEST_SPEC(mbeds_list, use_default_toolchain=True, use_suppo
14881495
14891496 for mut in mbeds_list :
14901497 mcu = mut ['platform_name' ]
1491- if mcu in TARGET_MAP :
1492- default_toolchain = TARGET_MAP [mcu ].default_toolchain
1493- supported_toolchains = TARGET_MAP [mcu ].supported_toolchains
1494-
1495- # Decide which toolchains should be added to test specification toolchain pool for each target
1496- toolchains = []
1497- if use_default_toolchain :
1498- toolchains .append (default_toolchain )
1499- if use_supported_toolchains :
1500- toolchains += supported_toolchains
1501- if toolchain_filter is not None :
1502- all_toolchains = supported_toolchains + [default_toolchain ]
1503- for toolchain in toolchain_filter .split (',' ):
1504- if toolchain in all_toolchains :
1505- toolchains .append (toolchain )
1506-
1507- result ['targets' ][mcu ] = list (set (toolchains ))
1498+ if platform_name_filter is None or (platform_name_filter and mut ['platform_name' ] in platform_name_filter ):
1499+ if mcu in TARGET_MAP :
1500+ default_toolchain = TARGET_MAP [mcu ].default_toolchain
1501+ supported_toolchains = TARGET_MAP [mcu ].supported_toolchains
1502+
1503+ # Decide which toolchains should be added to test specification toolchain pool for each target
1504+ toolchains = []
1505+ if use_default_toolchain :
1506+ toolchains .append (default_toolchain )
1507+ if use_supported_toolchains :
1508+ toolchains += supported_toolchains
1509+ if toolchain_filter is not None :
1510+ all_toolchains = supported_toolchains + [default_toolchain ]
1511+ for toolchain in toolchain_filter .split (',' ):
1512+ if toolchain in all_toolchains :
1513+ toolchains .append (toolchain )
1514+
1515+ result ['targets' ][mcu ] = list (set (toolchains ))
15081516 return result
15091517
15101518
0 commit comments