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,99 @@
1
+ <!DOCTYPE node PUBLIC
2
+ "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
3
+ "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"
4
+ >
5
+ <node>
6
+ % for intf in interfaces:
7
+ % for text in intf.comment.texts:
8
+ <!-- ${text} -->
9
+ % endfor
10
+ <interface name="${intf.name}">
11
+ ### 接口注释
12
+ % for anno in intf.annotations:
13
+ <annotation name="${anno.name}" value="${anno.value}"/>
14
+ % endfor
15
+ ### 属性
16
+ % for prop in intf.properties:
17
+ % if not prop.private:
18
+ % for text in prop.comment.texts:
19
+ <!-- ${text} -->
20
+ % endfor
21
+ % if len(prop.annotations) > 0:
22
+ <property name="${prop.name}" type="${prop.signature}" access="${prop.access}">
23
+ % for anno in prop.annotations:
24
+ % for text in anno.comment.texts:
25
+ <!-- ${text} -->
26
+ % endfor
27
+ <annotation name="${anno.name}" value="${anno.value}"/>
28
+ % endfor
29
+ </property>
30
+ % else:
31
+ <property name="${prop.name}" type="${prop.signature}" access="${prop.access}"/>
32
+ % endif
33
+ % endif
34
+ % endfor
35
+ ### 方法
36
+ % for method in intf.methods:
37
+ % for text in method.comment.texts:
38
+ <!-- ${text} -->
39
+ % endfor
40
+ <method name="${method.name}">
41
+ % for anno in method.annotations:
42
+ % for text in anno.comment.texts:
43
+ <!-- ${text} -->
44
+ % endfor
45
+ <annotation name="${anno.name}" value="${anno.value}"/>
46
+ % endfor
47
+ % for arg in method.req_args:
48
+ % for text in arg.comment.texts:
49
+ <!-- ${text} -->
50
+ % endfor
51
+ % if len(arg.name) > 0:
52
+ <arg name="${arg.name}" direction="${arg.direction}" type="${arg.signature}"/>
53
+ % else:
54
+ <arg direction="${arg.direction}" type="${arg.signature}"/>
55
+ % endif
56
+ % endfor
57
+ % for arg in method.rsp_args:
58
+ % for text in arg.comment.texts:
59
+ <!-- ${text} -->
60
+ % endfor
61
+ % if len(arg.name) > 0:
62
+ <arg name="${arg.name}" direction="${arg.direction}" type="${arg.signature}"/>
63
+ % else:
64
+ <arg direction="${arg.direction}" type="${arg.signature}"/>
65
+ % endif
66
+ % endfor
67
+ </method>
68
+ % endfor
69
+ ### 方法
70
+ % for signal in intf.signals:
71
+ % for text in signal.comment.texts:
72
+ <!-- ${text} -->
73
+ % endfor
74
+ %if len(signal.annotations) > 0 or len(signal.args) > 0:
75
+ <signal name="${signal.name}">
76
+ % for anno in signal.annotations:
77
+ % for text in anno.comment.texts:
78
+ <!-- ${text} -->
79
+ % endfor
80
+ <annotation name="${anno.name}" value="${anno.value}"/>
81
+ % endfor
82
+ % for arg in signal.args:
83
+ % for text in arg.comment.texts:
84
+ <!-- ${text} -->
85
+ % endfor
86
+ % if len(arg.name) > 0:
87
+ <arg name="${arg.name}" type="${arg.signature}"/>
88
+ % else:
89
+ <arg type="${arg.signature}"/>
90
+ % endif
91
+ % endfor
92
+ </signal>
93
+ % else:
94
+ <signal name="${signal.name}"/>
95
+ % endif
96
+ % endfor
97
+ </interface>
98
+ % endfor
99
+ </node>
@@ -0,0 +1,32 @@
1
+ #include "mcc/public.h"
2
+ #include "server/bmc.kepler.MicroComponent.h"
3
+
4
+ #define MCC_BUS_NAME "bmc.kepler.${mds["name"]}"
5
+
6
+ #define MCC_APP_NAME "${mds["name"]}"
7
+
8
+ static void micro_component_start(void)
9
+ {
10
+ const MicroComponent *component = mcc_object_new(INTERFACE_MICRO_COMPONENT, mcc_bus_name(),
11
+ "/bmc/kepler/${mds["name"]}/MicroComponent", NULL);
12
+ if (component == NULL) {
13
+ log_error("Create object failed, interface: %s,"
14
+ "object: /bmc/kepler/${mds["name"]}/MicroComponent",
15
+ INTERFACE_MICRO_COMPONENT_NAME);
16
+ } else {
17
+ mcc_object_present_set(component, TRUE);
18
+ MicroComponent_set_Author(component, "${mds.get("author", "Huawei")}");
19
+ MicroComponent_set_Description(component, "${mds.get("description", "").replace('"', '\\\"')}");
20
+ MicroComponent_set_Pid(component, (gint32)getpid());
21
+ MicroComponent_set_Version(component, "${mds["version"]}");
22
+ MicroComponent_set_License(component, "${mds.get("license", "Mulan PSL v2")}");
23
+ MicroComponent_set_Name(component, "${mds["name"]}");
24
+ MicroComponent_set_Status(component, "Starting");
25
+ }
26
+ }
27
+
28
+ static void __attribute__((constructor(150))) micro_component_init(void)
29
+ {
30
+ mdb_register_module(micro_component_start, "micro_component", STAGE_START);
31
+ mcc_bus_name_set(MCC_BUS_NAME);
32
+ }
@@ -0,0 +1,228 @@
1
+ #include "mdb_base.h"
2
+ #include "${xml.name}.h"
3
+
4
+ % for intf in xml.interfaces:
5
+ <% class_name = intf.class_name %>\
6
+ % for prop in intf.properties:
7
+ % if prop.private:
8
+ % if len(prop.annotations) > 0:
9
+ /* annotation for the property ${prop.name} */
10
+ static GDBusAnnotationInfo ${class_name}_prop_${prop.name}_annotations_i[] = {
11
+ % for anno in prop.annotations:
12
+ % for c in anno.comment.texts:
13
+ /* ${c} */
14
+ % endfor
15
+ {
16
+ .ref_count = -1,
17
+ .key = "${anno.name}",
18
+ .value = "${anno.value}",
19
+ },
20
+ % endfor
21
+ };\
22
+ <% id = 0 %>
23
+ static GDBusAnnotationInfo *${class_name}_prop_${prop.name}_annotations[] = {
24
+ % for anno in prop.annotations:
25
+ &${class_name}_prop_${prop.name}_annotations_i[${id}],\
26
+ <% id = id + 1 %>
27
+ % endfor
28
+ NULL,
29
+ };
30
+ % endif
31
+
32
+ % for c in prop.comment.texts:
33
+ /* ${c} */
34
+ % endfor
35
+ static GDBusPropertyInfo ${class_name}_property_${prop.name} = {
36
+ .ref_count = -1,
37
+ .name = "${prop.name}",
38
+ .signature = "${prop.signature}",
39
+ .flags = ${prop.access_flags},
40
+ % if len(prop.annotations) > 0:
41
+ .annotations = ${class_name}_prop_${prop.name}_annotations,
42
+ % endif
43
+ };
44
+ % endif
45
+ % endfor
46
+
47
+ static ${class_name}_Properties _${class_name}_properties = {
48
+ <% id = 0 %>\
49
+ % for prop in intf.properties:
50
+ .${prop.name} = {
51
+ .id = ${id},
52
+ <% id = id + 1 %>\
53
+ .name = "${prop.name}",
54
+ .offset = offsetof(${class_name}, ${prop.name}),
55
+ .read_privilege = ${prop.read_privilege},
56
+ .write_privilege = ${prop.write_privilege},
57
+ % if prop.private:
58
+ .info = &${class_name}_property_${prop.name},
59
+ % else:
60
+ .info = NULL, /* load from /usr/share/dbus-1/interfaces/${xml.name} by mdb_init */
61
+ % endif
62
+ .flags = ${prop.desc_flags}
63
+ },
64
+ % endfor
65
+ .__reserved__ = {
66
+ .name = NULL, /* __reserved__ */
67
+ },
68
+ };
69
+
70
+ const ${class_name}_Properties *${class_name}_properties_internal(void)
71
+ {
72
+ return &_${class_name}_properties;
73
+ }
74
+
75
+ <%def name="message_decode_func(args, stru_name, msg_name)">
76
+ if (${msg_name} == NULL) {
77
+ ${msg_name} = g_new0(${stru_name}, 1);
78
+ } else {
79
+ memset(${msg_name}, 0, sizeof(${stru_name}));
80
+ }
81
+ // 如果parameters为空则返回一个初始化的结构体地址
82
+ if (!parameters) {
83
+ return ${msg_name};
84
+ }
85
+ gsize arg_id __attribute__((unused)) = 0;
86
+ % for arg in args:
87
+ % for line in arg.ctype.arg_decode:
88
+ ${line.replace("<arg_name>", arg.name).replace("<req>", msg_name + "->")}
89
+ % endfor
90
+ arg_id++;
91
+ % endfor
92
+ return ${msg_name};
93
+ </%def>\
94
+ <%def name="message_encode_func(args, pointer_name)">
95
+ % if len(args) > 0:
96
+ if (!${pointer_name}) {
97
+ return NULL;
98
+ }
99
+ % endif
100
+ % for arg in args:
101
+ %if arg.ctype.variant_type == "v":
102
+ if (${pointer_name}->${arg.name} == NULL || g_strcmp0(g_variant_get_type_string(${pointer_name}->${arg.name}), "${arg.signature}") != 0) {
103
+ return NULL;
104
+ }
105
+ % endif
106
+ % endfor
107
+ GVariant *tmp_v __attribute__((unused));
108
+ GVariantBuilder builder;
109
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_TUPLE);
110
+ % for arg in args:
111
+ % for line in arg.ctype.arg_encode:
112
+ ${line.replace("<arg_name>", arg.name).replace("<req>", pointer_name + "->")}
113
+ % endfor
114
+ % endfor
115
+ return g_variant_builder_end(&builder);
116
+ </%def>\
117
+ <%def name="message_free_func(args, pointer_name)">
118
+ % for arg in args:
119
+ % for line in arg.ctype.arg_free:
120
+ ${line.replace("<arg_name>", arg.name).replace("<req>", pointer_name + "->")}
121
+ % endfor
122
+ % endfor
123
+ if (free_self) {
124
+ g_free(${pointer_name});
125
+ }
126
+ </%def>\
127
+ ### 开始生成方法的请求体、响应体和处理函数
128
+ % for method in intf.methods:
129
+ /* (服务端)将dbus接收到的消息转换成${class_name}_${method.name}_Req请求,配套Req_free释放 */
130
+ static ${class_name}_${method.name}_Req *${class_name}_${method.name}_Req_decode(GVariant *parameters, ${class_name}_${method.name}_Req *req)
131
+ {${message_decode_func(method.req_args, class_name + "_" + method.name + "_Req", "req")}}
132
+
133
+ /* (客户端)将${class_name}_${method.name}_Req请求转换成dbus需要发送的dbus消息(GVariant *),无需调用Req_free */
134
+ static GVariant *${class_name}_${method.name}_Req_encode(${class_name}_${method.name}_Req *req)
135
+ {${message_encode_func(method.req_args, "req")}}
136
+
137
+ /* 释放${class_name}_${method.name}_Req请求结构体内容 */
138
+ static void ${class_name}_${method.name}_Req_free(${class_name}_${method.name}_Req *req, gboolean free_self)
139
+ {${message_free_func(method.req_args, "req")}}
140
+ /* (客户端)将dbus接收到的响应体转换成${class_name}_${method.name}_Rsp响应,配合Rsp_free释放 */
141
+ static ${class_name}_${method.name}_Rsp *${class_name}_${method.name}_Rsp_decode(GVariant *parameters, ${class_name}_${method.name}_Rsp *rsp)
142
+ {${message_decode_func(method.rsp_args, class_name + "_" + method.name + "_Rsp", "rsp")}}
143
+
144
+ /* (服务端)将方法回调函数生成的${class_name}_${method.name}_Rsp响应转换成dbus的响应(GVariant *),无需调用Rsp_free */
145
+ static GVariant *${class_name}_${method.name}_Rsp_encode(${class_name}_${method.name}_Rsp *rsp)
146
+ {${message_encode_func(method.rsp_args, "rsp")}}
147
+
148
+ /* 释放${class_name}_${method.name}_Rsp响应结构体内容 */
149
+ static void ${class_name}_${method.name}_Rsp_free(${class_name}_${method.name}_Rsp *rsp, gboolean free_self)
150
+ {${message_free_func(method.rsp_args, "rsp")}}
151
+ % endfor
152
+
153
+ static ${class_name}_MethodMsgProcesser _${class_name}_method_msg_processer = {
154
+ % for method in intf.methods:
155
+ .${method.name} = {
156
+ .name = "${method.name}",
157
+ .req_signature = "${method.req_signature()}",
158
+ .req_decode = (mdb_message_decode)${class_name}_${method.name}_Req_decode,
159
+ .req_encode = (mdb_message_encode)${class_name}_${method.name}_Req_encode,
160
+ .req_free = (mdb_message_free)${class_name}_${method.name}_Req_free,
161
+ .rsp_signature = "${method.rsp_signature()}",
162
+ .rsp_decode = (mdb_message_decode)${class_name}_${method.name}_Rsp_decode,
163
+ .rsp_encode = (mdb_message_encode)${class_name}_${method.name}_Rsp_encode,
164
+ .rsp_free = (mdb_message_free)${class_name}_${method.name}_Rsp_free,
165
+ },
166
+ % endfor
167
+ .__reserved__ = {
168
+ .name = NULL,
169
+ }
170
+ };
171
+
172
+ ${class_name}_MethodMsgProcesser *${class_name}_method_msg_processer(void)
173
+ {
174
+ return &_${class_name}_method_msg_processer;
175
+ }
176
+
177
+ % for signal in intf.signals:
178
+ /* (客户端)将dbus接收到的消息转换成${class_name}_${signal.name}_Msg消息,配合Msg_free释放 */
179
+ static ${class_name}_${signal.name}_Msg *${class_name}_${signal.name}_Msg_decode(GVariant *parameters, ${class_name}_${signal.name}_Msg *msg)
180
+ {${message_decode_func(signal.args, class_name + "_" + signal.name + "_Msg", "msg")}}
181
+
182
+ /* (服务端)将${class_name}_${signal.name}_Msg转换成dbus需要发送的dbus消息(GVariant *),无需释放 */
183
+ static GVariant *${class_name}_${signal.name}_Msg_encode(${class_name}_${signal.name}_Msg *req)
184
+ {${message_encode_func(signal.args, "req")}}
185
+
186
+ /* 释放${class_name}_${signal.name}_Msg消息内容 */
187
+ static void ${class_name}_${signal.name}_Msg_free(${class_name}_${signal.name}_Msg *msg, gboolean free_self)
188
+ {${message_free_func(signal.args, "msg")}}
189
+
190
+ % endfor
191
+ static ${class_name}_SignalMsgProcesser _${class_name}_signal_msg_processer = {
192
+ % for signal in intf.signals:
193
+ .${signal.name} = {
194
+ .name = "${signal.name}",
195
+ .msg_signature = "${signal.msg_signature()}",
196
+ .msg_decode = (mdb_message_decode)${class_name}_${signal.name}_Msg_decode,
197
+ .msg_encode = (mdb_message_encode)${class_name}_${signal.name}_Msg_encode,
198
+ .msg_free = (mdb_message_free)${class_name}_${signal.name}_Msg_free,
199
+ },
200
+ % endfor
201
+ .__reserved__ = {
202
+ .name = NULL,
203
+ }
204
+ };
205
+
206
+ ${class_name}_SignalMsgProcesser *${class_name}_signal_msg_processer(void)
207
+ {
208
+ return &_${class_name}_signal_msg_processer;
209
+ }
210
+ static ${class_name}_Methods _${class_name}_methods = {
211
+ % for method in intf.methods:
212
+ .${method.name} = {
213
+ .name = "${method.name}",
214
+ .privilege = ${method.privilege},
215
+ .processer = (const MdbMethodMsgProcesser *)&_${class_name}_method_msg_processer.${method.name},
216
+ },
217
+ % endfor
218
+ .__reserved__ = {
219
+ .name = NULL,
220
+ },
221
+ };
222
+
223
+ ${class_name}_Methods *${class_name}_methods(void)
224
+ {
225
+ return &_${class_name}_methods;
226
+ }
227
+
228
+ % endfor
@@ -0,0 +1,128 @@
1
+ #ifndef __${"_".join(xml.name.upper().split(".", -1))}_PUB_H__
2
+ #define __${"_".join(xml.name.upper().split(".", -1))}_PUB_H__
3
+ <% import inflection %>
4
+ #include <glib-2.0/glib.h>
5
+ #include <glib-2.0/gio/gio.h>
6
+ #include "mdb_base.h"
7
+ % for intf in xml.interfaces:
8
+
9
+ /* Interface ${intf.name} codegen start */
10
+ <% class_name = intf.class_name %>\
11
+ ### 开始生成方法的请求体、响应体和处理函数
12
+ % for method in intf.methods:
13
+ /* ${method.name}方法的请求体 */
14
+ typedef struct {
15
+ % for arg in method.req_args:
16
+ % for line in arg.ctype.render_in_args(arg.name, False).split(", ", -1):
17
+ ${line};
18
+ % endfor
19
+ % endfor
20
+ } ${class_name}_${method.name}_Req;
21
+
22
+ /* ${method.name}方法的响应体 */
23
+ typedef struct {
24
+ % for arg in method.rsp_args:
25
+ % for line in arg.ctype.render_in_args(arg.name, False).split(", ", -1):
26
+ ${line};
27
+ % endfor
28
+ % endfor
29
+ } ${class_name}_${method.name}_Rsp;
30
+
31
+ % endfor
32
+ typedef struct {
33
+ % for method in intf.methods:
34
+ struct {
35
+ const gchar *const name;
36
+ const gchar *const req_signature;
37
+ mdb_message_decode req_decode;
38
+ mdb_message_encode req_encode;
39
+ mdb_message_free req_free;
40
+ const gchar *const rsp_signature;
41
+ mdb_message_decode rsp_decode;
42
+ mdb_message_encode rsp_encode;
43
+ mdb_message_free rsp_free;
44
+ } ${method.name} ${method.deprecated_str};
45
+ % endfor
46
+ MdbMethodMsgProcesser __reserved__;
47
+ } ${class_name}_MethodMsgProcesser;
48
+
49
+ typedef struct {
50
+ % for signal in intf.signals:
51
+ struct {
52
+ const gchar *const name;
53
+ const gchar *const msg_signature;
54
+ mdb_message_decode msg_decode;
55
+ mdb_message_encode msg_encode;
56
+ mdb_message_free msg_free;
57
+ } ${signal.name} ${signal.deprecated_str};
58
+ % endfor
59
+ MdbSignalMsgProcesser __reserved__;
60
+ } ${class_name}_SignalMsgProcesser;
61
+ ### 开始生成信号的请求体
62
+ % for signal in intf.signals:
63
+ typedef struct {
64
+ % for arg in signal.args:
65
+ % for line in arg.ctype.render_in_args(arg.name, False).split(", ", -1):
66
+ ${line};
67
+ % endfor
68
+ % endfor
69
+ } ${class_name}_${signal.name}_Msg;
70
+ % endfor
71
+
72
+ typedef struct {
73
+ % for prop in intf.properties:
74
+ MdbProperty ${prop.name} ${prop.deprecated_str};
75
+ % endfor
76
+ MdbProperty __reserved__;
77
+ } ${class_name}_Properties;
78
+
79
+ typedef struct {
80
+ MdbBase _base; /* Notice: property name can't be _base */
81
+ char __reserved__[8]; /* 8bytes reserved space, can't be modified */
82
+ % for prop in intf.properties:
83
+ % if prop.ref_object:
84
+ % if prop.signature.startswith("a"):
85
+ MdbObject **${prop.name} ${prop.deprecated_str};
86
+ % else:
87
+ MdbObject *${prop.name} ${prop.deprecated_str};
88
+ % endif
89
+ % else:
90
+ ${prop.struct_member()}
91
+ % endif
92
+ % endfor
93
+ } ${class_name};
94
+
95
+ % for method in intf.methods:
96
+ % for c in method.comment.texts:
97
+ /* ${c} */
98
+ % endfor
99
+ typedef int (*${class_name}_${method.name}_Method)(const ${class_name} *object, ${class_name}_${method.name}_Req *req, ${class_name}_${method.name}_Rsp *rsp, GError **error);
100
+ % endfor
101
+
102
+ typedef struct {
103
+ % for method in intf.methods:
104
+ struct {
105
+ const char *name;
106
+ guint32 privilege;
107
+ ${class_name}_${method.name}_Method handler;
108
+ const MdbMethodMsgProcesser *processer;
109
+ gpointer opaque;
110
+ } ${method.name};
111
+ % endfor
112
+ MdbMethod __reserved__;
113
+ } ${class_name}_Methods;
114
+
115
+ % for prop in intf.properties:
116
+ #define ${class_name}_${inflection.underscore(prop.name).upper()}_NAME "${prop.name}"
117
+ % endfor
118
+
119
+ #define INTERFACE_${intf.upper_name}_NAME "${intf.name}"
120
+ // internal function, Use PROPERTIES_${intf.upper_name} or PROPERTIES_CLI_${intf.upper_name} only
121
+ const ${class_name}_Properties *${class_name}_properties_internal(void);
122
+ ${class_name}_Methods *${class_name}_methods(void);
123
+ ${class_name}_SignalMsgProcesser *${class_name}_signal_msg_processer(void);
124
+ ${class_name}_MethodMsgProcesser *${class_name}_method_msg_processer(void);
125
+ /* Interface ${intf.name} codegen finish */
126
+ % endfor
127
+
128
+ #endif /* __${"_".join(xml.name.upper().split(".", -1))}_PUB_H__ */
@@ -0,0 +1,104 @@
1
+ #include "mdb_base.h"
2
+ #include "${xml.name}.h"
3
+ #include "public/${xml.name}.h"
4
+
5
+ % for intf in xml.interfaces:
6
+ <%
7
+ class_name = intf.class_name
8
+ method_processer = "_" + class_name + "_method_msg_processer"
9
+ properties = "_" + class_name + "_properties"
10
+ signal_processer = "_" + class_name + "_signal_msg_processer"
11
+ %>\
12
+ static ${class_name}_SignalMsgProcesser *${signal_processer} = NULL;
13
+ static ${class_name}_Properties ${properties} = {NULL};
14
+ static ${class_name}_Methods *_${class_name}_methods = NULL;
15
+
16
+ % for prop in intf.properties:
17
+ % for c in prop.comment.texts:
18
+ /* ${c} */
19
+ % endfor
20
+ % if prop.ref_object:
21
+ % if prop.signature.startswith("a"):
22
+ void ${class_name}_set_${prop.name}(const ${class_name} *object, MdbObject **value)
23
+ {
24
+ mdb_set_array_object(object, &${properties}.${prop.name}, value);
25
+ }
26
+ % else:
27
+ void ${class_name}_set_${prop.name}(const ${class_name} *object, MdbObject *value)
28
+ {
29
+ mdb_set_object(object, &${properties}.${prop.name}, value);
30
+ }
31
+ % endif
32
+ % else:
33
+ void ${class_name}_set_${prop.name}(const ${class_name} *object, ${prop.server_in_args_str()})
34
+ {
35
+ cleanup_unref GVariant *_value = ${prop.ctype.args_write_remote_declear.replace("<arg_name>", "value")};
36
+ (void)mdb_impl.set((MdbObject *)object, NULL, &${properties}.${prop.name}, _value, NULL);
37
+ }
38
+ % endif
39
+
40
+ % endfor
41
+ % for signal in intf.signals:
42
+ /*
43
+ * Signal: ${signal.name}
44
+ % for c in signal.comment.texts:
45
+ * ${c}
46
+ % endfor
47
+ */
48
+ gboolean ${class_name}_${signal.name}_Signal(const ${class_name} *object, const gchar *destination, ${class_name}_${signal.name}_Msg *msg, GError **error)
49
+ {
50
+ return mdb_impl.emit_signal((MdbObject *)object, destination, (const MdbSignalMsgProcesser *)&${signal_processer}->${signal.name}, msg, error);
51
+ }
52
+
53
+ % endfor
54
+ static MdbObject *_${class_name}_create(const gchar *obj_name, gpointer opaque);
55
+ /*
56
+ * interface: ${intf.name}
57
+ % for c in intf.comment.texts:
58
+ * ${c}
59
+ % endfor
60
+ */
61
+ static MdbInterface _${class_name}_interface = {
62
+ .create = _${intf.class_name}_create,
63
+ .is_remote = 0,
64
+ .privilege = ${intf.privilege},
65
+ .name = "${intf.name}",
66
+ .class_name = "${intf.class_name}",
67
+ .properties = (MdbProperty *)&${properties},
68
+ .interface = NULL, /* load from usr/share/dbus-1/interfaces/${xml.name} by mdb_init */
69
+ };
70
+
71
+ MdbObject *_${class_name}_create(const gchar *obj_name, gpointer opaque)
72
+ {
73
+ ${class_name} *obj = g_new0(${class_name}, 1);
74
+ (void)memcpy_s(obj->_base.magic, strlen(MDB_MAGIC) + 1, MDB_MAGIC, strlen(MDB_MAGIC) + 1);
75
+ obj->_base.lock = g_new0(GRecMutex, 1);
76
+ g_rec_mutex_init(obj->_base.lock);
77
+ obj->_base.name = g_strdup(obj_name);
78
+ obj->_base.intf = &_${class_name}_interface;
79
+ obj->_base.opaque = opaque;
80
+ return (MdbObject *)obj;
81
+ }
82
+
83
+ MdbInterface *${class_name}_interface(void)
84
+ {
85
+ return &_${class_name}_interface;
86
+ }
87
+
88
+ ${class_name}_Properties *${class_name}_properties(void)
89
+ {
90
+ return &${properties};
91
+ }
92
+
93
+ static void __attribute__((constructor(CONSTRUCTOR_REGISTER_INTERFACE_PRIORITY))) ${class_name}_register(void)
94
+ {
95
+ ${signal_processer} = ${class_name}_signal_msg_processer();
96
+ _${class_name}_methods = ${class_name}_methods();
97
+ _${class_name}_interface.methods = (MdbMethod *)_${class_name}_methods;
98
+ (void)memcpy_s(&${properties}, sizeof(${properties}), ${intf.class_name}_properties_internal(), sizeof(${properties}));
99
+
100
+ mdb_register_interface(&_${class_name}_interface,
101
+ "${xml.introspect_xml_sha256}",
102
+ "/usr/share/dbus-1/interfaces/${xml.name}.xml");
103
+ }
104
+ % endfor
@@ -0,0 +1,36 @@
1
+ #ifndef __${"_".join(xml.name.upper().split(".", -1))}_H__
2
+ #define __${"_".join(xml.name.upper().split(".", -1))}_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 %>\
10
+
11
+ % for prop in intf.properties:
12
+ % if prop.ref_object:
13
+ % if prop.signature.startswith("a"):
14
+ void ${class_name}_set_${prop.name}(const ${class_name} *object, MdbObject **value);
15
+ % else:
16
+ void ${class_name}_set_${prop.name}(const ${class_name} *object, MdbObject *value);
17
+ % endif
18
+ % else:
19
+ void ${class_name}_set_${prop.name}(const ${class_name} *object, ${prop.server_in_args_str()});
20
+ % endif
21
+ % endfor
22
+
23
+ % for signal in intf.signals:
24
+ % for c in signal.comment.texts:
25
+ /* ${c} */
26
+ % endfor
27
+ gboolean ${class_name}_${signal.name}_Signal(const ${class_name} *object, const gchar *destination, ${class_name}_${signal.name}_Msg *req, GError **error);
28
+ % endfor
29
+
30
+ MdbInterface *${class_name}_interface(void);
31
+ #define INTERFACE_${intf.upper_name} ${class_name}_interface()
32
+ ${class_name}_Properties *${class_name}_properties(void);
33
+ #define PROPERTIES_${intf.upper_name} ${class_name}_properties()
34
+ % endfor
35
+
36
+ #endif /* __${"_".join(xml.name.upper().split(".", -1))}_H__ */
@@ -0,0 +1,7 @@
1
+ keep_simple_control_block_one_line: false
2
+ keep_simple_function_one_line: false
3
+ indent_width: 4
4
+ align_args: false
5
+ align_parameter: false
6
+ column_limit: 120
7
+ double_quote_to_single_quote: true