@@ -29,15 +29,44 @@ class VerboseSafeDumper(yaml.SafeDumper):
29
29
def ignore_aliases (self , data ):
30
30
return True
31
31
32
- def get_yaml_data (comp_name , comp_dir ):
32
+ def get_yaml_data (comp_name , comp_dir , proc_ip_name = None , family = None ):
33
33
yaml_file = os .path .join (comp_dir , 'data' , f'{ comp_name } .yaml' )
34
34
schema = utils .load_yaml (yaml_file )
35
35
supported_proc_list = schema .get ('supported_processors' ,[])
36
36
supported_os_list = schema .get ('supported_os' ,[])
37
37
description = schema .get ('description' ,"" )
38
38
dep_lib_list = list (schema .get ('depends_libs' ,{}).keys ())
39
-
40
- return supported_proc_list , supported_os_list , description , dep_lib_list
39
+ examples = schema .get ('examples' , {})
40
+ example_dict = {}
41
+ if examples and proc_ip_name and family :
42
+ if examples .get ("condition" ):
43
+ local_scope = {
44
+ "proc" :proc_ip_name ,
45
+ "platform" :family ,
46
+ "examples" :[]
47
+ }
48
+ try :
49
+ exec (examples ["condition" ], {}, local_scope )
50
+ except Exception as e :
51
+ _error ("The condition in the YAML file has failed. -> {e}" )
52
+ examples = {key : value for key , value in examples .items () if key in local_scope ["examples" ]}
53
+ for ex ,deps in examples .items ():
54
+ if deps :
55
+ # Read the supported_platforms check if any
56
+ dep_plat_list = [dep for dep in deps if "supported_platforms" in dep ]
57
+ dep_file_list = [dep for dep in deps if "dependency_files" in dep ]
58
+ if dep_plat_list :
59
+ plat_list = dep_plat_list [0 ]['supported_platforms' ]
60
+ if family in plat_list :
61
+ if dep_file_list :
62
+ example_dict .update ({ex :dep_file_list [0 ]['dependency_files' ]})
63
+ else :
64
+ example_dict .update ({ex :[]})
65
+ elif dep_file_list :
66
+ example_dict .update ({ex :dep_file_list [0 ]['dependency_files' ]})
67
+ else :
68
+ example_dict .update ({ex :[]})
69
+ return supported_proc_list , supported_os_list , description , dep_lib_list , example_dict
41
70
42
71
def xlnx_baremetal_getsupported_comp (tgt_node , sdt , options ):
43
72
_level (utils .log_setup (options ), __name__ )
@@ -46,7 +75,7 @@ def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):
46
75
47
76
matched_node = get_cpu_node (sdt , options )
48
77
proc_ip_name = matched_node ['xlnx,ip-name' ].value [0 ]
49
-
78
+ family = sdt . tree [ '/' ]. propval ( 'family' )[ 0 ]
50
79
supported_app_dict = {proc_name : {'standalone' : {}, 'freertos' : {}}}
51
80
supported_libs_dict = {proc_name : {'standalone' : {}, 'freertos' : {}}}
52
81
@@ -84,9 +113,9 @@ def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):
84
113
85
114
for app_name in list (apps_dict .keys ()):
86
115
try :
87
- supported_proc_list , supported_os_list , description , dep_lib_list = get_yaml_data (app_name , apps_dict [app_name ]['vless' ])
116
+ supported_proc_list , supported_os_list , description , dep_lib_list , _ = get_yaml_data (app_name , apps_dict [app_name ]['vless' ])
88
117
except KeyError :
89
- supported_proc_list , supported_os_list , description , dep_lib_list = get_yaml_data (app_name , apps_dict [app_name ]['path' ][0 ])
118
+ supported_proc_list , supported_os_list , description , dep_lib_list , _ = get_yaml_data (app_name , apps_dict [app_name ]['path' ][0 ])
90
119
if proc_ip_name in supported_proc_list :
91
120
app_dict = {app_name : {'description' : description , 'depends_libs' : dep_lib_list }}
92
121
if 'standalone' in supported_os_list :
@@ -105,12 +134,12 @@ def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):
105
134
lib_dir = cur_lib_dict [version_list [0 ]]
106
135
sorted_lib_dict = {version : cur_lib_dict [version ] for version in version_list }
107
136
108
- supported_proc_list , supported_os_list , description , dep_lib_list = get_yaml_data (lib_name , lib_dir )
137
+ supported_proc_list , supported_os_list , description , dep_lib_list , examples = get_yaml_data (lib_name , lib_dir , proc_ip_name , family )
109
138
if proc_ip_name in supported_proc_list :
110
139
if 'path' in version_list :
111
- lib_dict = {lib_name : {'description' : description , 'depends_libs' : dep_lib_list , 'path' : sorted_lib_dict ['path' ]}}
140
+ lib_dict = {lib_name : {'description' : description , 'depends_libs' : dep_lib_list , 'path' : sorted_lib_dict ['path' ], 'examples' : examples }}
112
141
else :
113
- lib_dict = {lib_name : {'description' : description , 'depends_libs' : dep_lib_list , 'versions' : sorted_lib_dict }}
142
+ lib_dict = {lib_name : {'description' : description , 'depends_libs' : dep_lib_list , 'versions' : sorted_lib_dict , 'examples' : examples }}
114
143
if 'standalone' in supported_os_list :
115
144
supported_libs_dict [proc_name ]['standalone' ].update (lib_dict )
116
145
if "freertos10_xilinx" in supported_os_list :
0 commit comments