openubmc-bingo 0.5.240__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of openubmc-bingo might be problematic. Click here for more details.

Files changed (242) hide show
  1. bmcgo/__init__.py +12 -0
  2. bmcgo/bmcgo.py +22 -0
  3. bmcgo/bmcgo_config.py +176 -0
  4. bmcgo/cli/__init__.py +10 -0
  5. bmcgo/cli/cli.py +584 -0
  6. bmcgo/codegen/__init__.py +14 -0
  7. bmcgo/codegen/c/__init__.py +9 -0
  8. bmcgo/codegen/c/annotation.py +52 -0
  9. bmcgo/codegen/c/argument.py +42 -0
  10. bmcgo/codegen/c/codegen.py +153 -0
  11. bmcgo/codegen/c/comment.py +22 -0
  12. bmcgo/codegen/c/ctype_defination.py +353 -0
  13. bmcgo/codegen/c/helper.py +87 -0
  14. bmcgo/codegen/c/interface.py +63 -0
  15. bmcgo/codegen/c/method.py +82 -0
  16. bmcgo/codegen/c/property.py +180 -0
  17. bmcgo/codegen/c/renderer.py +21 -0
  18. bmcgo/codegen/c/signal.py +64 -0
  19. bmcgo/codegen/c/template/client.c.mako +145 -0
  20. bmcgo/codegen/c/template/client.h.mako +36 -0
  21. bmcgo/codegen/c/template/interface.c.mako +0 -0
  22. bmcgo/codegen/c/template/interface.introspect.xml.mako +99 -0
  23. bmcgo/codegen/c/template/micro_component.c.mako +32 -0
  24. bmcgo/codegen/c/template/public.c.mako +228 -0
  25. bmcgo/codegen/c/template/public.h.mako +128 -0
  26. bmcgo/codegen/c/template/server.c.mako +104 -0
  27. bmcgo/codegen/c/template/server.h.mako +36 -0
  28. bmcgo/codegen/lua/.lua-format +7 -0
  29. bmcgo/codegen/lua/Makefile +101 -0
  30. bmcgo/codegen/lua/__init__.py +9 -0
  31. bmcgo/codegen/lua/codegen.py +171 -0
  32. bmcgo/codegen/lua/proto/Makefile +87 -0
  33. bmcgo/codegen/lua/proto/ipmi_types.proto +17 -0
  34. bmcgo/codegen/lua/proto/types.proto +52 -0
  35. bmcgo/codegen/lua/script/check_intfs.py +161 -0
  36. bmcgo/codegen/lua/script/dto/__init__.py +11 -0
  37. bmcgo/codegen/lua/script/dto/exception.py +53 -0
  38. bmcgo/codegen/lua/script/dto/kepler_abstract.py +47 -0
  39. bmcgo/codegen/lua/script/dto/options.py +33 -0
  40. bmcgo/codegen/lua/script/dto/print_simple.py +19 -0
  41. bmcgo/codegen/lua/script/dto/redfish_api.py +241 -0
  42. bmcgo/codegen/lua/script/dto/url_route.py +195 -0
  43. bmcgo/codegen/lua/script/gen_db_json.py +444 -0
  44. bmcgo/codegen/lua/script/gen_depends.py +89 -0
  45. bmcgo/codegen/lua/script/gen_entry.py +263 -0
  46. bmcgo/codegen/lua/script/gen_feature_json.py +156 -0
  47. bmcgo/codegen/lua/script/gen_historical_local_db_json.py +88 -0
  48. bmcgo/codegen/lua/script/gen_intf_json.py +261 -0
  49. bmcgo/codegen/lua/script/gen_intf_rpc_json.py +575 -0
  50. bmcgo/codegen/lua/script/gen_ipmi_json.py +485 -0
  51. bmcgo/codegen/lua/script/gen_mdb_json.py +117 -0
  52. bmcgo/codegen/lua/script/gen_rpc_msg_json.py +487 -0
  53. bmcgo/codegen/lua/script/gen_schema.py +302 -0
  54. bmcgo/codegen/lua/script/ipmi_types_pb2.py +135 -0
  55. bmcgo/codegen/lua/script/loader/__init__.py +11 -0
  56. bmcgo/codegen/lua/script/loader/file_utils.py +33 -0
  57. bmcgo/codegen/lua/script/loader/kepler_abstract_collect.py +79 -0
  58. bmcgo/codegen/lua/script/loader/kepler_abstract_loader.py +47 -0
  59. bmcgo/codegen/lua/script/loader/redfish_loader.py +127 -0
  60. bmcgo/codegen/lua/script/lua_format.py +62 -0
  61. bmcgo/codegen/lua/script/mds_util.py +385 -0
  62. bmcgo/codegen/lua/script/merge_model.py +330 -0
  63. bmcgo/codegen/lua/script/merge_proto_algo.py +85 -0
  64. bmcgo/codegen/lua/script/proto_loader.py +47 -0
  65. bmcgo/codegen/lua/script/proto_plugin.py +140 -0
  66. bmcgo/codegen/lua/script/redfish_source_tree.py +118 -0
  67. bmcgo/codegen/lua/script/render_utils/__init__.py +38 -0
  68. bmcgo/codegen/lua/script/render_utils/base.py +25 -0
  69. bmcgo/codegen/lua/script/render_utils/client_lua.py +98 -0
  70. bmcgo/codegen/lua/script/render_utils/controller_lua.py +71 -0
  71. bmcgo/codegen/lua/script/render_utils/db_lua.py +224 -0
  72. bmcgo/codegen/lua/script/render_utils/error_lua.py +185 -0
  73. bmcgo/codegen/lua/script/render_utils/factory.py +52 -0
  74. bmcgo/codegen/lua/script/render_utils/ipmi_lua.py +159 -0
  75. bmcgo/codegen/lua/script/render_utils/ipmi_message_lua.py +24 -0
  76. bmcgo/codegen/lua/script/render_utils/mdb_lua.py +177 -0
  77. bmcgo/codegen/lua/script/render_utils/mdb_register.py +215 -0
  78. bmcgo/codegen/lua/script/render_utils/message_lua.py +26 -0
  79. bmcgo/codegen/lua/script/render_utils/messages_lua.py +156 -0
  80. bmcgo/codegen/lua/script/render_utils/model_lua.py +485 -0
  81. bmcgo/codegen/lua/script/render_utils/old_model_lua.py +429 -0
  82. bmcgo/codegen/lua/script/render_utils/plugin_lua.py +38 -0
  83. bmcgo/codegen/lua/script/render_utils/redfish_proto.py +86 -0
  84. bmcgo/codegen/lua/script/render_utils/request_lua.py +76 -0
  85. bmcgo/codegen/lua/script/render_utils/service_lua.py +130 -0
  86. bmcgo/codegen/lua/script/render_utils/utils_message_lua.py +125 -0
  87. bmcgo/codegen/lua/script/render_utils/validate_lua.py +221 -0
  88. bmcgo/codegen/lua/script/sep_ipmi_message_cmds.py +217 -0
  89. bmcgo/codegen/lua/script/template.py +166 -0
  90. bmcgo/codegen/lua/script/types_pb2.py +516 -0
  91. bmcgo/codegen/lua/script/utils.py +663 -0
  92. bmcgo/codegen/lua/script/validate.py +80 -0
  93. bmcgo/codegen/lua/script/yaml_to_json.py +73 -0
  94. bmcgo/codegen/lua/templates/Makefile +114 -0
  95. bmcgo/codegen/lua/templates/apps/Makefile +261 -0
  96. bmcgo/codegen/lua/templates/apps/Makefile.mdb.mk +64 -0
  97. bmcgo/codegen/lua/templates/apps/app.lua.mako +19 -0
  98. bmcgo/codegen/lua/templates/apps/class.lua.mako +35 -0
  99. bmcgo/codegen/lua/templates/apps/client.lua.mako +429 -0
  100. bmcgo/codegen/lua/templates/apps/controller.lua.mako +276 -0
  101. bmcgo/codegen/lua/templates/apps/datas.lua.mako +8 -0
  102. bmcgo/codegen/lua/templates/apps/db.lua.mako +89 -0
  103. bmcgo/codegen/lua/templates/apps/entry.lua.mako +128 -0
  104. bmcgo/codegen/lua/templates/apps/feature.lua.mako +37 -0
  105. bmcgo/codegen/lua/templates/apps/generate_route.mako +25 -0
  106. bmcgo/codegen/lua/templates/apps/impl_feature.lua.mako +72 -0
  107. bmcgo/codegen/lua/templates/apps/ipmi.lua.mako +97 -0
  108. bmcgo/codegen/lua/templates/apps/ipmi_cmd.lua.mako +18 -0
  109. bmcgo/codegen/lua/templates/apps/ipmi_message.lua.mako +36 -0
  110. bmcgo/codegen/lua/templates/apps/local_db.lua.mako +263 -0
  111. bmcgo/codegen/lua/templates/apps/main.lua.mako +25 -0
  112. bmcgo/codegen/lua/templates/apps/mc.lua.mako +77 -0
  113. bmcgo/codegen/lua/templates/apps/mdb.lua.mako +45 -0
  114. bmcgo/codegen/lua/templates/apps/mdb_interface.lua.mako +73 -0
  115. bmcgo/codegen/lua/templates/apps/message.lua.mako +38 -0
  116. bmcgo/codegen/lua/templates/apps/model.lua.mako +239 -0
  117. bmcgo/codegen/lua/templates/apps/orm_classes.lua.mako +16 -0
  118. bmcgo/codegen/lua/templates/apps/plugin.lua.mako +8 -0
  119. bmcgo/codegen/lua/templates/apps/redfish.proto.mako +47 -0
  120. bmcgo/codegen/lua/templates/apps/service.lua.mako +440 -0
  121. bmcgo/codegen/lua/templates/apps/signal_listen.lua.mako +19 -0
  122. bmcgo/codegen/lua/templates/apps/utils/default_intf.lua.mako +41 -0
  123. bmcgo/codegen/lua/templates/apps/utils/enum.mako +10 -0
  124. bmcgo/codegen/lua/templates/apps/utils/imports.mako +13 -0
  125. bmcgo/codegen/lua/templates/apps/utils/mdb_intf.lua.mako +25 -0
  126. bmcgo/codegen/lua/templates/apps/utils/mdb_obj.lua.mako +23 -0
  127. bmcgo/codegen/lua/templates/apps/utils/message.mako +160 -0
  128. bmcgo/codegen/lua/templates/apps/utils/request.lua.mako +59 -0
  129. bmcgo/codegen/lua/templates/apps/utils/validate.mako +83 -0
  130. bmcgo/codegen/lua/templates/errors.lua.mako +36 -0
  131. bmcgo/codegen/lua/templates/messages.lua.mako +32 -0
  132. bmcgo/codegen/lua/templates/new_app/.clang-format.mako +170 -0
  133. bmcgo/codegen/lua/templates/new_app/.gitignore.mako +26 -0
  134. bmcgo/codegen/lua/templates/new_app/CHANGELOG.md.mako +0 -0
  135. bmcgo/codegen/lua/templates/new_app/CMakeLists.txt.mako +29 -0
  136. bmcgo/codegen/lua/templates/new_app/Makefile.mako +25 -0
  137. bmcgo/codegen/lua/templates/new_app/README.md.mako +0 -0
  138. bmcgo/codegen/lua/templates/new_app/conanfile.py.mako +7 -0
  139. bmcgo/codegen/lua/templates/new_app/config.cfg.mako +6 -0
  140. bmcgo/codegen/lua/templates/new_app/mds/model.json.mako +3 -0
  141. bmcgo/codegen/lua/templates/new_app/mds/service.json.mako +21 -0
  142. bmcgo/codegen/lua/templates/new_app/permissions.ini.mako +16 -0
  143. bmcgo/codegen/lua/templates/new_app/src/lualib/${project_name}_app.lua.mako +16 -0
  144. bmcgo/codegen/lua/templates/new_app/src/service/main.lua.mako +25 -0
  145. bmcgo/codegen/lua/templates/new_app/test/integration/test_${project_name}.conf.mako +9 -0
  146. bmcgo/codegen/lua/templates/new_app/test/integration/test_${project_name}.lua.mako +47 -0
  147. bmcgo/codegen/lua/templates/new_app/test/unit/test.lua.mako +23 -0
  148. bmcgo/codegen/lua/templates/new_app/user_conf/rootfs/etc/systemd/system/${project_name}.service.mako +18 -0
  149. bmcgo/codegen/lua/templates/new_app/user_conf/rootfs/etc/systemd/system/multi-user.target.wants/${project_name}.service.link +1 -0
  150. bmcgo/component/__init__.py +10 -0
  151. bmcgo/component/analysis/analysis.py +183 -0
  152. bmcgo/component/analysis/build_deps.py +165 -0
  153. bmcgo/component/analysis/data_deps.py +333 -0
  154. bmcgo/component/analysis/dep-rules.json +912 -0
  155. bmcgo/component/analysis/dep_node.py +110 -0
  156. bmcgo/component/analysis/intf_deps.py +163 -0
  157. bmcgo/component/analysis/intf_validation.py +254 -0
  158. bmcgo/component/analysis/rule.py +211 -0
  159. bmcgo/component/analysis/smc_dfx_whitelist.json +11 -0
  160. bmcgo/component/analysis/sr_validation.py +391 -0
  161. bmcgo/component/build.py +222 -0
  162. bmcgo/component/component_dt_version_parse.py +348 -0
  163. bmcgo/component/component_helper.py +114 -0
  164. bmcgo/component/coverage/__init__.py +11 -0
  165. bmcgo/component/coverage/c_incremental_cov_report.template +53 -0
  166. bmcgo/component/coverage/incremental_cov.py +464 -0
  167. bmcgo/component/deploy.py +110 -0
  168. bmcgo/component/gen.py +169 -0
  169. bmcgo/component/package_info.py +236 -0
  170. bmcgo/component/template/conanbase.py.mako +278 -0
  171. bmcgo/component/template/conanfile.deploy.py.mako +40 -0
  172. bmcgo/component/test.py +947 -0
  173. bmcgo/errors.py +119 -0
  174. bmcgo/frame.py +217 -0
  175. bmcgo/functional/__init__.py +10 -0
  176. bmcgo/functional/analysis.py +96 -0
  177. bmcgo/functional/bmc_studio_action.py +98 -0
  178. bmcgo/functional/check.py +185 -0
  179. bmcgo/functional/conan_index_build.py +251 -0
  180. bmcgo/functional/config.py +332 -0
  181. bmcgo/functional/csr_build.py +724 -0
  182. bmcgo/functional/deploy.py +263 -0
  183. bmcgo/functional/diff.py +235 -0
  184. bmcgo/functional/fetch.py +235 -0
  185. bmcgo/functional/full_component.py +391 -0
  186. bmcgo/functional/maintain.py +381 -0
  187. bmcgo/functional/new.py +166 -0
  188. bmcgo/functional/schema_valid.py +111 -0
  189. bmcgo/functional/simple_sign.py +104 -0
  190. bmcgo/functional/upgrade.py +78 -0
  191. bmcgo/ipmigen/__init__.py +13 -0
  192. bmcgo/ipmigen/ctype_defination.py +82 -0
  193. bmcgo/ipmigen/ipmigen.py +309 -0
  194. bmcgo/ipmigen/template/cmd.c.mako +366 -0
  195. bmcgo/ipmigen/template/ipmi.c.mako +25 -0
  196. bmcgo/ipmigen/template/ipmi.h.mako +51 -0
  197. bmcgo/logger.py +176 -0
  198. bmcgo/misc.py +117 -0
  199. bmcgo/target/app.yml +17 -0
  200. bmcgo/target/install_sdk.yml +15 -0
  201. bmcgo/target/personal.yml +53 -0
  202. bmcgo/target/publish.yml +45 -0
  203. bmcgo/tasks/__init__.py +11 -0
  204. bmcgo/tasks/download_buildtools_hm.py +124 -0
  205. bmcgo/tasks/misc.py +15 -0
  206. bmcgo/tasks/task.py +354 -0
  207. bmcgo/tasks/task_build_conan.py +714 -0
  208. bmcgo/tasks/task_build_rootfs_img.py +595 -0
  209. bmcgo/tasks/task_buildgppbin.py +88 -0
  210. bmcgo/tasks/task_buildhpm_ext4.py +82 -0
  211. bmcgo/tasks/task_create_interface_config.py +122 -0
  212. bmcgo/tasks/task_download_buildtools.py +99 -0
  213. bmcgo/tasks/task_download_dependency.py +72 -0
  214. bmcgo/tasks/task_hpm_envir_prepare.py +112 -0
  215. bmcgo/tasks/task_packet_to_supporte.py +87 -0
  216. bmcgo/tasks/task_prepare.py +105 -0
  217. bmcgo/tasks/task_sign_and_pack_hpm.py +42 -0
  218. bmcgo/utils/__init__.py +10 -0
  219. bmcgo/utils/buffer.py +128 -0
  220. bmcgo/utils/combine_json_schemas.py +170 -0
  221. bmcgo/utils/component_post.py +54 -0
  222. bmcgo/utils/component_version_check.py +86 -0
  223. bmcgo/utils/config.py +1067 -0
  224. bmcgo/utils/fetch_component_code.py +232 -0
  225. bmcgo/utils/install_manager.py +61 -0
  226. bmcgo/utils/installations/__init__.py +10 -0
  227. bmcgo/utils/installations/base_installer.py +70 -0
  228. bmcgo/utils/installations/install_consts.py +30 -0
  229. bmcgo/utils/installations/install_plans/bingo.yml +11 -0
  230. bmcgo/utils/installations/install_workflow.py +50 -0
  231. bmcgo/utils/installations/installers/apt_installer.py +177 -0
  232. bmcgo/utils/installations/installers/pip_installer.py +46 -0
  233. bmcgo/utils/installations/version_util.py +100 -0
  234. bmcgo/utils/mapping_config_patch.py +443 -0
  235. bmcgo/utils/perf_analysis.py +114 -0
  236. bmcgo/utils/tools.py +704 -0
  237. bmcgo/worker.py +417 -0
  238. openubmc_bingo-0.5.240.dist-info/METADATA +30 -0
  239. openubmc_bingo-0.5.240.dist-info/RECORD +242 -0
  240. openubmc_bingo-0.5.240.dist-info/WHEEL +5 -0
  241. openubmc_bingo-0.5.240.dist-info/entry_points.txt +2 -0
  242. openubmc_bingo-0.5.240.dist-info/top_level.txt +1 -0
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/python3
2
+ # coding: utf-8
3
+ # Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
+ # openUBMC is licensed under Mulan PSL v2.
5
+ # You can use this software according to the terms and conditions of the Mulan PSL v2.
6
+ # You may obtain a copy of Mulan PSL v2 at:
7
+ # http://license.coscl.org.cn/MulanPSL2
8
+ # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9
+ # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10
+ # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11
+ # See the Mulan PSL v2 for more details.
12
+ from xml.dom import Node
13
+ import inflection
14
+ from bmcgo.codegen.c.property import Property
15
+ from bmcgo.codegen.c.method import Method
16
+ from bmcgo.codegen.c.signal import Signal
17
+ from bmcgo.codegen.c.comment import Comment
18
+ from bmcgo.codegen.c.annotation import Annotation
19
+ from bmcgo.codegen.c.helper import Helper
20
+ from bmcgo.logger import Logger
21
+
22
+ log = Logger("c_interface")
23
+
24
+
25
+ class Interface():
26
+ def __init__(self, node: Node, comment: Comment, version):
27
+ super().__init__()
28
+ prefix = ""
29
+ self.node = node
30
+ self.name = Helper.get_node_value(node, "name")
31
+ self.class_name = "_".join(self.name.split("."))
32
+ self.version = version
33
+ self.properties: list[Property] = []
34
+ self.annotations: list[Annotation] = []
35
+ self.methods: list[Method] = []
36
+ self.signals: list[Signal] = []
37
+ self.comment = comment or Comment()
38
+ self.privilege = "0"
39
+ log.debug("接口: %s, 版本: %s" % (self.name, version))
40
+ if len(comment.texts) > 0:
41
+ log.debug("%s 注释: %s" % (prefix, comment.texts))
42
+ comment = Comment()
43
+ for child in node.childNodes:
44
+ if child.nodeType == Node.COMMENT_NODE:
45
+ comment.append(child)
46
+ if child.nodeType == Node.ELEMENT_NODE:
47
+ if child.nodeName == "property":
48
+ prop = Property(self, child, comment, prefix)
49
+ self.properties.append(prop)
50
+ elif child.nodeName == "annotation":
51
+ self.annotations.append(Annotation(child, comment, prefix))
52
+ elif child.nodeName == "method":
53
+ self.methods.append(Method(self, child, comment, prefix))
54
+ elif child.nodeName == "signal":
55
+ self.signals.append(Signal(self, child, comment, prefix))
56
+ comment = Comment()
57
+
58
+ for annotation in self.annotations:
59
+ if annotation.name == "bmc.kepler.Interface.Alias":
60
+ self.class_name = annotation.value
61
+ elif annotation.name == "bmc.kepler.annotition.Privileges":
62
+ self.privilege = Helper.get_privilege(annotation.value)
63
+ self.upper_name = inflection.underscore(self.class_name).upper()
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/python3
2
+ # coding: utf-8
3
+ # Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
+ # openUBMC is licensed under Mulan PSL v2.
5
+ # You can use this software according to the terms and conditions of the Mulan PSL v2.
6
+ # You may obtain a copy of Mulan PSL v2 at:
7
+ # http://license.coscl.org.cn/MulanPSL2
8
+ # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9
+ # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10
+ # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11
+ # See the Mulan PSL v2 for more details.
12
+ from xml.dom import Node
13
+ from bmcgo.codegen.c.annotation import Annotation
14
+ from bmcgo.codegen.c.argument import Argument
15
+ from bmcgo.codegen.c.comment import Comment
16
+ from bmcgo.codegen.c.helper import Helper
17
+ from bmcgo.logger import Logger
18
+
19
+ log = Logger("c_method")
20
+
21
+
22
+ class Method():
23
+ def __init__(self, interface, node: Node, comment: Comment, prefix: str = ""):
24
+ prefix = prefix + " "
25
+ self.comment = comment
26
+ self.name = Helper.get_node_value(node, "name")
27
+ self.req_args: list[Argument] = []
28
+ self.rsp_args: list[Argument] = []
29
+ self.annotations: list[Annotation] = []
30
+ self.deprecated = False
31
+ self.interface = interface
32
+ self.privilege = "0"
33
+ self.deprecated_str = ""
34
+ log.debug("%s 方法名: %33s" % (prefix, self.name))
35
+ if len(comment.texts) > 0:
36
+ log.debug("%s 注释: %s" % (prefix, comment.texts))
37
+ comment = Comment()
38
+ for child in node.childNodes:
39
+ if child.nodeType == Node.COMMENT_NODE:
40
+ comment.append(child)
41
+ elif child.nodeType == Node.ELEMENT_NODE:
42
+ if child.nodeName == "annotation":
43
+ self.annotations.append(Annotation(child, comment, prefix))
44
+ elif child.nodeName == "arg":
45
+ self._args_append(Argument(child, comment, prefix))
46
+ comment = Comment()
47
+ arg_id = 0
48
+ for arg in self.req_args:
49
+ arg.set_arg_id(arg_id)
50
+ arg_id += 1
51
+ arg_id = 0
52
+ for arg in self.rsp_args:
53
+ arg.set_arg_id(arg_id)
54
+ arg_id += 1
55
+
56
+ # 是否已被弃用
57
+ for annotation in self.annotations:
58
+ if annotation.deprecated:
59
+ self.deprecated = True
60
+ self.deprecated_str = " __attribute__((__deprecated__(\"%s\"))) " % annotation.deprecated
61
+ elif annotation.name == "bmc.kepler.annotition.Privileges":
62
+ self.privilege = Helper.get_privilege(annotation.value)
63
+
64
+ def req_signature(self):
65
+ signature = "("
66
+ for arg in self.req_args:
67
+ signature = signature + arg.signature
68
+ signature = signature + ")"
69
+ return signature
70
+
71
+ def rsp_signature(self):
72
+ signature = "("
73
+ for arg in self.rsp_args:
74
+ signature = signature + arg.signature
75
+ signature = signature + ")"
76
+ return signature
77
+
78
+ def _args_append(self, arg):
79
+ if arg.direction == "in":
80
+ self.req_args.append(arg)
81
+ else:
82
+ self.rsp_args.append(arg)
@@ -0,0 +1,180 @@
1
+ #!/usr/bin/python3
2
+ # coding: utf-8
3
+ # Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
+ # openUBMC is licensed under Mulan PSL v2.
5
+ # You can use this software according to the terms and conditions of the Mulan PSL v2.
6
+ # You may obtain a copy of Mulan PSL v2 at:
7
+ # http://license.coscl.org.cn/MulanPSL2
8
+ # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9
+ # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10
+ # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11
+ # See the Mulan PSL v2 for more details.
12
+ from xml.dom import Node
13
+ from bmcgo.codegen.c.annotation import Annotation, AnnotationBase
14
+ from bmcgo.codegen.c.comment import Comment
15
+ from bmcgo.codegen.c.ctype_defination import CTypeBase, CTypes
16
+ from bmcgo.codegen.c.helper import Helper
17
+ from bmcgo.logger import Logger
18
+
19
+ log = Logger("c_property")
20
+
21
+
22
+ class MdsFormatError(OSError):
23
+ """测试失败"""
24
+
25
+
26
+ class Property():
27
+ def __init__(self, interface, node: Node, comment, prefix: str = ""):
28
+ prefix = prefix + " "
29
+ self.interface = interface
30
+ self.node = node
31
+ self.comment = comment or Comment()
32
+ self.name = Helper.get_node_value(node, "name")
33
+ self.read_privilege = "0"
34
+ self.write_privilege = "0"
35
+ if self.name == "_base" or self.name == "__reserved__":
36
+ raise MdsFormatError("格式错误, 属性 _base 被保留")
37
+ self.signature = Helper.get_node_value(node, "type")
38
+ self.ctype: CTypeBase = CTypes.types.get(self.signature, CTypes.types.get("*"))
39
+ self.access = Helper.get_node_value(node, "access", "")
40
+ if self.access not in ["readwrite", "read", "write", ""]:
41
+ log.error("不支持的属性访问类型: " + self.access)
42
+ log.debug("%s 属性, 名字: %s, 类型: %s, 访问: %s" % (
43
+ prefix, self.name, self.signature, self.access))
44
+ if len(comment.texts) > 0:
45
+ log.debug("%s 注释: %s" % (prefix, comment.texts))
46
+ self.annotations: list[Annotation] = []
47
+ comment = Comment()
48
+ for child in node.childNodes:
49
+ if child.nodeType == Node.COMMENT_NODE:
50
+ comment.append(child)
51
+ elif child.nodeType == Node.ELEMENT_NODE:
52
+ if child.nodeName == "annotation":
53
+ self.annotations.append(Annotation(child, comment, prefix))
54
+ comment = Comment()
55
+
56
+ # 是否已被弃用
57
+ self.deprecated = False
58
+ self.deprecated_str = ""
59
+ # 是否是私有数据
60
+ self.private = False
61
+ # 是否发送信号
62
+ self.emit_changed_signal = "true"
63
+ # 是否是引用对象
64
+ self.ref_object = False;
65
+ # 是否是主键
66
+ self.primary_key = False;
67
+ # Reset_per持久化
68
+ self.reset_per = False;
69
+ # PoweroffPer持久化
70
+ self.poweroff_per = False;
71
+ # 永久持久化
72
+ self.permanent_per = False;
73
+ self.__annotations_proc()
74
+ ### 如果是对象引用属性,则必须是私有属性
75
+ if self.ref_object and not self.private:
76
+ self.annotations.append(AnnotationBase("bmc.kepler.annotition.Property.Private", "true"))
77
+ self.private = True
78
+ self.__proc_flags()
79
+
80
+ @property
81
+ def default_value(self):
82
+ for annotation in self.annotations:
83
+ if annotation.name == "bmc.kepler.annotition.Property.Default":
84
+ return annotation.value;
85
+ return ""
86
+
87
+ # 输出类结构体成员定义, 如"guint32 id"
88
+ def struct_member(self):
89
+ render_str = self.ctype.render_in_args(self.name, False).replace("const gchar *", "gchar *")
90
+ splits = render_str.split(",", -1)
91
+ out = ";".join(splits) + self.deprecated_str + ";"
92
+ return out
93
+
94
+ # 定义服务端属性值写函数参数
95
+ def server_in_args_str(self):
96
+ return self.ctype.render_in_args("value", True)
97
+
98
+ # 定义客户端属性值写参数原型
99
+ def client_in_args_str(self):
100
+ return self.ctype.render_in_args(self.name, True)
101
+
102
+ def get_flags(self):
103
+ if self.access == "readwrite":
104
+ return "G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE | G_DBUS_PROPERTY_INFO_FLAGS_READABLE"
105
+ elif self.access == "write":
106
+ return "G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE"
107
+ elif self.access == "read":
108
+ return "G_DBUS_PROPERTY_INFO_FLAGS_READABLE"
109
+ else:
110
+ return "G_DBUS_PROPERTY_INFO_FLAGS_NONE"
111
+
112
+ def __annotations_proc(self):
113
+ for annotation in self.annotations:
114
+ if annotation.deprecated:
115
+ self.deprecated = True
116
+ self.deprecated_str = " __attribute__((__deprecated__(\"%s\"))) " % annotation.deprecated
117
+ elif annotation.is_private():
118
+ self.private = True
119
+ elif annotation.is_emit_changed_signal():
120
+ self.emit_changed_signal = annotation.value
121
+ elif annotation.name == "bmc.kepler.annotition.Privileges.Read":
122
+ self.read_privilege = Helper.get_privilege(annotation.value)
123
+ elif annotation.name == "bmc.kepler.annotition.Privileges.Write":
124
+ self.write_privilege = Helper.get_privilege(annotation.value)
125
+ elif annotation.name == "bmc.kepler.annotition.RefObject":
126
+ self.ref_object = Helper.string_to_bool(annotation.value)
127
+ elif annotation.name == "bmc.kepler.annotition.PrimaryKey":
128
+ self.primary_key = Helper.string_to_bool(annotation.value)
129
+ elif annotation.name == "bmc.kepler.annotition.ResetPer":
130
+ self.reset_per = Helper.string_to_bool(annotation.value)
131
+ elif annotation.name == "bmc.kepler.annotition.PoweroffPer":
132
+ self.poweroff_per = Helper.string_to_bool(annotation.value)
133
+ elif annotation.name == "bmc.kepler.annotition.PermanentPer":
134
+ self.permanent_per = Helper.string_to_bool(annotation.value)
135
+
136
+ def __proc_flags(self):
137
+ flags = []
138
+ if self.private:
139
+ flags.append("MDB_FLAGS_PROPERTY_PRIVATE")
140
+ elif self.emit_changed_signal == "const":
141
+ flags.append("MDB_FLAGS_PROPERTY_EMIT_CONST")
142
+ elif self.emit_changed_signal == "true":
143
+ flags.append("MDB_FLAGS_PROPERTY_EMIT_TRUE")
144
+ elif self.emit_changed_signal == "false":
145
+ flags.append("MDB_FLAGS_PROPERTY_EMIT_FALSE")
146
+ elif self.emit_changed_signal == "invalidates":
147
+ flags.append("MDB_FLAGS_PROPERTY_EMIT_INVALIDATES")
148
+ if self.deprecated:
149
+ flags.append("MDB_FLAGS_PROPERTY_DEPRECATED")
150
+ if self.ref_object:
151
+ flags.append("MDB_FLAGS_PROPERTY_REFOBJECT")
152
+ if self.primary_key:
153
+ flags.append("MDB_FLAGS_PROPERTY_PRIMARY_KEY")
154
+ if self.reset_per or self.poweroff_per or self.permanent_per:
155
+ raise MdsFormatError("持久化属性不能是主键")
156
+ if self.reset_per:
157
+ flags.append("MDB_FLAGS_PROPERTY_RESET_PER")
158
+ if self.poweroff_per:
159
+ flags.append("MDB_FLAGS_PROPERTY_POWEROFF_PER")
160
+ if self.permanent_per:
161
+ flags.append("MDB_FLAGS_PROPERTY_PERMANENT_PER")
162
+ # 重置为v
163
+ if self.signature == "*":
164
+ flags.append("MDB_FLAGS_PROPERTY_ANY")
165
+ self.signature = "v"
166
+ if len(flags) == 0:
167
+ self.desc_flags = "0"
168
+ else:
169
+ self.desc_flags = " | ".join(flags)
170
+ self._access_proc()
171
+
172
+ def _access_proc(self):
173
+ if self.access == "readwrite":
174
+ self.access_flags = "G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE | G_DBUS_PROPERTY_INFO_FLAGS_READABLE"
175
+ elif self.access == "write":
176
+ self.access_flags = "G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE"
177
+ elif self.access == "read":
178
+ self.access_flags = "G_DBUS_PROPERTY_INFO_FLAGS_READABLE"
179
+ else:
180
+ self.access_flags = "G_DBUS_PROPERTY_INFO_FLAGS_NONE"
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/python3
2
+ # coding: utf-8
3
+ # Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
+ # openUBMC is licensed under Mulan PSL v2.
5
+ # You can use this software according to the terms and conditions of the Mulan PSL v2.
6
+ # You may obtain a copy of Mulan PSL v2 at:
7
+ # http://license.coscl.org.cn/MulanPSL2
8
+ # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9
+ # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10
+ # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11
+ # See the Mulan PSL v2 for more details.
12
+ from mako.lookup import TemplateLookup
13
+
14
+
15
+ class Renderer(object):
16
+ def __init__(self):
17
+ super(Renderer, self).__init__()
18
+
19
+ def render(self, lookup: TemplateLookup, template, **kwargs):
20
+ template = lookup.get_template(template)
21
+ return template.render(lookup=lookup, **kwargs)
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/python3
2
+ # coding: utf-8
3
+ # Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
+ # openUBMC is licensed under Mulan PSL v2.
5
+ # You can use this software according to the terms and conditions of the Mulan PSL v2.
6
+ # You may obtain a copy of Mulan PSL v2 at:
7
+ # http://license.coscl.org.cn/MulanPSL2
8
+ # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9
+ # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10
+ # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11
+ # See the Mulan PSL v2 for more details.
12
+ from xml.dom import Node
13
+ from bmcgo.codegen.c.annotation import Annotation
14
+ from bmcgo.codegen.c.argument import Argument
15
+ from bmcgo.codegen.c.comment import Comment
16
+ from bmcgo.codegen.c.helper import Helper
17
+ from bmcgo.logger import Logger
18
+
19
+ log = Logger("c_signal")
20
+
21
+
22
+ class Signal():
23
+ def __init__(self, interface, node: Node, comment: Comment, prefix: str = ""):
24
+ prefix = prefix + " "
25
+ self.name = Helper.get_node_value(node, "name", "")
26
+ if self.name is None:
27
+ log.error("方法缺少 'name' 属性")
28
+ self.args: list[Argument] = []
29
+ self.annotations: list[Annotation] = []
30
+ self.deprecated = False
31
+ self.interface = interface
32
+ self.comment = comment or Comment()
33
+ self.deprecated_str = ""
34
+ log.debug("%s 信号名: %33s" % (prefix, self.name))
35
+ if len(comment.texts) > 0:
36
+ log.debug("%s 注释: %s" % (prefix, comment.texts))
37
+ comment = Comment()
38
+ for child in node.childNodes:
39
+ if child.nodeType == Node.COMMENT_NODE:
40
+ comment.append(child)
41
+ elif child.nodeType == Node.ELEMENT_NODE:
42
+ if child.nodeName == "annotation":
43
+ self.annotations.append(Annotation(child, comment, prefix))
44
+ elif child.nodeName == "arg":
45
+ self.args.append(Argument(child, comment, prefix))
46
+ comment = Comment()
47
+
48
+ arg_id = 0
49
+ for arg in self.args:
50
+ arg.set_arg_id(arg_id)
51
+ arg_id += 1
52
+
53
+ # 是否已被弃用
54
+ for annotation in self.annotations:
55
+ if annotation.deprecated:
56
+ self.deprecated = True
57
+ self.deprecated_str = " __attribute__((__deprecated__(\"%s\"))) " % annotation.deprecated
58
+
59
+ def msg_signature(self):
60
+ signature = "("
61
+ for arg in self.args:
62
+ signature = signature + arg.signature
63
+ signature = signature + ")"
64
+ return signature
@@ -0,0 +1,145 @@
1
+ #include "mdb_base.h"
2
+ #include "${xml.name}.h"
3
+
4
+ % for intf in xml.interfaces:
5
+ <% class_name = intf.class_name + "_Cli"
6
+ method_processer = "_" + intf.class_name + "_method_msg_processer"
7
+ properties = "_" + intf.class_name + "_properties"
8
+ signal_processer = "_" + intf.class_name + "_signal_msg_processer"
9
+ %>\
10
+ static ${intf.class_name}_MethodMsgProcesser *${method_processer} = NULL;
11
+ static ${intf.class_name}_Properties ${properties};
12
+ static ${intf.class_name}_SignalMsgProcesser *${signal_processer} = NULL;
13
+
14
+ % for prop in intf.properties:
15
+ % if not prop.ref_object:
16
+ % for c in prop.comment.texts:
17
+ /* ${c} */
18
+ % endfor
19
+ int ${class_name}_set_${prop.name}(const ${class_name} *object, const CallerContext *ctx, ${prop.client_in_args_str()}, GError **error)
20
+ {
21
+ cleanup_unref GVariant *_value = ${prop.ctype.args_write_remote_declear.replace("<arg_name>", prop.name)};
22
+ return mdb_impl.set((MdbObject *)object, ctx, &${properties}.${prop.name}, _value, error);
23
+ }
24
+ int ${class_name}_get_${prop.name}(const ${class_name} *object, const CallerContext *ctx, GError **error)
25
+ {
26
+ GVariant *out_val = NULL;
27
+ gint ret = mdb_impl.get((MdbObject *)object, ctx, &${properties}.${prop.name}, &out_val, error);
28
+ if (ret != 0) {
29
+ return ret;
30
+ }
31
+ g_variant_unref(out_val);
32
+ return 0;
33
+ }
34
+
35
+ % endif
36
+ % endfor
37
+ % for method in intf.methods:
38
+ /*
39
+ * Call dbus method: ${method.name}
40
+ % for arg in method.req_args:
41
+ % if len(arg.comment.texts) > 0:
42
+ * @in_${arg.name}: ${" ".join(arg.comment.texts)}
43
+ % else:
44
+ * @in_${arg.name}: method input
45
+ % endif
46
+ % endfor
47
+ % for arg in method.rsp_args:
48
+ % if len(arg.comment.texts) > 0:
49
+ * @out_${arg.name}: ${" ".join(arg.comment.texts)}
50
+ % else:
51
+ * @out_${arg.name}: method output
52
+ % endif
53
+ % endfor
54
+ *
55
+ % for c in method.comment.texts:
56
+ * ${c}
57
+ % endfor
58
+ */
59
+ int ${class_name}_Call_${method.name}(const ${class_name} *object, ${intf.class_name}_${method.name}_Req *req, ${intf.class_name}_${method.name}_Rsp *rsp, gint timeout, GError **error)
60
+ {
61
+ return mdb_impl.call_method((MdbObject *)object, (const MdbMethodMsgProcesser *)&${method_processer}->${method.name},
62
+ req, rsp, timeout, error);
63
+ }
64
+ % endfor
65
+
66
+ static MdbObject *_${class_name}_create(const gchar *obj_name, gpointer opaque);
67
+ /*
68
+ * interface: ${intf.name}
69
+ % for c in intf.comment.texts:
70
+ * ${c}
71
+ % endfor
72
+ */
73
+ static MdbInterface _${class_name}_interface = {
74
+ .create = _${class_name}_create,
75
+ .is_remote = 1,
76
+ .privilege = ${intf.privilege},
77
+ .name = "${intf.name}",
78
+ .class_name = "${intf.class_name}",
79
+ .properties = (MdbProperty *)&${properties},
80
+ .methods = NULL,
81
+ .interface = NULL, /* load from usr/share/dbus-1/interfaces/${xml.name} by mdb_init */
82
+ };
83
+
84
+ MdbObject *_${class_name}_create(const gchar *obj_name, gpointer opaque)
85
+ {
86
+ ${class_name} *obj = g_new0(${class_name}, 1);
87
+ (void)memcpy_s(obj->_base.magic, strlen(MDB_MAGIC) + 1, MDB_MAGIC, strlen(MDB_MAGIC) + 1);
88
+ obj->_base.lock = g_new0(GRecMutex, 1);
89
+ g_rec_mutex_init(obj->_base.lock);
90
+ obj->_base.name = g_strdup(obj_name);
91
+ obj->_base.intf = &_${class_name}_interface;
92
+ obj->_base.opaque = opaque;
93
+ return (MdbObject *)obj;
94
+ }
95
+ % for signal in intf.signals:
96
+ /*
97
+ * Send dbus signal: ${signal.name}
98
+ % for c in signal.comment.texts:
99
+ * ${c}
100
+ % endfor
101
+ */
102
+ guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Signal handler, const gchar *bus_name,
103
+ const gchar *object_path, const gchar *arg0, gpointer user_data)
104
+ {
105
+ if (handler == NULL) {
106
+ log_error("parameter error, handler is NULL");
107
+ return 0;
108
+ }
109
+ return mdb_impl.subscribe_signal(&_${class_name}_interface, bus_name, (const MdbSignalMsgProcesser *)&${signal_processer}->${signal.name},
110
+ object_path, arg0, (mdb_signal_handler)handler, user_data);
111
+ }
112
+
113
+ void ${class_name}_Unsubscribe_${signal.name}(guint id)
114
+ {
115
+ return mdb_impl.unsubscribe_signal(id);
116
+ }
117
+
118
+ % endfor
119
+
120
+ MdbInterface *${class_name}_interface(void)
121
+ {
122
+ return &_${class_name}_interface;
123
+ }
124
+
125
+ ${intf.class_name}_Properties *${class_name}_properties(void)
126
+ {
127
+ return &${properties};
128
+ }
129
+
130
+ static void __attribute__((constructor(CONSTRUCTOR_REGISTER_INTERFACE_PRIORITY))) ${class_name}_register(void)
131
+ {
132
+ // 从公共库中复制信号处理函数
133
+ ${signal_processer} = ${intf.class_name}_signal_msg_processer();
134
+
135
+ // 从公共库中复制方法处理函数
136
+ ${method_processer} = ${intf.class_name}_method_msg_processer();
137
+
138
+ // 从公共库中复制属性信息
139
+ (void)memcpy_s(&${properties}, sizeof(${properties}),${intf.class_name}_properties_internal(), sizeof(${properties}));
140
+
141
+ mdb_register_interface(&_${class_name}_interface,
142
+ "${xml.introspect_xml_sha256}",
143
+ "/usr/share/dbus-1/interfaces/${xml.name}.xml");
144
+ }
145
+ % endfor
@@ -0,0 +1,36 @@
1
+ #ifndef __${"_".join(xml.name.upper().split(".", -1))}_CLI_H__
2
+ #define __${"_".join(xml.name.upper().split(".", -1))}_CLI_H__
3
+
4
+ #include <glib-2.0/glib.h>
5
+ #include <glib-2.0/gio/gio.h>
6
+ #include "mdb_base.h"
7
+ #include "public/${xml.name}.h"
8
+ % for intf in xml.interfaces:
9
+ <% class_name = intf.class_name + "_Cli" %>
10
+ typedef ${intf.class_name} ${class_name};
11
+
12
+ % for prop in intf.properties:
13
+ % if not prop.ref_object:
14
+ int ${class_name}_set_${prop.name}(const ${class_name} *object, const CallerContext *ctx, ${prop.client_in_args_str()}, GError **error);
15
+ int ${class_name}_get_${prop.name}(const ${class_name} *object, const CallerContext *ctx, GError **error);
16
+ % endif
17
+ % endfor
18
+
19
+ % for method in intf.methods:
20
+ int ${class_name}_Call_${method.name}(const ${class_name} *object, ${intf.class_name}_${method.name}_Req *req, ${intf.class_name}_${method.name}_Rsp *rsp, gint timeout, GError **error);
21
+ % endfor
22
+
23
+ % for signal in intf.signals:
24
+ typedef void (*${class_name}_${signal.name}_Signal)(const ${class_name} *object, const gchar *destination, ${intf.class_name}_${signal.name}_Msg *req, gpointer user_data);
25
+ guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Signal handler,
26
+ const gchar *bus_name, const gchar *object_path, const gchar *arg0, gpointer user_data);
27
+ void ${class_name}_Unsubscribe_${signal.name}(guint id);
28
+
29
+ % endfor
30
+ MdbInterface *${class_name}_interface(void);
31
+ #define INTERFACE_CLI_${intf.upper_name} ${class_name}_interface()
32
+ ${intf.class_name}_Properties *${class_name}_properties(void);
33
+ #define PROPERTIES_CLI_${intf.upper_name} *${class_name}_properties()
34
+ % endfor
35
+
36
+ #endif /* __${"_".join(xml.name.upper().split(".", -1))}_CLI_H__ */
File without changes