@@ -29,15 +29,45 @@ 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 :
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
+ examples = {key : value for key , value in examples .items () if key in local_scope ["examples" ]}
51
+ except Exception as e :
52
+ _warning (f"The condition in the { yaml_file } file has failed. -> { e } " )
53
+ examples = {key : value for key , value in examples .items () if key != "condition" }
54
+ for ex ,deps in examples .items ():
55
+ if deps :
56
+ # Read the supported_platforms check if any
57
+ dep_plat_list = [dep for dep in deps if "supported_platforms" in dep ]
58
+ dep_file_list = [dep for dep in deps if "dependency_files" in dep ]
59
+ if dep_plat_list :
60
+ plat_list = dep_plat_list [0 ]['supported_platforms' ]
61
+ if family in plat_list :
62
+ if dep_file_list :
63
+ example_dict .update ({ex :dep_file_list [0 ]['dependency_files' ]})
64
+ else :
65
+ example_dict .update ({ex :[]})
66
+ elif dep_file_list :
67
+ example_dict .update ({ex :dep_file_list [0 ]['dependency_files' ]})
68
+ else :
69
+ example_dict .update ({ex :[]})
70
+ return supported_proc_list , supported_os_list , description , dep_lib_list , example_dict
41
71
42
72
def xlnx_baremetal_getsupported_comp (tgt_node , sdt , options ):
43
73
_level (utils .log_setup (options ), __name__ )
@@ -46,7 +76,8 @@ def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):
46
76
47
77
matched_node = get_cpu_node (sdt , options )
48
78
proc_ip_name = matched_node ['xlnx,ip-name' ].value [0 ]
49
-
79
+ family = sdt .tree ['/' ].propval ('family' )
80
+ family = family [0 ] if family else ""
50
81
supported_app_dict = {proc_name : {'standalone' : {}, 'freertos' : {}}}
51
82
supported_libs_dict = {proc_name : {'standalone' : {}, 'freertos' : {}}}
52
83
@@ -84,9 +115,9 @@ def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):
84
115
85
116
for app_name in list (apps_dict .keys ()):
86
117
try :
87
- supported_proc_list , supported_os_list , description , dep_lib_list = get_yaml_data (app_name , apps_dict [app_name ]['vless' ])
118
+ supported_proc_list , supported_os_list , description , dep_lib_list , _ = get_yaml_data (app_name , apps_dict [app_name ]['vless' ])
88
119
except KeyError :
89
- supported_proc_list , supported_os_list , description , dep_lib_list = get_yaml_data (app_name , apps_dict [app_name ]['path' ][0 ])
120
+ supported_proc_list , supported_os_list , description , dep_lib_list , _ = get_yaml_data (app_name , apps_dict [app_name ]['path' ][0 ])
90
121
if proc_ip_name in supported_proc_list :
91
122
app_dict = {app_name : {'description' : description , 'depends_libs' : dep_lib_list }}
92
123
if 'standalone' in supported_os_list :
@@ -105,12 +136,12 @@ def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):
105
136
lib_dir = cur_lib_dict [version_list [0 ]]
106
137
sorted_lib_dict = {version : cur_lib_dict [version ] for version in version_list }
107
138
108
- supported_proc_list , supported_os_list , description , dep_lib_list = get_yaml_data (lib_name , lib_dir )
139
+ supported_proc_list , supported_os_list , description , dep_lib_list , examples = get_yaml_data (lib_name , lib_dir , proc_ip_name , family )
109
140
if proc_ip_name in supported_proc_list :
110
141
if 'path' in version_list :
111
- lib_dict = {lib_name : {'description' : description , 'depends_libs' : dep_lib_list , 'path' : sorted_lib_dict ['path' ]}}
142
+ lib_dict = {lib_name : {'description' : description , 'depends_libs' : dep_lib_list , 'path' : sorted_lib_dict ['path' ], 'examples' : examples }}
112
143
else :
113
- lib_dict = {lib_name : {'description' : description , 'depends_libs' : dep_lib_list , 'versions' : sorted_lib_dict }}
144
+ lib_dict = {lib_name : {'description' : description , 'depends_libs' : dep_lib_list , 'versions' : sorted_lib_dict , 'examples' : examples }}
114
145
if 'standalone' in supported_os_list :
115
146
supported_libs_dict [proc_name ]['standalone' ].update (lib_dict )
116
147
if "freertos10_xilinx" in supported_os_list :
0 commit comments