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.
- bmcgo/__init__.py +12 -0
- bmcgo/bmcgo.py +22 -0
- bmcgo/bmcgo_config.py +176 -0
- bmcgo/cli/__init__.py +10 -0
- bmcgo/cli/cli.py +584 -0
- bmcgo/codegen/__init__.py +14 -0
- bmcgo/codegen/c/__init__.py +9 -0
- bmcgo/codegen/c/annotation.py +52 -0
- bmcgo/codegen/c/argument.py +42 -0
- bmcgo/codegen/c/codegen.py +153 -0
- bmcgo/codegen/c/comment.py +22 -0
- bmcgo/codegen/c/ctype_defination.py +353 -0
- bmcgo/codegen/c/helper.py +87 -0
- bmcgo/codegen/c/interface.py +63 -0
- bmcgo/codegen/c/method.py +82 -0
- bmcgo/codegen/c/property.py +180 -0
- bmcgo/codegen/c/renderer.py +21 -0
- bmcgo/codegen/c/signal.py +64 -0
- bmcgo/codegen/c/template/client.c.mako +145 -0
- bmcgo/codegen/c/template/client.h.mako +36 -0
- bmcgo/codegen/c/template/interface.c.mako +0 -0
- bmcgo/codegen/c/template/interface.introspect.xml.mako +99 -0
- bmcgo/codegen/c/template/micro_component.c.mako +32 -0
- bmcgo/codegen/c/template/public.c.mako +228 -0
- bmcgo/codegen/c/template/public.h.mako +128 -0
- bmcgo/codegen/c/template/server.c.mako +104 -0
- bmcgo/codegen/c/template/server.h.mako +36 -0
- bmcgo/codegen/lua/.lua-format +7 -0
- bmcgo/codegen/lua/Makefile +101 -0
- bmcgo/codegen/lua/__init__.py +9 -0
- bmcgo/codegen/lua/codegen.py +171 -0
- bmcgo/codegen/lua/proto/Makefile +87 -0
- bmcgo/codegen/lua/proto/ipmi_types.proto +17 -0
- bmcgo/codegen/lua/proto/types.proto +52 -0
- bmcgo/codegen/lua/script/check_intfs.py +161 -0
- bmcgo/codegen/lua/script/dto/__init__.py +11 -0
- bmcgo/codegen/lua/script/dto/exception.py +53 -0
- bmcgo/codegen/lua/script/dto/kepler_abstract.py +47 -0
- bmcgo/codegen/lua/script/dto/options.py +33 -0
- bmcgo/codegen/lua/script/dto/print_simple.py +19 -0
- bmcgo/codegen/lua/script/dto/redfish_api.py +241 -0
- bmcgo/codegen/lua/script/dto/url_route.py +195 -0
- bmcgo/codegen/lua/script/gen_db_json.py +444 -0
- bmcgo/codegen/lua/script/gen_depends.py +89 -0
- bmcgo/codegen/lua/script/gen_entry.py +263 -0
- bmcgo/codegen/lua/script/gen_feature_json.py +156 -0
- bmcgo/codegen/lua/script/gen_historical_local_db_json.py +88 -0
- bmcgo/codegen/lua/script/gen_intf_json.py +261 -0
- bmcgo/codegen/lua/script/gen_intf_rpc_json.py +575 -0
- bmcgo/codegen/lua/script/gen_ipmi_json.py +485 -0
- bmcgo/codegen/lua/script/gen_mdb_json.py +117 -0
- bmcgo/codegen/lua/script/gen_rpc_msg_json.py +487 -0
- bmcgo/codegen/lua/script/gen_schema.py +302 -0
- bmcgo/codegen/lua/script/ipmi_types_pb2.py +135 -0
- bmcgo/codegen/lua/script/loader/__init__.py +11 -0
- bmcgo/codegen/lua/script/loader/file_utils.py +33 -0
- bmcgo/codegen/lua/script/loader/kepler_abstract_collect.py +79 -0
- bmcgo/codegen/lua/script/loader/kepler_abstract_loader.py +47 -0
- bmcgo/codegen/lua/script/loader/redfish_loader.py +127 -0
- bmcgo/codegen/lua/script/lua_format.py +62 -0
- bmcgo/codegen/lua/script/mds_util.py +385 -0
- bmcgo/codegen/lua/script/merge_model.py +330 -0
- bmcgo/codegen/lua/script/merge_proto_algo.py +85 -0
- bmcgo/codegen/lua/script/proto_loader.py +47 -0
- bmcgo/codegen/lua/script/proto_plugin.py +140 -0
- bmcgo/codegen/lua/script/redfish_source_tree.py +118 -0
- bmcgo/codegen/lua/script/render_utils/__init__.py +38 -0
- bmcgo/codegen/lua/script/render_utils/base.py +25 -0
- bmcgo/codegen/lua/script/render_utils/client_lua.py +98 -0
- bmcgo/codegen/lua/script/render_utils/controller_lua.py +71 -0
- bmcgo/codegen/lua/script/render_utils/db_lua.py +224 -0
- bmcgo/codegen/lua/script/render_utils/error_lua.py +185 -0
- bmcgo/codegen/lua/script/render_utils/factory.py +52 -0
- bmcgo/codegen/lua/script/render_utils/ipmi_lua.py +159 -0
- bmcgo/codegen/lua/script/render_utils/ipmi_message_lua.py +24 -0
- bmcgo/codegen/lua/script/render_utils/mdb_lua.py +177 -0
- bmcgo/codegen/lua/script/render_utils/mdb_register.py +215 -0
- bmcgo/codegen/lua/script/render_utils/message_lua.py +26 -0
- bmcgo/codegen/lua/script/render_utils/messages_lua.py +156 -0
- bmcgo/codegen/lua/script/render_utils/model_lua.py +485 -0
- bmcgo/codegen/lua/script/render_utils/old_model_lua.py +429 -0
- bmcgo/codegen/lua/script/render_utils/plugin_lua.py +38 -0
- bmcgo/codegen/lua/script/render_utils/redfish_proto.py +86 -0
- bmcgo/codegen/lua/script/render_utils/request_lua.py +76 -0
- bmcgo/codegen/lua/script/render_utils/service_lua.py +130 -0
- bmcgo/codegen/lua/script/render_utils/utils_message_lua.py +125 -0
- bmcgo/codegen/lua/script/render_utils/validate_lua.py +221 -0
- bmcgo/codegen/lua/script/sep_ipmi_message_cmds.py +217 -0
- bmcgo/codegen/lua/script/template.py +166 -0
- bmcgo/codegen/lua/script/types_pb2.py +516 -0
- bmcgo/codegen/lua/script/utils.py +663 -0
- bmcgo/codegen/lua/script/validate.py +80 -0
- bmcgo/codegen/lua/script/yaml_to_json.py +73 -0
- bmcgo/codegen/lua/templates/Makefile +114 -0
- bmcgo/codegen/lua/templates/apps/Makefile +261 -0
- bmcgo/codegen/lua/templates/apps/Makefile.mdb.mk +64 -0
- bmcgo/codegen/lua/templates/apps/app.lua.mako +19 -0
- bmcgo/codegen/lua/templates/apps/class.lua.mako +35 -0
- bmcgo/codegen/lua/templates/apps/client.lua.mako +429 -0
- bmcgo/codegen/lua/templates/apps/controller.lua.mako +276 -0
- bmcgo/codegen/lua/templates/apps/datas.lua.mako +8 -0
- bmcgo/codegen/lua/templates/apps/db.lua.mako +89 -0
- bmcgo/codegen/lua/templates/apps/entry.lua.mako +128 -0
- bmcgo/codegen/lua/templates/apps/feature.lua.mako +37 -0
- bmcgo/codegen/lua/templates/apps/generate_route.mako +25 -0
- bmcgo/codegen/lua/templates/apps/impl_feature.lua.mako +72 -0
- bmcgo/codegen/lua/templates/apps/ipmi.lua.mako +97 -0
- bmcgo/codegen/lua/templates/apps/ipmi_cmd.lua.mako +18 -0
- bmcgo/codegen/lua/templates/apps/ipmi_message.lua.mako +36 -0
- bmcgo/codegen/lua/templates/apps/local_db.lua.mako +263 -0
- bmcgo/codegen/lua/templates/apps/main.lua.mako +25 -0
- bmcgo/codegen/lua/templates/apps/mc.lua.mako +77 -0
- bmcgo/codegen/lua/templates/apps/mdb.lua.mako +45 -0
- bmcgo/codegen/lua/templates/apps/mdb_interface.lua.mako +73 -0
- bmcgo/codegen/lua/templates/apps/message.lua.mako +38 -0
- bmcgo/codegen/lua/templates/apps/model.lua.mako +239 -0
- bmcgo/codegen/lua/templates/apps/orm_classes.lua.mako +16 -0
- bmcgo/codegen/lua/templates/apps/plugin.lua.mako +8 -0
- bmcgo/codegen/lua/templates/apps/redfish.proto.mako +47 -0
- bmcgo/codegen/lua/templates/apps/service.lua.mako +440 -0
- bmcgo/codegen/lua/templates/apps/signal_listen.lua.mako +19 -0
- bmcgo/codegen/lua/templates/apps/utils/default_intf.lua.mako +41 -0
- bmcgo/codegen/lua/templates/apps/utils/enum.mako +10 -0
- bmcgo/codegen/lua/templates/apps/utils/imports.mako +13 -0
- bmcgo/codegen/lua/templates/apps/utils/mdb_intf.lua.mako +25 -0
- bmcgo/codegen/lua/templates/apps/utils/mdb_obj.lua.mako +23 -0
- bmcgo/codegen/lua/templates/apps/utils/message.mako +160 -0
- bmcgo/codegen/lua/templates/apps/utils/request.lua.mako +59 -0
- bmcgo/codegen/lua/templates/apps/utils/validate.mako +83 -0
- bmcgo/codegen/lua/templates/errors.lua.mako +36 -0
- bmcgo/codegen/lua/templates/messages.lua.mako +32 -0
- bmcgo/codegen/lua/templates/new_app/.clang-format.mako +170 -0
- bmcgo/codegen/lua/templates/new_app/.gitignore.mako +26 -0
- bmcgo/codegen/lua/templates/new_app/CHANGELOG.md.mako +0 -0
- bmcgo/codegen/lua/templates/new_app/CMakeLists.txt.mako +29 -0
- bmcgo/codegen/lua/templates/new_app/Makefile.mako +25 -0
- bmcgo/codegen/lua/templates/new_app/README.md.mako +0 -0
- bmcgo/codegen/lua/templates/new_app/conanfile.py.mako +7 -0
- bmcgo/codegen/lua/templates/new_app/config.cfg.mako +6 -0
- bmcgo/codegen/lua/templates/new_app/mds/model.json.mako +3 -0
- bmcgo/codegen/lua/templates/new_app/mds/service.json.mako +21 -0
- bmcgo/codegen/lua/templates/new_app/permissions.ini.mako +16 -0
- bmcgo/codegen/lua/templates/new_app/src/lualib/${project_name}_app.lua.mako +16 -0
- bmcgo/codegen/lua/templates/new_app/src/service/main.lua.mako +25 -0
- bmcgo/codegen/lua/templates/new_app/test/integration/test_${project_name}.conf.mako +9 -0
- bmcgo/codegen/lua/templates/new_app/test/integration/test_${project_name}.lua.mako +47 -0
- bmcgo/codegen/lua/templates/new_app/test/unit/test.lua.mako +23 -0
- bmcgo/codegen/lua/templates/new_app/user_conf/rootfs/etc/systemd/system/${project_name}.service.mako +18 -0
- bmcgo/codegen/lua/templates/new_app/user_conf/rootfs/etc/systemd/system/multi-user.target.wants/${project_name}.service.link +1 -0
- bmcgo/component/__init__.py +10 -0
- bmcgo/component/analysis/analysis.py +183 -0
- bmcgo/component/analysis/build_deps.py +165 -0
- bmcgo/component/analysis/data_deps.py +333 -0
- bmcgo/component/analysis/dep-rules.json +912 -0
- bmcgo/component/analysis/dep_node.py +110 -0
- bmcgo/component/analysis/intf_deps.py +163 -0
- bmcgo/component/analysis/intf_validation.py +254 -0
- bmcgo/component/analysis/rule.py +211 -0
- bmcgo/component/analysis/smc_dfx_whitelist.json +11 -0
- bmcgo/component/analysis/sr_validation.py +391 -0
- bmcgo/component/build.py +222 -0
- bmcgo/component/component_dt_version_parse.py +348 -0
- bmcgo/component/component_helper.py +114 -0
- bmcgo/component/coverage/__init__.py +11 -0
- bmcgo/component/coverage/c_incremental_cov_report.template +53 -0
- bmcgo/component/coverage/incremental_cov.py +464 -0
- bmcgo/component/deploy.py +110 -0
- bmcgo/component/gen.py +169 -0
- bmcgo/component/package_info.py +236 -0
- bmcgo/component/template/conanbase.py.mako +278 -0
- bmcgo/component/template/conanfile.deploy.py.mako +40 -0
- bmcgo/component/test.py +947 -0
- bmcgo/errors.py +119 -0
- bmcgo/frame.py +217 -0
- bmcgo/functional/__init__.py +10 -0
- bmcgo/functional/analysis.py +96 -0
- bmcgo/functional/bmc_studio_action.py +98 -0
- bmcgo/functional/check.py +185 -0
- bmcgo/functional/conan_index_build.py +251 -0
- bmcgo/functional/config.py +332 -0
- bmcgo/functional/csr_build.py +724 -0
- bmcgo/functional/deploy.py +263 -0
- bmcgo/functional/diff.py +235 -0
- bmcgo/functional/fetch.py +235 -0
- bmcgo/functional/full_component.py +391 -0
- bmcgo/functional/maintain.py +381 -0
- bmcgo/functional/new.py +166 -0
- bmcgo/functional/schema_valid.py +111 -0
- bmcgo/functional/simple_sign.py +104 -0
- bmcgo/functional/upgrade.py +78 -0
- bmcgo/ipmigen/__init__.py +13 -0
- bmcgo/ipmigen/ctype_defination.py +82 -0
- bmcgo/ipmigen/ipmigen.py +309 -0
- bmcgo/ipmigen/template/cmd.c.mako +366 -0
- bmcgo/ipmigen/template/ipmi.c.mako +25 -0
- bmcgo/ipmigen/template/ipmi.h.mako +51 -0
- bmcgo/logger.py +176 -0
- bmcgo/misc.py +117 -0
- bmcgo/target/app.yml +17 -0
- bmcgo/target/install_sdk.yml +15 -0
- bmcgo/target/personal.yml +53 -0
- bmcgo/target/publish.yml +45 -0
- bmcgo/tasks/__init__.py +11 -0
- bmcgo/tasks/download_buildtools_hm.py +124 -0
- bmcgo/tasks/misc.py +15 -0
- bmcgo/tasks/task.py +354 -0
- bmcgo/tasks/task_build_conan.py +714 -0
- bmcgo/tasks/task_build_rootfs_img.py +595 -0
- bmcgo/tasks/task_buildgppbin.py +88 -0
- bmcgo/tasks/task_buildhpm_ext4.py +82 -0
- bmcgo/tasks/task_create_interface_config.py +122 -0
- bmcgo/tasks/task_download_buildtools.py +99 -0
- bmcgo/tasks/task_download_dependency.py +72 -0
- bmcgo/tasks/task_hpm_envir_prepare.py +112 -0
- bmcgo/tasks/task_packet_to_supporte.py +87 -0
- bmcgo/tasks/task_prepare.py +105 -0
- bmcgo/tasks/task_sign_and_pack_hpm.py +42 -0
- bmcgo/utils/__init__.py +10 -0
- bmcgo/utils/buffer.py +128 -0
- bmcgo/utils/combine_json_schemas.py +170 -0
- bmcgo/utils/component_post.py +54 -0
- bmcgo/utils/component_version_check.py +86 -0
- bmcgo/utils/config.py +1067 -0
- bmcgo/utils/fetch_component_code.py +232 -0
- bmcgo/utils/install_manager.py +61 -0
- bmcgo/utils/installations/__init__.py +10 -0
- bmcgo/utils/installations/base_installer.py +70 -0
- bmcgo/utils/installations/install_consts.py +30 -0
- bmcgo/utils/installations/install_plans/bingo.yml +11 -0
- bmcgo/utils/installations/install_workflow.py +50 -0
- bmcgo/utils/installations/installers/apt_installer.py +177 -0
- bmcgo/utils/installations/installers/pip_installer.py +46 -0
- bmcgo/utils/installations/version_util.py +100 -0
- bmcgo/utils/mapping_config_patch.py +443 -0
- bmcgo/utils/perf_analysis.py +114 -0
- bmcgo/utils/tools.py +704 -0
- bmcgo/worker.py +417 -0
- openubmc_bingo-0.5.240.dist-info/METADATA +30 -0
- openubmc_bingo-0.5.240.dist-info/RECORD +242 -0
- openubmc_bingo-0.5.240.dist-info/WHEEL +5 -0
- openubmc_bingo-0.5.240.dist-info/entry_points.txt +2 -0
- openubmc_bingo-0.5.240.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env 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
|
+
|
|
13
|
+
import re
|
|
14
|
+
from numbers import Number
|
|
15
|
+
from typeguard import typechecked, check_type, Optional
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@typechecked
|
|
19
|
+
def lens(min_num: Optional[int], max_num: Optional[int]):
|
|
20
|
+
return ("lens", [min_num, max_num])
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@typechecked
|
|
24
|
+
def len_or_none(min_num: Optional[int], max_num: Optional[int]):
|
|
25
|
+
return ("len_or_none", [min_num, max_num])
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@typechecked
|
|
29
|
+
def ranges(min_num: Optional[Number], max_num: Optional[Number]):
|
|
30
|
+
return ("ranges", [min_num, max_num])
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@typechecked
|
|
34
|
+
def range_or_none(min_num: Optional[Number], max_num: Optional[Number]):
|
|
35
|
+
return ("range_or_none", [min_num, max_num])
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@typechecked
|
|
39
|
+
def regex(rx: str):
|
|
40
|
+
try:
|
|
41
|
+
check_type("rx", re.compile(rx), re.Pattern)
|
|
42
|
+
except RuntimeError as ex:
|
|
43
|
+
raise RuntimeError("(regex)正则表达式校验失败: {}".format(rx)) from e
|
|
44
|
+
return ("regex", [rx])
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@typechecked
|
|
48
|
+
def regex_or_none(rx: str):
|
|
49
|
+
try:
|
|
50
|
+
check_type("rx", re.compile(rx), re.Pattern)
|
|
51
|
+
except RuntimeError as ex:
|
|
52
|
+
raise RuntimeError(
|
|
53
|
+
"(regexornone)正则表达式校验失败: {}".format(rx)) from e
|
|
54
|
+
return ("regex_or_none", [rx])
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@typechecked
|
|
58
|
+
def enum(enums: list):
|
|
59
|
+
return ("enum", enums)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@typechecked
|
|
63
|
+
def enum_or_none(enums: list):
|
|
64
|
+
return ("enum_or_none", enums)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
validates = {
|
|
68
|
+
"lens": lens,
|
|
69
|
+
"len_or_none": len_or_none,
|
|
70
|
+
"ranges": ranges,
|
|
71
|
+
"range_or_none": range_or_none,
|
|
72
|
+
"regex": regex,
|
|
73
|
+
"regex_or_none": regex_or_none,
|
|
74
|
+
"enum": enum,
|
|
75
|
+
"enum_or_none": enum_or_none
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def all_validates():
|
|
80
|
+
return validates
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env 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
|
+
|
|
13
|
+
import getopt
|
|
14
|
+
import importlib
|
|
15
|
+
import sys
|
|
16
|
+
import os
|
|
17
|
+
import stat
|
|
18
|
+
import json
|
|
19
|
+
import logging
|
|
20
|
+
import yaml
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def generate(if_name, of_name, base):
|
|
24
|
+
if importlib.util.find_spec('yamlinclude') is not None:
|
|
25
|
+
# 兼容pyyaml-include 1.4.1 版本
|
|
26
|
+
constructor = getattr(importlib.import_module('yamlinclude'), 'YamlIncludeConstructor')
|
|
27
|
+
constructor.add_to_loader_class(loader_class=yaml.FullLoader, base_dir=base)
|
|
28
|
+
else:
|
|
29
|
+
constructor = getattr(importlib.import_module('yaml_include'), 'Constructor')
|
|
30
|
+
yaml.add_constructor("!include", constructor(), yaml.Loader)
|
|
31
|
+
|
|
32
|
+
with open(if_name) as f:
|
|
33
|
+
data = yaml.safe_load(f)
|
|
34
|
+
|
|
35
|
+
ofile = os.fdopen(os.open(of_name, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, stat.S_IWUSR | stat.S_IRUSR), 'w')
|
|
36
|
+
ofile.write(json.dumps(data if data is not None else {}, indent=2))
|
|
37
|
+
ofile.close()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def usage():
|
|
41
|
+
logging.info('gen.py -i <inputfile> -b <base dir> -o <outfile>')
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def main(argv):
|
|
45
|
+
m_input = ''
|
|
46
|
+
output = ''
|
|
47
|
+
base = './datas'
|
|
48
|
+
try:
|
|
49
|
+
opts, _ = getopt.getopt(
|
|
50
|
+
argv, "hi:b:o:", ["help", "input=", "base_dir=", "out="])
|
|
51
|
+
except getopt.GetoptError:
|
|
52
|
+
help()
|
|
53
|
+
return
|
|
54
|
+
for opt, arg in opts:
|
|
55
|
+
if opt in ("-h", "--help"):
|
|
56
|
+
usage()
|
|
57
|
+
return
|
|
58
|
+
elif opt in ("-i", "--input"):
|
|
59
|
+
m_input = arg
|
|
60
|
+
elif opt in ("-b", "--base_dir"):
|
|
61
|
+
base = arg
|
|
62
|
+
elif opt in ("-o", "--out"):
|
|
63
|
+
output = arg
|
|
64
|
+
else:
|
|
65
|
+
raise RuntimeError("不支持的选项: {}".format(opt))
|
|
66
|
+
if not m_input or not output:
|
|
67
|
+
usage()
|
|
68
|
+
return
|
|
69
|
+
generate(m_input, output, base)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if __name__ == "__main__":
|
|
73
|
+
main(sys.argv[1:])
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
GENERATE_OUT_DIR = ${OUT_DIR}/gen
|
|
2
|
+
TEMPLATE_BIN = ${SCRIPT_DIR}/template.py
|
|
3
|
+
LUA_FORMATER = ${SCRIPT_DIR}/lua_format.py
|
|
4
|
+
MESSAGES_DIR := ${BUILD_DIR}/messages
|
|
5
|
+
MESSAGES_OUT_DIR := ${BUILD_DIR}/messages_gen
|
|
6
|
+
|
|
7
|
+
.PHONY: apps errors mdb dft_make debug_make
|
|
8
|
+
|
|
9
|
+
default: all
|
|
10
|
+
|
|
11
|
+
apps:
|
|
12
|
+
@cd apps && make \
|
|
13
|
+
GENERATE_OUT_DIR=${GENERATE_OUT_DIR} \
|
|
14
|
+
PLUGIN_TEMPLATE_DIR=${TEMP_DIR}/plugin \
|
|
15
|
+
SCRIPT_DIR=${SCRIPT_DIR} \
|
|
16
|
+
PROTO_OUT_DIR=${PROTO_OUT_DIR} \
|
|
17
|
+
PROTO_DIR=${PROTO_DIR} \
|
|
18
|
+
PROJECT_NAME=${PROJECT_NAME} \
|
|
19
|
+
VERSION=${VERSION} \
|
|
20
|
+
RESTAPI_DIRS="${RESTAPI_DIRS}" \
|
|
21
|
+
MDS_DIR=${MDS_DIR} \
|
|
22
|
+
TEMP_DIR=${TEMP_DIR} \
|
|
23
|
+
GEN_BAK_DIR=${GEN_BAK_DIR} \
|
|
24
|
+
SERVICE_JSON_PATH=${MDS_DIR}/service.json \
|
|
25
|
+
TYPES_JSON_PATH=${MDS_DIR}/types.json \
|
|
26
|
+
OUT_DIR=${OUT_DIR} \
|
|
27
|
+
GEN_OUT_DIR:=${GENERATE_OUT_DIR}/${PROJECT_NAME}
|
|
28
|
+
|
|
29
|
+
DFT_SERVICE_JSON_EXISTS := $(wildcard ${MDS_DIR}/service.json)
|
|
30
|
+
DFT_MODEL_JSON_EXISTS := $(wildcard ${MDS_DIR}/dft/model.json)
|
|
31
|
+
DFT_NAME = dft
|
|
32
|
+
ifneq ($(and $(DFT_SERVICE_JSON_EXISTS),$(DFT_MODEL_JSON_EXISTS)),)
|
|
33
|
+
dft_make:
|
|
34
|
+
@cd apps && make \
|
|
35
|
+
GENERATE_OUT_DIR=${GENERATE_OUT_DIR}/dft \
|
|
36
|
+
PLUGIN_TEMPLATE_DIR=${TEMP_DIR}/dft/plugin \
|
|
37
|
+
SCRIPT_DIR=${SCRIPT_DIR} \
|
|
38
|
+
PROTO_OUT_DIR=${PROTO_OUT_DIR}/dft \
|
|
39
|
+
PROTO_DIR=${PROTO_DIR} \
|
|
40
|
+
PROJECT_NAME=${DFT_NAME} \
|
|
41
|
+
VERSION=${VERSION} \
|
|
42
|
+
RESTAPI_DIRS="${RESTAPI_DIRS}" \
|
|
43
|
+
MDS_DIR=${MDS_DIR}/dft \
|
|
44
|
+
TEMP_DIR=${TEMP_DIR} \
|
|
45
|
+
GEN_BAK_DIR=${GEN_BAK_DIR} \
|
|
46
|
+
SERVICE_JSON_PATH=${MDS_DIR}/dft/service.json \
|
|
47
|
+
TYPES_JSON_PATH=${MDS_DIR}/dft/types.json \
|
|
48
|
+
OUT_DIR=${OUT_DIR}/dft \
|
|
49
|
+
GEN_OUT_DIR:=${GENERATE_OUT_DIR}/dft
|
|
50
|
+
else
|
|
51
|
+
dft_make:
|
|
52
|
+
endif
|
|
53
|
+
|
|
54
|
+
DEBUG_SERVICE_JSON_EXISTS := $(wildcard ${MDS_DIR}/service.json)
|
|
55
|
+
DEBUG_MODEL_JSON_EXISTS := $(wildcard ${MDS_DIR}/debug/model.json)
|
|
56
|
+
DEBUG_NAME = debug
|
|
57
|
+
ifneq ($(and $(DEBUG_SERVICE_JSON_EXISTS),$(DEBUG_MODEL_JSON_EXISTS)),)
|
|
58
|
+
debug_make:
|
|
59
|
+
@cd apps && make \
|
|
60
|
+
GENERATE_OUT_DIR=${GENERATE_OUT_DIR}/debug \
|
|
61
|
+
PLUGIN_TEMPLATE_DIR=${TEMP_DIR}/debug/plugin \
|
|
62
|
+
SCRIPT_DIR=${SCRIPT_DIR} \
|
|
63
|
+
PROTO_OUT_DIR=${PROTO_OUT_DIR}/debug \
|
|
64
|
+
PROTO_DIR=${PROTO_DIR} \
|
|
65
|
+
PROJECT_NAME=${DEBUG_NAME} \
|
|
66
|
+
VERSION=${VERSION} \
|
|
67
|
+
RESTAPI_DIRS="${RESTAPI_DIRS}" \
|
|
68
|
+
MDS_DIR=${MDS_DIR}/debug \
|
|
69
|
+
TEMP_DIR=${TEMP_DIR} \
|
|
70
|
+
GEN_BAK_DIR=${GEN_BAK_DIR} \
|
|
71
|
+
SERVICE_JSON_PATH=${MDS_DIR}/debug/service.json \
|
|
72
|
+
TYPES_JSON_PATH=${MDS_DIR}/debug/types.json \
|
|
73
|
+
OUT_DIR=${OUT_DIR}/debug \
|
|
74
|
+
GEN_OUT_DIR:=${GENERATE_OUT_DIR}/debug
|
|
75
|
+
else
|
|
76
|
+
debug_make:
|
|
77
|
+
endif
|
|
78
|
+
|
|
79
|
+
ifneq ($(wildcard ${MDS_DIR}/errors.json),)
|
|
80
|
+
${GENERATE_OUT_DIR}/${PROJECT_NAME}/errors.lua:
|
|
81
|
+
${GENERATE_OUT_DIR}/${PROJECT_NAME}/errors.lua: ${TEMPLATE_BIN} errors.lua.mako
|
|
82
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_OUT_DIR} -i ${MDS_DIR}/errors.json -f ${LUA_FORMATER} -t errors.lua.mako -o $@
|
|
83
|
+
errors: ${GENERATE_OUT_DIR}/${PROJECT_NAME}/errors.lua
|
|
84
|
+
else
|
|
85
|
+
errors:
|
|
86
|
+
endif
|
|
87
|
+
|
|
88
|
+
define get_message_files
|
|
89
|
+
$(wildcard $(1)*.json) $(foreach e, $(wildcard $(1)*), $(call get_message_files, $(e)/))
|
|
90
|
+
endef
|
|
91
|
+
|
|
92
|
+
# 遍历读取 messages 目录所有的文件
|
|
93
|
+
MESSAGE_FILES = $(foreach v, $(call get_message_files, ${MESSAGES_DIR}/), $(subst ${MESSAGES_DIR}/,, $(v)))
|
|
94
|
+
MESSAGES = $(foreach v, $(MESSAGE_FILES), $(subst .json,,$(v)))
|
|
95
|
+
|
|
96
|
+
define MAKE_MESSAGE
|
|
97
|
+
$$(MESSAGES_OUT_DIR)/$(1).lua: $${TEMPLATE_BIN} messages.lua.mako
|
|
98
|
+
@mkdir -p $$(dir $$@)
|
|
99
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_OUT_DIR} -i ${MESSAGES_DIR}/$(1).json -f ${LUA_FORMATER} -t messages.lua.mako -o $$@
|
|
100
|
+
endef
|
|
101
|
+
$(foreach v, $(MESSAGES), $(eval $(call MAKE_MESSAGE,$(v))))
|
|
102
|
+
messages: $(foreach v, $(MESSAGES), $(MESSAGES_OUT_DIR)/$(v).lua)
|
|
103
|
+
|
|
104
|
+
mdb:
|
|
105
|
+
@cd apps && make \
|
|
106
|
+
GENERATE_OUT_DIR=${GENERATE_OUT_DIR} \
|
|
107
|
+
SCRIPT_DIR=${SCRIPT_DIR} \
|
|
108
|
+
PROTO_OUT_DIR=${PROTO_OUT_DIR} \
|
|
109
|
+
PROTO_DIR=${PROTO_DIR} \
|
|
110
|
+
PROJECT_NAME=${PROJECT_NAME} \
|
|
111
|
+
VERSION=${VERSION} \
|
|
112
|
+
-f Makefile.mdb.mk
|
|
113
|
+
|
|
114
|
+
all: apps errors dft_make debug_make
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
SCRIPT_DIR = $(PWD)/../../script
|
|
2
|
+
TEMPLATE_BIN = ${SCRIPT_DIR}/template.py
|
|
3
|
+
SEP_IPMI_MESSAGE_CMDS_BIN = ${SCRIPT_DIR}/sep_ipmi_message_cmds.py
|
|
4
|
+
LUA_FORMATER = ${SCRIPT_DIR}/lua_format.py
|
|
5
|
+
MDB_INTF_DIR = ${TEMP_DIR}/opt/bmc/apps/mdb_interface/
|
|
6
|
+
YAML_TO_JSON_BIN = ${SCRIPT_DIR}/yaml_to_json.py
|
|
7
|
+
BAK_LOCAL_DB_DIR = ${GEN_BAK_DIR}/${PROJECT_NAME}
|
|
8
|
+
|
|
9
|
+
define get_proto_files
|
|
10
|
+
$(wildcard $(1)*.proto) $(foreach e, $(wildcard $(1)*), $(call get_proto_files, $(e)/))
|
|
11
|
+
endef
|
|
12
|
+
define get_proto_json_files
|
|
13
|
+
$(wildcard $(1)*.proto.json) $(foreach e, $(wildcard $(1)*), $(call get_proto_json_files, $(e)/))
|
|
14
|
+
endef
|
|
15
|
+
|
|
16
|
+
# 遍历读取当前目录的所有 .yaml 文件
|
|
17
|
+
define get_yaml_files
|
|
18
|
+
$(wildcard $(1)*.yaml) $(foreach e, $(wildcard $(1)*), $(call get_yaml_files, $(e)/))
|
|
19
|
+
endef
|
|
20
|
+
YAML_FILES_TMP = $(subst ${PROTO_DIR}/,,$(filter-out %errors.yaml, $(call get_yaml_files, ${PROTO_DIR}/)))
|
|
21
|
+
YAML_FILES = $(YAML_FILES_TMP:.yaml=)
|
|
22
|
+
|
|
23
|
+
YAML_FILES_CONF_TMP = $(subst ${CONF_DIR}/,,$(filter-out %errors.yaml, $(call get_yaml_files, ${CONF_DIR}/)))
|
|
24
|
+
YAML_FILES_CONF = $(YAML_FILES_CONF_TMP:.yaml=)
|
|
25
|
+
|
|
26
|
+
# 读取 interface 文件
|
|
27
|
+
INTERFACE_FILE = $(subst ${PROTO_OUT_DIR}/,, $(wildcard $(PROTO_OUT_DIR)/interface.proto.json))
|
|
28
|
+
|
|
29
|
+
# 读取 types 目录所有的文件
|
|
30
|
+
MESSAGE_JSON_FILES = $(foreach v, $(call get_proto_files, ${PROTO_DIR}/types/), $(subst ${PROTO_DIR}/,, $(v)))
|
|
31
|
+
MESSAGE_FILES = $(foreach v, $(MESSAGE_JSON_FILES), $(subst .proto,,$(v)))
|
|
32
|
+
|
|
33
|
+
# 读取 database 文件
|
|
34
|
+
DATABASE_FILE = $(subst ${PROTO_OUT_DIR}/,, $(wildcard $(PROTO_OUT_DIR)/database.proto.json))
|
|
35
|
+
|
|
36
|
+
# 遍历读取 routes 目录下的所有文件
|
|
37
|
+
RESTAPI_DIRS = routes
|
|
38
|
+
RESTAPI_JSON_DIR_FILES = $(foreach v, ${RESTAPI_DIRS}, $(call get_proto_json_files, ${PROTO_OUT_DIR}/${v}))
|
|
39
|
+
RESTAPI_JSON_FILES = $(foreach v, ${RESTAPI_JSON_DIR_FILES}, $(subst ${PROTO_OUT_DIR}/,, $(v)))
|
|
40
|
+
RESTAPI_FILES = $(foreach v, $(RESTAPI_JSON_FILES), $(subst .proto.json,,$(v)))
|
|
41
|
+
|
|
42
|
+
# 遍历读取 resource 目录下的所有文件
|
|
43
|
+
RESTAPI_RESOURCE_DIRS = resource
|
|
44
|
+
RESTAPI_RESOURCE_JSON_DIR_FILES = $(foreach v, ${RESTAPI_RESOURCE_DIRS}, $(call get_proto_json_files, ${PROTO_OUT_DIR}/${v}))
|
|
45
|
+
RESTAPI_RESOURCE_JSON_FILES = $(foreach v, ${RESTAPI_RESOURCE_JSON_DIR_FILES}, $(subst ${PROTO_OUT_DIR}/,, $(v)))
|
|
46
|
+
RESTAPI_RESOURCE_FILES = $(foreach v, $(RESTAPI_RESOURCE_JSON_FILES), $(subst .proto.json,,$(v)))
|
|
47
|
+
|
|
48
|
+
# 读取 ipmi 目录所有的文件
|
|
49
|
+
IPMI_JSON_FILES = $(foreach v, $(call get_proto_files, ${PROTO_DIR}/ipmi/), $(subst ${PROTO_DIR}/,, $(v)))
|
|
50
|
+
IPMI_FILES = $(foreach v, $(IPMI_JSON_FILES), $(subst .proto,,$(v)))
|
|
51
|
+
|
|
52
|
+
.PHONY: all service client message database datas datas_conf restapi restapi_resource ipmi model_message_json model_message service_message_json service_message client_messages_json client_messages types_message_json types_message feature_json feature impl_feature
|
|
53
|
+
|
|
54
|
+
default: all
|
|
55
|
+
|
|
56
|
+
define proto_json_to_lua
|
|
57
|
+
$(strip $(subst proto.json,lua,$(1)))
|
|
58
|
+
endef
|
|
59
|
+
|
|
60
|
+
define strip_proto_json
|
|
61
|
+
$(strip $(subst .proto.json,,$(1)))
|
|
62
|
+
endef
|
|
63
|
+
|
|
64
|
+
define MAKE_MESSAGE
|
|
65
|
+
$$(GEN_OUT_DIR)/$(1).lua: ${PROTO_OUT_DIR}/$(1).proto.json $${TEMPLATE_BIN} message.lua.mako utils/message.mako utils/enum.mako
|
|
66
|
+
@mkdir -p $$(dir $$@)
|
|
67
|
+
python3 $${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR} -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/$(1).proto.json -f ${LUA_FORMATER} -t message.lua.mako -o $$@
|
|
68
|
+
endef
|
|
69
|
+
$(foreach v, $(MESSAGE_FILES), $(eval $(call MAKE_MESSAGE,$(v))))
|
|
70
|
+
message: $(foreach v, $(MESSAGE_FILES), $(GEN_OUT_DIR)/$(v).lua)
|
|
71
|
+
|
|
72
|
+
define MAKE_DATAS
|
|
73
|
+
$$(GEN_OUT_DIR)/$(1).lua: ${PROTO_OUT_DIR}/$(1).json $${TEMPLATE_BIN} datas.lua.mako
|
|
74
|
+
@mkdir -p $$(dir $$@)
|
|
75
|
+
python3 $${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR} -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/$(1).json -f ${LUA_FORMATER} -t datas.lua.mako -o $$@
|
|
76
|
+
endef
|
|
77
|
+
$(foreach v, $(YAML_FILES), $(eval $(call MAKE_DATAS,$(v))))
|
|
78
|
+
datas: $(foreach v, $(YAML_FILES), $(GEN_OUT_DIR)/$(v).lua)
|
|
79
|
+
|
|
80
|
+
define MAKE_CONF_DATAS
|
|
81
|
+
$$(GEN_OUT_DIR)/$(1).lua: ${CONF_DIR}/$(1).yaml $${TEMPLATE_BIN} datas.lua.mako
|
|
82
|
+
@mkdir -p $$(dir $$@)
|
|
83
|
+
python3 ${YAML_TO_JSON_BIN} -i ${CONF_DIR}/$(1).yaml -b ${CONF_DIR} -o ${PROTO_OUT_DIR}/$(1).json
|
|
84
|
+
python3 $${TEMPLATE_BIN} -d ${CONF_DIR} -j ${PROTO_OUT_DIR} -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/$(1).json -f ${LUA_FORMATER} -t datas.lua.mako -o $$@
|
|
85
|
+
endef
|
|
86
|
+
$(foreach v, $(YAML_FILES_CONF), $(eval $(call MAKE_CONF_DATAS,$(v))))
|
|
87
|
+
datas_conf: $(foreach v, $(YAML_FILES_CONF), $(GEN_OUT_DIR)/$(v).lua)
|
|
88
|
+
|
|
89
|
+
define MAKE_RESTAPI
|
|
90
|
+
$$(GEN_OUT_DIR)/$(1).lua: ${PROTO_OUT_DIR}/$(1).proto.json $${TEMPLATE_BIN} \
|
|
91
|
+
controller.lua.mako utils/message.mako utils/validate.mako utils/enum.mako utils/imports.mako
|
|
92
|
+
@mkdir -p $$(dir $$@)
|
|
93
|
+
python3 $${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR} -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/$(1).proto.json -f ${LUA_FORMATER} -t controller.lua.mako -o $$@
|
|
94
|
+
endef
|
|
95
|
+
$(foreach v, $(RESTAPI_FILES), $(eval $(call MAKE_RESTAPI,$(v))))
|
|
96
|
+
restapi: $(foreach v, $(RESTAPI_FILES), $(GEN_OUT_DIR)/$(v).lua)
|
|
97
|
+
|
|
98
|
+
$(foreach v, $(RESTAPI_RESOURCE_FILES), $(eval $(call MAKE_RESTAPI,$(v))))
|
|
99
|
+
restapi_resource: $(foreach v, $(RESTAPI_RESOURCE_FILES), $(GEN_OUT_DIR)/$(v).lua)
|
|
100
|
+
|
|
101
|
+
ifneq ($(wildcard ${MDS_DIR}/ipmi.json),)
|
|
102
|
+
${PROTO_OUT_DIR}/ipmi/ipmi.proto.json: ${MDS_DIR}/ipmi.json ${SCRIPT_DIR}/gen_ipmi_json.py
|
|
103
|
+
@mkdir -p ${PROTO_OUT_DIR}/ipmi/
|
|
104
|
+
python3 ${SCRIPT_DIR}/gen_ipmi_json.py -i ${MDS_DIR}/ipmi.json -v ${VERSION} -o $@
|
|
105
|
+
${GEN_OUT_DIR}/ipmi/ipmi.lua: ${PROTO_OUT_DIR}/ipmi/ipmi.proto.json ${TEMPLATE_BIN} ipmi.lua.mako
|
|
106
|
+
@mkdir -p ${GEN_OUT_DIR}/ipmi/
|
|
107
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR} -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/ipmi/ipmi.proto.json -f ${LUA_FORMATER} -v ${VERSION} -t ipmi.lua.mako -o $@
|
|
108
|
+
$(GEN_OUT_DIR)/ipmi/ipmi_message.lua: ${PROTO_OUT_DIR}/ipmi/ipmi.proto.json ${TEMPLATE_BIN} ipmi_message.lua.mako
|
|
109
|
+
@mkdir -p ${GEN_OUT_DIR}/ipmi/
|
|
110
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR} -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/ipmi/ipmi.proto.json -t ipmi_message.lua.mako -o $@
|
|
111
|
+
python3 ${SEP_IPMI_MESSAGE_CMDS_BIN} ${MDS_DIR}/ipmi.json $(GEN_OUT_DIR)/ipmi/ipmi_message.lua $(GEN_OUT_DIR)/ipmi/cmds ${PROJECT_NAME} ${LUA_FORMATER}
|
|
112
|
+
|
|
113
|
+
ipmi: ${GEN_OUT_DIR}/ipmi/ipmi.lua $(GEN_OUT_DIR)/ipmi/ipmi_message.lua
|
|
114
|
+
else
|
|
115
|
+
|
|
116
|
+
define MAKE_IPMI
|
|
117
|
+
$$(GEN_OUT_DIR)/$(1).lua: ${PROTO_OUT_DIR}/$(1).proto.json $${TEMPLATE_BIN} ipmi.lua.mako
|
|
118
|
+
@mkdir -p $$(dir $$@)
|
|
119
|
+
python3 $${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR} -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/$(1).proto.json -f ${LUA_FORMATER} -v ${VERSION} -t ipmi.lua.mako -o $$@
|
|
120
|
+
$$(GEN_OUT_DIR)/$(1)_message.lua: ${PROTO_OUT_DIR}/$(1).proto.json $${TEMPLATE_BIN} ipmi_message.lua.mako
|
|
121
|
+
@mkdir -p $$(dir $$@)
|
|
122
|
+
python3 $${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR} -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/$(1).proto.json -f ${LUA_FORMATER} -t ipmi_message.lua.mako -o $$@
|
|
123
|
+
endef
|
|
124
|
+
|
|
125
|
+
$(foreach v, $(IPMI_FILES), $(eval $(call MAKE_IPMI,$(v))))
|
|
126
|
+
ipmi: $(foreach v, $(IPMI_FILES), $(GEN_OUT_DIR)/$(v).lua $(GEN_OUT_DIR)/$(v)_message.lua)
|
|
127
|
+
|
|
128
|
+
endif
|
|
129
|
+
|
|
130
|
+
${PROTO_OUT_DIR}/_model.json: ${SCRIPT_DIR}/merge_model.py
|
|
131
|
+
python3 ${SCRIPT_DIR}/merge_model.py -i ${MDS_DIR}/model.json -o $@ -d ${MDB_INTF_DIR} -c ${SCRIPT_DIR}/../temp/check_cmd.json
|
|
132
|
+
|
|
133
|
+
${PROTO_OUT_DIR}/service.json: ${PROTO_OUT_DIR}/_model.json ${SCRIPT_DIR}/gen_intf_rpc_json.py
|
|
134
|
+
python3 ${SCRIPT_DIR}/gen_intf_rpc_json.py -i ${PROTO_OUT_DIR}/_model.json -o $@ -s ${SERVICE_JSON_PATH} -p ${MDS_DIR}/ipmi.json
|
|
135
|
+
|
|
136
|
+
${GEN_OUT_DIR}/service.lua: ${PROTO_OUT_DIR}/service.json ${TEMPLATE_BIN} \
|
|
137
|
+
service.lua.mako utils/validate.mako utils/imports.mako service_message message
|
|
138
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -v ${VERSION} -j ${PROTO_OUT_DIR}/json_types/ -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/service.json -f ${LUA_FORMATER} -t service.lua.mako -o $@
|
|
139
|
+
|
|
140
|
+
service:${GEN_OUT_DIR}/service.lua
|
|
141
|
+
|
|
142
|
+
ifneq ($(wildcard ${MDS_DIR}/model.json),)
|
|
143
|
+
${MDS_DIR}/schema.json: ${PROTO_OUT_DIR}/_model.json ${SCRIPT_DIR}/gen_schema.py
|
|
144
|
+
python3 ${SCRIPT_DIR}/gen_schema.py -i ${PROTO_OUT_DIR}/_model.json -n ${PROJECT_NAME} -o $@
|
|
145
|
+
|
|
146
|
+
${PROTO_OUT_DIR}/db_json.json: ${PROTO_OUT_DIR}/_model.json ${SCRIPT_DIR}/gen_db_json.py
|
|
147
|
+
python3 ${SCRIPT_DIR}/gen_historical_local_db_json.py -i ${BAK_LOCAL_DB_DIR}/local_db.lua -o ${PROTO_OUT_DIR}/historical_local_db.json
|
|
148
|
+
python3 ${SCRIPT_DIR}/gen_db_json.py -i ${PROTO_OUT_DIR}/_model.json -m ${PROTO_OUT_DIR}/historical_local_db.json -o $@
|
|
149
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/ -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/db_json.json -f ${LUA_FORMATER} -t db.lua.mako -o ${GEN_OUT_DIR}/db.lua
|
|
150
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/ -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/local_db_json.json -f ${LUA_FORMATER} -t local_db.lua.mako -o ${GEN_OUT_DIR}/local_db.lua
|
|
151
|
+
|
|
152
|
+
ifneq ($(wildcard ${MDS_DIR}/types.json),)
|
|
153
|
+
# types代码生成
|
|
154
|
+
types_message_json: ${TYPES_JSON_PATH} ${SCRIPT_DIR}/gen_rpc_msg_json.py
|
|
155
|
+
mkdir -p ${PROTO_OUT_DIR}/model_types/
|
|
156
|
+
python3 ${SCRIPT_DIR}/gen_rpc_msg_json.py -i ${TYPES_JSON_PATH} -o ${PROTO_OUT_DIR}/model_types/ -d ${MDB_INTF_DIR} -t
|
|
157
|
+
|
|
158
|
+
types_message: types_message_json
|
|
159
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/model_types/ -n ${PROJECT_NAME} \
|
|
160
|
+
-i ${PROTO_OUT_DIR}/model_types/def_types.proto.json -f ${LUA_FORMATER} -t message.lua.mako \
|
|
161
|
+
-o $(call proto_json_to_lua, ${GENERATE_OUT_DIR}/class/types/types.lua);
|
|
162
|
+
|
|
163
|
+
endif
|
|
164
|
+
|
|
165
|
+
# model types代码生成
|
|
166
|
+
model_message_json: ${PROTO_OUT_DIR}/_model.json ${SCRIPT_DIR}/gen_rpc_msg_json.py
|
|
167
|
+
mkdir -p ${PROTO_OUT_DIR}/model_types/
|
|
168
|
+
python3 ${SCRIPT_DIR}/gen_rpc_msg_json.py -i ${PROTO_OUT_DIR}/_model.json -o ${PROTO_OUT_DIR}/model_types/ -d ${MDB_INTF_DIR} -p
|
|
169
|
+
|
|
170
|
+
model_message: model_message_json
|
|
171
|
+
@$(foreach x,$(shell ls $(PROTO_OUT_DIR)/model_types/ -I def_types.proto.json), \
|
|
172
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/model_types/ -n ${PROJECT_NAME} \
|
|
173
|
+
-i ${PROTO_OUT_DIR}/model_types/$x -f ${LUA_FORMATER} -t message.lua.mako \
|
|
174
|
+
-o $(call proto_json_to_lua, ${GENERATE_OUT_DIR}/class/types/$x);)
|
|
175
|
+
|
|
176
|
+
# 服务端代码生成
|
|
177
|
+
service_message_json: ${PROTO_OUT_DIR}/_model.json ${SCRIPT_DIR}/gen_rpc_msg_json.py
|
|
178
|
+
@mkdir -p ${PROTO_OUT_DIR}/json_types/
|
|
179
|
+
python3 ${SCRIPT_DIR}/gen_rpc_msg_json.py -i ${PROTO_OUT_DIR}/_model.json -o ${PROTO_OUT_DIR}/json_types/ -d ${MDB_INTF_DIR} -n ${PROJECT_NAME} -m
|
|
180
|
+
|
|
181
|
+
service_message: service_message_json
|
|
182
|
+
@$(foreach x,$(shell ls $(PROTO_OUT_DIR)/json_types/),\
|
|
183
|
+
python3 ${TEMPLATE_BIN} -v ${VERSION} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/json_types/ -n ${PROJECT_NAME} \
|
|
184
|
+
-i ${PROTO_OUT_DIR}/json_types/$x -f ${LUA_FORMATER} -t message.lua.mako \
|
|
185
|
+
-o $(call proto_json_to_lua, ${GEN_OUT_DIR}/json_types/$x);)
|
|
186
|
+
@$(foreach x,$(shell ls $(PROTO_OUT_DIR)/device_types/),\
|
|
187
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/device_types/ -n ${PROJECT_NAME} \
|
|
188
|
+
-i ${PROTO_OUT_DIR}/device_types/$x -f ${LUA_FORMATER} -t message.lua.mako \
|
|
189
|
+
-o $(call proto_json_to_lua, ${GEN_OUT_DIR}/device_types/$x);)
|
|
190
|
+
|
|
191
|
+
schema: ${MDS_DIR}/schema.json
|
|
192
|
+
database: ${PROTO_OUT_DIR}/db_json.json
|
|
193
|
+
|
|
194
|
+
${GENERATE_OUT_DIR}/class/model.lua: ${PROTO_OUT_DIR}/_model.json ${TEMPLATE_BIN} model.lua.mako
|
|
195
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -v ${VERSION} -j ${PROTO_OUT_DIR} -i ${PROTO_OUT_DIR}/_model.json -f ${LUA_FORMATER} -t model.lua.mako -n ${PROJECT_NAME} -o $@
|
|
196
|
+
|
|
197
|
+
model: ${GENERATE_OUT_DIR}/class/model.lua
|
|
198
|
+
|
|
199
|
+
VER_GE_9 := $(shell [ $(VERSION) -ge 9 ] && echo true)
|
|
200
|
+
ifeq ($(VER_GE_9), true)
|
|
201
|
+
feature_json: ${PROTO_OUT_DIR}/_model.json ${SCRIPT_DIR}/gen_feature_json.py
|
|
202
|
+
mkdir -p ${PROTO_OUT_DIR}/features/
|
|
203
|
+
rm -rf ${PLUGIN_TEMPLATE_DIR}
|
|
204
|
+
python3 ${SCRIPT_DIR}/gen_feature_json.py -i ${PROTO_OUT_DIR}/_model.json -o ${PROTO_OUT_DIR}/features/ -n ${PROJECT_NAME} -f
|
|
205
|
+
|
|
206
|
+
feature: feature_json
|
|
207
|
+
@$(foreach x,$(shell ls $(PROTO_OUT_DIR)/features/),\
|
|
208
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/features/ -n ${PROJECT_NAME} \
|
|
209
|
+
-i ${PROTO_OUT_DIR}/features/$x -f ${LUA_FORMATER} -t feature.lua.mako \
|
|
210
|
+
-o $(call proto_json_to_lua, ${GEN_OUT_DIR}/features/$x);)
|
|
211
|
+
|
|
212
|
+
impl_feature: feature_json
|
|
213
|
+
@$(foreach x,$(shell ls $(PROTO_OUT_DIR)/features/),\
|
|
214
|
+
mkdir -p ${PLUGIN_TEMPLATE_DIR}/$(call strip_proto_json, $x); \
|
|
215
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/features/$(call strip_proto_json, $x) -n ${PROJECT_NAME} \
|
|
216
|
+
-i ${PROTO_OUT_DIR}/features/$x -f ${LUA_FORMATER} -t impl_feature.lua.mako \
|
|
217
|
+
-o $(call proto_json_to_lua, ${PLUGIN_TEMPLATE_DIR}/$(call strip_proto_json, $x)/init.lua);)
|
|
218
|
+
|
|
219
|
+
else
|
|
220
|
+
feature_json:
|
|
221
|
+
feature:
|
|
222
|
+
impl_feature:
|
|
223
|
+
endif
|
|
224
|
+
|
|
225
|
+
orm_classes: ${PROTO_OUT_DIR}/db_json.json
|
|
226
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/ -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/db_json.json -f ${LUA_FORMATER} -t orm_classes.lua.mako -o ${GEN_OUT_DIR}/orm_classes.lua
|
|
227
|
+
else
|
|
228
|
+
schema:
|
|
229
|
+
model:
|
|
230
|
+
database:
|
|
231
|
+
orm_classes:
|
|
232
|
+
feature_json:
|
|
233
|
+
feature:
|
|
234
|
+
impl_feature:
|
|
235
|
+
endif
|
|
236
|
+
|
|
237
|
+
ifneq ($(wildcard ${MDS_DIR}/service.json),)
|
|
238
|
+
|
|
239
|
+
${PROTO_OUT_DIR}/client.json: ${MDS_DIR}/service.json ${SCRIPT_DIR}/gen_intf_rpc_json.py
|
|
240
|
+
python3 ${SCRIPT_DIR}/gen_intf_rpc_json.py -i ${MDS_DIR}/service.json -o $@ -d ${MDB_INTF_DIR} -s ${SERVICE_JSON_PATH} -c
|
|
241
|
+
|
|
242
|
+
# 客户端代码生成
|
|
243
|
+
client_messages_json: ${MDS_DIR}/service.json ${SCRIPT_DIR}/gen_rpc_msg_json.py
|
|
244
|
+
@mkdir -p ${PROTO_OUT_DIR}/json_types/
|
|
245
|
+
python3 ${SCRIPT_DIR}/gen_rpc_msg_json.py -i ${MDS_DIR}/service.json -o ${PROTO_OUT_DIR}/json_types/ -d ${MDB_INTF_DIR} -n ${PROJECT_NAME} -x
|
|
246
|
+
|
|
247
|
+
client_messages: client_messages_json
|
|
248
|
+
@$(foreach x,$(shell ls $(PROTO_OUT_DIR)/json_types/),\
|
|
249
|
+
python3 ${TEMPLATE_BIN} -v ${VERSION} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/json_types/ -n ${PROJECT_NAME} \
|
|
250
|
+
-i ${PROTO_OUT_DIR}/json_types/$x -f ${LUA_FORMATER} -t message.lua.mako \
|
|
251
|
+
-o $(call proto_json_to_lua, ${GEN_OUT_DIR}/json_types/$x);) \
|
|
252
|
+
|
|
253
|
+
${GEN_OUT_DIR}/client.lua : ${PROTO_OUT_DIR}/client.json ${TEMPLATE_BIN} \
|
|
254
|
+
client.lua.mako utils/validate.mako utils/imports.mako client_messages message
|
|
255
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -v ${VERSION} -j ${PROTO_OUT_DIR}/json_types/ -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/client.json -f ${LUA_FORMATER} -t client.lua.mako -o $@
|
|
256
|
+
|
|
257
|
+
client: ${GEN_OUT_DIR}/client.lua
|
|
258
|
+
|
|
259
|
+
endif
|
|
260
|
+
|
|
261
|
+
all: client service message datas datas_conf restapi restapi_resource schema model types_message model_message database ipmi orm_classes feature impl_feature
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
OUT_DIR = $(PWD)/../../build
|
|
2
|
+
PROTO_OUT_DIR = $(OUT_DIR)/proto
|
|
3
|
+
SCRIPT_DIR = $(PWD)/../../script
|
|
4
|
+
TEMPLATE_BIN = ${SCRIPT_DIR}/template.py
|
|
5
|
+
GENERATE_OUT_DIR := ${OUT_DIR}/gen
|
|
6
|
+
PROTO_DIR = $(PWD)/../../proto
|
|
7
|
+
LUA_FORMATER = ${SCRIPT_DIR}/lua_format.py
|
|
8
|
+
JSON_PATH_DIR = ${PROTO_OUT_DIR}/path
|
|
9
|
+
JSON_INTF_DIR = ${PROTO_OUT_DIR}/intf
|
|
10
|
+
|
|
11
|
+
define get_proto_json_files
|
|
12
|
+
$(wildcard $(1)*.proto.json) $(foreach e, $(wildcard $(1)*), $(call get_proto_json_files, $(e)/))
|
|
13
|
+
endef
|
|
14
|
+
|
|
15
|
+
define get_dir_name
|
|
16
|
+
$(shell echo $(dir $(1))|awk -F '/' '{ print $$(NF-1) }')
|
|
17
|
+
endef
|
|
18
|
+
|
|
19
|
+
# 遍历读取 mdb 目录所有的文件
|
|
20
|
+
MDB_JSON_FILES = $(foreach v, $(filter-out %message.proto.json %messages.proto.json %enums.proto.json, $(call get_proto_json_files, ${PROTO_OUT_DIR}/)), $(subst ${PROTO_OUT_DIR}/,, $(v)))
|
|
21
|
+
MDB_FILES = $(foreach v, $(MDB_JSON_FILES), $(subst .proto.json,,$(v)))
|
|
22
|
+
|
|
23
|
+
define get_json_files
|
|
24
|
+
$(wildcard $(1)*.json) $(foreach e, $(wildcard $(1)*), $(call get_json_files, $(e)/))
|
|
25
|
+
endef
|
|
26
|
+
|
|
27
|
+
MDB_PAHT_JSON_FILES = $(foreach v, $(call get_json_files, ${JSON_PATH_DIR}/), $(subst ${JSON_PATH_DIR}/,, $(v)))
|
|
28
|
+
MDB_PATH_FILES = $(foreach v, $(MDB_PAHT_JSON_FILES), $(subst .json,,$(v)))
|
|
29
|
+
MDB_INTF_JSON_FILES = $(foreach v, $(call get_json_files, ${JSON_INTF_DIR}/), $(subst ${JSON_INTF_DIR}/,, $(v)))
|
|
30
|
+
MDB_INTF_FILES = $(foreach v, $(MDB_INTF_JSON_FILES), $(subst .json,,$(v)))
|
|
31
|
+
|
|
32
|
+
.PHONY: all mdb mdb_interface
|
|
33
|
+
|
|
34
|
+
default: all
|
|
35
|
+
|
|
36
|
+
# 实现资源树对象注册代码自动生成
|
|
37
|
+
define MAKE_MDB_INTERFACE_JSON
|
|
38
|
+
$$(GENERATE_OUT_DIR)/$$(subst index,$(call get_dir_name, $(1)),$(1))Interface.lua: ${JSON_INTF_DIR}/$(1).json $${TEMPLATE_BIN} mdb_interface.lua.mako
|
|
39
|
+
@mkdir -p $$(dir $$@)
|
|
40
|
+
python3 $${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${JSON_INTF_DIR} -n ${PROJECT_NAME} -i ${JSON_INTF_DIR}/$(1).json -f ${LUA_FORMATER} -t mdb_interface.lua.mako -o $$@
|
|
41
|
+
endef
|
|
42
|
+
$(foreach v, $(MDB_INTF_FILES), $(eval $(call MAKE_MDB_INTERFACE_JSON,$(v))))
|
|
43
|
+
mdb_interface: $(foreach v, $(MDB_INTF_FILES), $(GENERATE_OUT_DIR)/$(subst index,$(call get_dir_name, $(v)),$(v))Interface.lua)
|
|
44
|
+
|
|
45
|
+
define MAKE_MDB_JSON
|
|
46
|
+
$$(GENERATE_OUT_DIR)/$$(subst index,init,$(1)).lua: ${JSON_PATH_DIR}/$(1).json $${TEMPLATE_BIN} mdb.lua.mako
|
|
47
|
+
@mkdir -p $$(dir $$@)
|
|
48
|
+
python3 $${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${JSON_PATH_DIR} -n ${PROJECT_NAME} -i ${JSON_PATH_DIR}/$(1).json -f ${LUA_FORMATER} -t mdb.lua.mako -o $$@
|
|
49
|
+
endef
|
|
50
|
+
$(foreach v, $(MDB_PATH_FILES), $(eval $(call MAKE_MDB_JSON,$(v))))
|
|
51
|
+
mdb: $(foreach v, $(MDB_PATH_FILES), $(GENERATE_OUT_DIR)/$(subst index,init,$(v)).lua)
|
|
52
|
+
|
|
53
|
+
define MAKE_MESSAGE
|
|
54
|
+
$$(GENERATE_OUT_DIR)/$(1).lua: ${PROTO_OUT_DIR}/$(1).proto.json $${TEMPLATE_BIN} message.lua.mako utils/message.mako utils/enum.mako
|
|
55
|
+
@mkdir -p $$(dir $$@)
|
|
56
|
+
python3 $${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR} -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/$(1).proto.json -f ${LUA_FORMATER} -t message.lua.mako -o $$@
|
|
57
|
+
endef
|
|
58
|
+
MDB_MESSAGE_JSON_FILES = $(foreach v, $(filter %message.proto.json %messages.proto.json %enums.proto.json, $(call get_proto_json_files, ${PROTO_OUT_DIR}/mdb)), $(subst ${PROTO_OUT_DIR}/,, $(v)))
|
|
59
|
+
MDB_MESSAGE_FILES = $(foreach v, $(MDB_MESSAGE_JSON_FILES), $(subst .proto.json,,$(v)))
|
|
60
|
+
$(foreach v, $(MDB_MESSAGE_FILES), $(eval $(call MAKE_MESSAGE,$(v))))
|
|
61
|
+
mdb_message: $(foreach v, $(MDB_MESSAGE_FILES), $(GENERATE_OUT_DIR)/$(v).lua)
|
|
62
|
+
|
|
63
|
+
all: mdb mdb_interface mdb_message
|
|
64
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
${make_header('lua')}
|
|
2
|
+
|
|
3
|
+
local factory = require '${project_name}.factory'
|
|
4
|
+
local class = require 'mc.class'
|
|
5
|
+
local log = require 'mc.logging'
|
|
6
|
+
|
|
7
|
+
local app = class()
|
|
8
|
+
|
|
9
|
+
function app:init()
|
|
10
|
+
|
|
11
|
+
return
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
function app:start()
|
|
15
|
+
|
|
16
|
+
return
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
factory.register_to_factory('app', app)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
${make_header('lua')}
|
|
2
|
+
|
|
3
|
+
local factory = require '${project_name}.factory'
|
|
4
|
+
local class = require 'mc.class'
|
|
5
|
+
|
|
6
|
+
local ${class_name.lower()} = class()
|
|
7
|
+
|
|
8
|
+
% for interface in model[class_name].get('interfaces', []):
|
|
9
|
+
% for method in model[class_name]['interfaces'][interface].get('methods', []):
|
|
10
|
+
<% method_dict = model[class_name]['interfaces'][interface]['methods'][method] %>
|
|
11
|
+
<% intf_name = interface.split('.')[-1] %>
|
|
12
|
+
% if intf_name == 'Default':
|
|
13
|
+
<% pre_intf_name = interface.split('.')[-2] %>
|
|
14
|
+
function ${class_name.lower()}:${class_name}${pre_intf_name}${intf_name}${method}(obj, ctx${''.join([', ' + key for key in method_dict.get('req', dict()).keys()])})
|
|
15
|
+
% else:
|
|
16
|
+
<% unique_intf_name = render_utils.get_unique_intf_name(interface) %>
|
|
17
|
+
function ${class_name.lower()}:${class_name}${unique_intf_name}${method}(obj, ctx${''.join([', ' + key for key in method_dict.get('req', dict()).keys()])})
|
|
18
|
+
% endif
|
|
19
|
+
|
|
20
|
+
return 0
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
% endfor
|
|
24
|
+
%endfor
|
|
25
|
+
function ${class_name.lower()}:on_add_object(class_name, object, position)
|
|
26
|
+
|
|
27
|
+
return
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
function ${class_name.lower()}:on_del_object(class_name, object, position)
|
|
31
|
+
|
|
32
|
+
return
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
factory.register_to_factory('${class_name}', ${class_name.lower()})
|