66
77import os
88import scl
9- from twisterlib .config_parser import TwisterConfigParser
109from twisterlib .environment import ZEPHYR_BASE
10+ import logging
11+
12+ logger = logging .getLogger ('twister' )
13+ logger .setLevel (logging .DEBUG )
1114
1215class Platform :
1316 """Class representing metadata for a particular platform
@@ -23,6 +26,7 @@ def __init__(self):
2326 """
2427
2528 self .name = ""
29+ self .aliases = []
2630 self .normalized_name = ""
2731 # if sysbuild to be used by default on a given platform
2832 self .sysbuild = False
@@ -38,7 +42,7 @@ def __init__(self):
3842 self .flash = 512
3943 self .supported = set ()
4044
41- self .arch = ""
45+ self .arch = None
4246 self .vendor = ""
4347 self .tier = - 1
4448 self .type = "na"
@@ -50,41 +54,58 @@ def __init__(self):
5054 self .filter_data = dict ()
5155 self .uart = ""
5256 self .resc = ""
57+ self .qualifier = None
58+
59+ def load (self , board , target , aliases , data ):
60+ """Load the platform data from the board data and target data
61+ board: the board object as per the zephyr build system
62+ target: the target name of the board as per the zephyr build system
63+ aliases: list of aliases for the target
64+ data: the data from the twister.yaml file for the target
65+ """
66+ self .name = target
67+ self .aliases = aliases
68+
69+ # Get data for various targets and use the main board data as a
70+ # defauly. Individual variant information will replace the default data
71+ # provded in the main twister configuration for this board.
72+ variants = data .get ("variants" , {})
73+ variant_data = {}
74+ for alias in aliases :
75+ variant_data = variants .get (alias , {})
76+ if variant_data :
77+ break
5378
54- def load (self , platform_file ):
55- scp = TwisterConfigParser (platform_file , self .platform_schema )
56- scp .load ()
57- data = scp .data
58-
59- self .name = data ['identifier' ]
6079 self .normalized_name = self .name .replace ("/" , "_" )
61- self .sysbuild = data .get ("sysbuild" , False )
62- self .twister = data .get ("twister" , True )
80+ self .sysbuild = variant_data .get ("sysbuild" , data .get ("sysbuild" , self .sysbuild ))
81+ self .twister = variant_data .get ("twister" , data .get ("twister" , self .twister ))
82+
6383 # if no RAM size is specified by the board, take a default of 128K
64- self .ram = data .get ("ram" , 128 )
65- testing = data .get ("testing" , {})
66- self .timeout_multiplier = testing .get ("timeout_multiplier" , 1.0 )
67- self .ignore_tags = testing .get ("ignore_tags" , [])
68- self .only_tags = testing .get ("only_tags" , [])
69- self .default = testing .get ("default" , False )
84+ self .ram = variant_data .get ("ram" , data .get ("ram" , self .ram ))
85+ # if no flash size is specified by the board, take a default of 512K
86+ self .flash = variant_data .get ("flash" , data .get ("flash" , self .flash ))
87+
88+ testing = variant_data .get ("testing" , data .get ("testing" , {}))
89+ self .timeout_multiplier = testing .get ("timeout_multiplier" , self .timeout_multiplier )
90+ self .ignore_tags = testing .get ("ignore_tags" , self .ignore_tags )
91+ self .only_tags = testing .get ("only_tags" , self .only_tags )
92+ self .default = testing .get ("default" , self .default )
7093 self .binaries = testing .get ("binaries" , [])
7194 renode = testing .get ("renode" , {})
7295 self .uart = renode .get ("uart" , "" )
7396 self .resc = renode .get ("resc" , "" )
74- # if no flash size is specified by the board, take a default of 512K
75- self .flash = data .get ("flash" , 512 )
7697 self .supported = set ()
77- for supp_feature in data .get ("supported" , []):
98+ for supp_feature in variant_data . get ( "supported" , data .get ("supported" , []) ):
7899 for item in supp_feature .split (":" ):
79100 self .supported .add (item )
80101
81- self .arch = data [ 'arch' ]
82- self .vendor = data . get ( ' vendor' , '' )
83- self .tier = data .get ("tier" , - 1 )
84- self .type = data .get ('type' , "na" )
85- self .simulation = data .get ('simulation' , "na" )
86- self .simulation_exec = data .get ('simulation_exec' )
87- self .supported_toolchains = data .get ("toolchain" , [])
102+ self .arch = variant_data . get ( 'arch' , data . get ( 'arch' , self . arch ))
103+ self .vendor = board . vendor
104+ self .tier = variant_data . get ( "tier" , data .get ("tier" , self . tier ) )
105+ self .type = variant_data . get ( 'type' , data .get ('type' , self . type ) )
106+ self .simulation = variant_data . get ( 'simulation' , data .get ('simulation' , self . simulation ) )
107+ self .simulation_exec = variant_data . get ( 'simulation_exec' , data .get ('simulation_exec' , self . simulation_exec ) )
108+ self .supported_toolchains = variant_data . get ( "toolchain" , data .get ("toolchain" , []) )
88109 if self .supported_toolchains is None :
89110 self .supported_toolchains = []
90111
@@ -111,7 +132,7 @@ def load(self, platform_file):
111132 if toolchain not in self .supported_toolchains :
112133 self .supported_toolchains .append (toolchain )
113134
114- self .env = data .get ("env" , [])
135+ self .env = variant_data . get ( "env" , data .get ("env" , []) )
115136 self .env_satisfied = True
116137 for env in self .env :
117138 if not os .environ .get (env , None ):
0 commit comments