Skip to content

Commit bd38fef

Browse files
author
Sathish Kumar Kamishettigari
committed
lopper:assists:baremetal_getsupported_comp_xlnx: Add support to include the examples in the lib_list.yaml
In the current implementation the examples are not included in the lib_list yaml file, Add support to include the examples in the lib_list.yaml to show the available examles for the library in the GUI. To enhance functionality, add support for reading examples from custom configurations in YAML files. If a YAML file contains a condition within the examples section in the form of a Python code block, read and execute this code to update the examples based on the specified conditions. This approach allows dynamic configuration adjustments based on predefined logic, improving flexibility and customization in managing examples Signed-off-by: Sathish Kumar Kamishettigari <sathishkumar.kamishettigari@amd.com>
1 parent 5b46bb1 commit bd38fef

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

lopper/assists/baremetal_getsupported_comp_xlnx.py

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,44 @@ class VerboseSafeDumper(yaml.SafeDumper):
2929
def ignore_aliases(self, data):
3030
return True
3131

32-
def get_yaml_data(comp_name, comp_dir):
32+
def get_yaml_data(comp_name, comp_dir,proc_ip_name=None,family=None):
3333
yaml_file = os.path.join(comp_dir, 'data', f'{comp_name}.yaml')
3434
schema = utils.load_yaml(yaml_file)
3535
supported_proc_list = schema.get('supported_processors',[])
3636
supported_os_list = schema.get('supported_os',[])
3737
description = schema.get('description',"")
3838
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
4170

4271
def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):
4372
_level(utils.log_setup(options), __name__)
@@ -46,7 +75,7 @@ def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):
4675

4776
matched_node = get_cpu_node(sdt, options)
4877
proc_ip_name = matched_node['xlnx,ip-name'].value[0]
49-
78+
family = sdt.tree.dct['family'][0]
5079
supported_app_dict = {proc_name: {'standalone': {}, 'freertos': {}}}
5180
supported_libs_dict = {proc_name: {'standalone': {}, 'freertos': {}}}
5281

@@ -84,9 +113,9 @@ def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):
84113

85114
for app_name in list(apps_dict.keys()):
86115
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'])
88117
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])
90119
if proc_ip_name in supported_proc_list:
91120
app_dict = {app_name : {'description': description, 'depends_libs': dep_lib_list}}
92121
if 'standalone' in supported_os_list:
@@ -105,12 +134,12 @@ def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):
105134
lib_dir = cur_lib_dict[version_list[0]]
106135
sorted_lib_dict = {version: cur_lib_dict[version] for version in version_list}
107136

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)
109138
if proc_ip_name in supported_proc_list:
110139
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}}
112141
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}}
114143
if 'standalone' in supported_os_list:
115144
supported_libs_dict[proc_name]['standalone'].update(lib_dict)
116145
if "freertos10_xilinx" in supported_os_list:

0 commit comments

Comments
 (0)