Skip to content

Commit 0846969

Browse files
Sathish Kumar Kamishettigarizeddii
Sathish Kumar Kamishettigari
authored andcommitted
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 0846969

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

lopper/assists/baremetal_getsupported_comp_xlnx.py

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,45 @@ 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:
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.pop("condition",None)
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
4171

4272
def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):
4373
_level(utils.log_setup(options), __name__)
@@ -46,7 +76,8 @@ def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):
4676

4777
matched_node = get_cpu_node(sdt, options)
4878
proc_ip_name = matched_node['xlnx,ip-name'].value[0]
49-
79+
family = sdt.tree['/'].propval('family')
80+
family = family[0] if family else ""
5081
supported_app_dict = {proc_name: {'standalone': {}, 'freertos': {}}}
5182
supported_libs_dict = {proc_name: {'standalone': {}, 'freertos': {}}}
5283

@@ -84,9 +115,9 @@ def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):
84115

85116
for app_name in list(apps_dict.keys()):
86117
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'])
88119
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])
90121
if proc_ip_name in supported_proc_list:
91122
app_dict = {app_name : {'description': description, 'depends_libs': dep_lib_list}}
92123
if 'standalone' in supported_os_list:
@@ -105,12 +136,12 @@ def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):
105136
lib_dir = cur_lib_dict[version_list[0]]
106137
sorted_lib_dict = {version: cur_lib_dict[version] for version in version_list}
107138

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)
109140
if proc_ip_name in supported_proc_list:
110141
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}}
112143
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}}
114145
if 'standalone' in supported_os_list:
115146
supported_libs_dict[proc_name]['standalone'].update(lib_dict)
116147
if "freertos10_xilinx" in supported_os_list:

0 commit comments

Comments
 (0)