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,235 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# encoding=utf-8
|
|
3
|
+
# 描述:拉取当前minifest快照下的全量代码
|
|
4
|
+
# Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
5
|
+
# openUBMC is licensed under Mulan PSL v2.
|
|
6
|
+
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
7
|
+
# You may obtain a copy of Mulan PSL v2 at:
|
|
8
|
+
# http://license.coscl.org.cn/MulanPSL2
|
|
9
|
+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
10
|
+
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
11
|
+
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
12
|
+
# See the Mulan PSL v2 for more details.
|
|
13
|
+
import os
|
|
14
|
+
import json
|
|
15
|
+
import re
|
|
16
|
+
import argparse
|
|
17
|
+
from multiprocessing import Pool
|
|
18
|
+
import yaml
|
|
19
|
+
from git import Repo
|
|
20
|
+
from bmcgo.codegen.c.helper import Helper
|
|
21
|
+
from bmcgo.logger import Logger
|
|
22
|
+
from bmcgo.bmcgo_config import BmcgoConfig
|
|
23
|
+
from bmcgo.utils.tools import Tools
|
|
24
|
+
from bmcgo import misc
|
|
25
|
+
from bmcgo.errors import ParameterException
|
|
26
|
+
from bmcgo.utils.fetch_component_code import FetchComponentCode
|
|
27
|
+
|
|
28
|
+
tools = Tools()
|
|
29
|
+
log = Logger()
|
|
30
|
+
|
|
31
|
+
command_info: misc.CommandInfo = misc.CommandInfo(
|
|
32
|
+
group=misc.GRP_MISC,
|
|
33
|
+
name="fetch",
|
|
34
|
+
description=["基于参数指定的单个、部分、全量组件版本拉取源代码"],
|
|
35
|
+
hidden=False
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def if_available(bconfig: BmcgoConfig):
|
|
40
|
+
if bconfig.component:
|
|
41
|
+
return False
|
|
42
|
+
return True
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def process_err_cb(err):
|
|
46
|
+
log.error("进程运行失败, 错误: %s", err)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
_PACKAGE_INFO_HELP = """
|
|
50
|
+
1. 通过组件包名及版本拉取单个组件源码,格式:package/version@user/channel
|
|
51
|
+
2. 通过配置文件拉取部分指定版本的组件源码。支持以下2种配置文件:
|
|
52
|
+
a. yml格式
|
|
53
|
+
dependencies:
|
|
54
|
+
- conan: "package/version@user/channel"
|
|
55
|
+
b. 文本格式
|
|
56
|
+
package/version@user/channel
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class BmcgoCommand:
|
|
61
|
+
conan_package_re = r"^[^@|/]+/[^@|/]+@[^@|/]+/(rc|stable|dev)$"
|
|
62
|
+
|
|
63
|
+
def __init__(self, bconfig: BmcgoConfig, *args):
|
|
64
|
+
self.bconfig = bconfig
|
|
65
|
+
parser = argparse.ArgumentParser(prog="bingo fetch", description="BMC source code fetch", add_help=True,
|
|
66
|
+
formatter_class=argparse.RawTextHelpFormatter)
|
|
67
|
+
if self.bconfig.manifest:
|
|
68
|
+
manifest_exclusive_group = parser.add_mutually_exclusive_group()
|
|
69
|
+
manifest_exclusive_group.add_argument(
|
|
70
|
+
"-b",
|
|
71
|
+
"--board_name",
|
|
72
|
+
help="指定单板获取配套全量源码,可选值为build/product目录下的单板名\n默认:openUBMC",
|
|
73
|
+
default="openUBMC",
|
|
74
|
+
)
|
|
75
|
+
manifest_exclusive_group.add_argument("--manifest_yml", help="指定manifest.yml文件获取源码", default=None)
|
|
76
|
+
manifest_exclusive_group.add_argument("-pi", "--package_info", help=_PACKAGE_INFO_HELP, default=None)
|
|
77
|
+
manifest_exclusive_group.add_argument("-sys", "--subsystem", help="根据平台获取源码,可选平台包括(opensource、public、\
|
|
78
|
+
framework、bmc_core、security、hardware、ras、energy、om、interface、product_extension、customer_extension)", default=None)
|
|
79
|
+
parser.add_argument("--stage", help="包类型,可选值为: rc(预发布包), stable(发布包)\n默认:stable", default='stable')
|
|
80
|
+
parser.add_argument("-a", "--all", help="拉取全部conan代码", action=misc.STORE_TRUE)
|
|
81
|
+
else:
|
|
82
|
+
parser.add_argument("-pi", "--package_info", help=_PACKAGE_INFO_HELP, required=True)
|
|
83
|
+
|
|
84
|
+
parser.add_argument("-p", "--path", help="指定拉取源代码的存放路径\n默认:./source_code", default="./source_code")
|
|
85
|
+
|
|
86
|
+
parser.add_argument("-r", "--remote", help=f"conan仓别名,请检查conan remote list查看已配置的conan仓")
|
|
87
|
+
|
|
88
|
+
parsed_args, _ = parser.parse_known_args(*args)
|
|
89
|
+
self.component_ver = {}
|
|
90
|
+
self.remote = parsed_args.remote
|
|
91
|
+
self.code_path = os.path.realpath(os.path.join(os.getcwd(), parsed_args.path))
|
|
92
|
+
self.package_info = parsed_args.package_info
|
|
93
|
+
if self.bconfig.manifest:
|
|
94
|
+
self.stage = parsed_args.stage
|
|
95
|
+
self.board_name = parsed_args.board_name
|
|
96
|
+
self.manifest_yml_path = parsed_args.manifest_yml
|
|
97
|
+
self.manifest_build_dir = os.path.join(self.bconfig.manifest.folder, "build")
|
|
98
|
+
self.fetch_all = parsed_args.all
|
|
99
|
+
self.subsystem = parsed_args.subsystem
|
|
100
|
+
self.script_dir = os.path.join(os.path.dirname(os.path.split(os.path.realpath(__file__))[0]),
|
|
101
|
+
"component/analysis/dep-rules.json")
|
|
102
|
+
|
|
103
|
+
def get_subsys_file_components(self, stage):
|
|
104
|
+
components = {}
|
|
105
|
+
version_config_dir = os.path.join(self.manifest_build_dir, "subsys", stage)
|
|
106
|
+
for file_name in os.listdir(version_config_dir):
|
|
107
|
+
with open(os.path.join(version_config_dir, file_name)) as f_:
|
|
108
|
+
ver_descp = yaml.safe_load(f_).get(misc.CONAN_DEPDENCIES_KEY)
|
|
109
|
+
for ver in ver_descp:
|
|
110
|
+
components[ver[misc.CONAN].split('/')[0]] = ver[misc.CONAN]
|
|
111
|
+
return components
|
|
112
|
+
|
|
113
|
+
def run(self):
|
|
114
|
+
if self.package_info:
|
|
115
|
+
self.__parse_package_info()
|
|
116
|
+
# 增加判断情况,使用提取的方法和平台组件对比
|
|
117
|
+
elif self.subsystem:
|
|
118
|
+
log.info("====== 开始更新源码, 平台名: %s 代码路径: %s ======",
|
|
119
|
+
self.subsystem, self.code_path)
|
|
120
|
+
|
|
121
|
+
self.__load_config_json(self.stage)
|
|
122
|
+
|
|
123
|
+
else:
|
|
124
|
+
os.chdir(self.manifest_build_dir)
|
|
125
|
+
log.info("====== 开始更新源码, 单板名: %s 代码路径: %s ======",
|
|
126
|
+
self.board_name, self.code_path)
|
|
127
|
+
|
|
128
|
+
self.__update_manifest_path()
|
|
129
|
+
|
|
130
|
+
self.__load_config_yml(self.stage)
|
|
131
|
+
|
|
132
|
+
if not os.path.exists(self.code_path):
|
|
133
|
+
os.makedirs(self.code_path)
|
|
134
|
+
FetchComponentCode(self.component_ver, self.code_path, self.remote).run()
|
|
135
|
+
return 0
|
|
136
|
+
|
|
137
|
+
def __update_manifest_path(self):
|
|
138
|
+
if self.manifest_yml_path:
|
|
139
|
+
return
|
|
140
|
+
for root, _, files in os.walk(os.path.join(self.manifest_build_dir, "product")):
|
|
141
|
+
if "manifest.yml" in files and root.endswith(self.board_name):
|
|
142
|
+
self.manifest_yml_path = os.path.join(root, "manifest.yml")
|
|
143
|
+
return
|
|
144
|
+
|
|
145
|
+
raise RuntimeError("在单板配置目录下, 无法找到 manifest.yml 文件")
|
|
146
|
+
|
|
147
|
+
def __update_component_ver(self, comp, subsys_file_components):
|
|
148
|
+
component = comp if self.subsystem else comp[misc.CONAN]
|
|
149
|
+
# 此处判断manifest.yml中组件是否已指定版本
|
|
150
|
+
is_comfirm = component.find("/") > 0
|
|
151
|
+
component_name = component.split('/')[0]
|
|
152
|
+
if not self.fetch_all and component_name in self.bconfig.conan_blacklist:
|
|
153
|
+
return
|
|
154
|
+
if is_comfirm:
|
|
155
|
+
self.component_ver[component_name] = comp[misc.CONAN]
|
|
156
|
+
else:
|
|
157
|
+
self.component_ver[component_name] = subsys_file_components[component_name]
|
|
158
|
+
self._fix_com_package(self.component_ver, component_name)
|
|
159
|
+
|
|
160
|
+
def _fix_com_package(self, com_package, index):
|
|
161
|
+
com_package_split = com_package[index].split("/")
|
|
162
|
+
if len(com_package_split) == 2:
|
|
163
|
+
stage = self.stage
|
|
164
|
+
if stage != misc.StageEnum.STAGE_STABLE.value:
|
|
165
|
+
stage = misc.StageEnum.STAGE_RC.value
|
|
166
|
+
user_channel = f"@{tools.conan_user}/{stage}"
|
|
167
|
+
com_package[index] += user_channel
|
|
168
|
+
|
|
169
|
+
def __load_config_json(self, stage):
|
|
170
|
+
if not os.path.exists(self.script_dir):
|
|
171
|
+
raise RuntimeError("json 文件不存在")
|
|
172
|
+
with open(self.script_dir, 'r') as f_:
|
|
173
|
+
subsystems = json.load(f_)["Subsystems"]
|
|
174
|
+
if self.subsystem not in subsystems:
|
|
175
|
+
raise AttributeError(f"平台 {self.subsystem} 不存在于 {subsystems.keys()}")
|
|
176
|
+
subsys_file_components = self.get_subsys_file_components(self.manifest_build_dir, stage)
|
|
177
|
+
for items in subsystems[self.subsystem]:
|
|
178
|
+
if items == "Level":
|
|
179
|
+
continue
|
|
180
|
+
components = subsystems[self.subsystem].get(items, [])
|
|
181
|
+
for component in components:
|
|
182
|
+
self.__update_component_ver(component, subsys_file_components)
|
|
183
|
+
if len(self.component_ver) == 0:
|
|
184
|
+
raise RuntimeError(f"平台 {self.subsystem} 没有任何组件信息")
|
|
185
|
+
|
|
186
|
+
def __load_config_yml(self, stage):
|
|
187
|
+
if not os.path.exists(self.manifest_yml_path):
|
|
188
|
+
raise RuntimeError("manifest 文件不存在")
|
|
189
|
+
components = tools.get_manifest_dependencies(
|
|
190
|
+
self.manifest_build_dir, self.manifest_yml_path, self.stage, self.remote
|
|
191
|
+
)
|
|
192
|
+
subsys_file_components = self.get_subsys_file_components(stage)
|
|
193
|
+
for component in components:
|
|
194
|
+
self.__update_component_ver(component, subsys_file_components)
|
|
195
|
+
|
|
196
|
+
def __load_version_yml(self, package_info):
|
|
197
|
+
try:
|
|
198
|
+
with open(package_info) as f_:
|
|
199
|
+
ver_descp = yaml.safe_load(f_).get(misc.CONAN_DEPDENCIES_KEY)
|
|
200
|
+
for v in ver_descp:
|
|
201
|
+
ver = v[misc.CONAN]
|
|
202
|
+
comp_name = ver.split('/')[0]
|
|
203
|
+
self.component_ver[comp_name] = ver
|
|
204
|
+
return True
|
|
205
|
+
except Exception as exp:
|
|
206
|
+
log.warning("尝试以yml格式解析配置文件(%s)失败, 错误信息: %s", self.package_info, exp)
|
|
207
|
+
return False
|
|
208
|
+
|
|
209
|
+
def __load_version_file(self, package_info):
|
|
210
|
+
with open(package_info, encoding="UTF-8") as fp:
|
|
211
|
+
for line_num, line in enumerate(fp.readlines()):
|
|
212
|
+
package = line.strip()
|
|
213
|
+
if re.match(self.conan_package_re, package):
|
|
214
|
+
comp_name = package.split('/')[0]
|
|
215
|
+
self.component_ver[comp_name] = package
|
|
216
|
+
elif package != "":
|
|
217
|
+
log.error(f"第{line_num + 1}行不满足conan包格式要求, 跳过: {package}")
|
|
218
|
+
|
|
219
|
+
def __parse_package_info(self):
|
|
220
|
+
log.info("====== 开始获取组件包信息: %s ======", self.package_info)
|
|
221
|
+
package_match = re.match(self.conan_package_re, self.package_info)
|
|
222
|
+
package_info_path = os.path.relpath(os.path.join(self.bconfig.cwd, self.package_info))
|
|
223
|
+
if not (package_match or os.path.isfile(package_info_path)):
|
|
224
|
+
raise ParameterException(f"{self.package_info}文件不存在 或 不满足conan包格式要求。")
|
|
225
|
+
|
|
226
|
+
if package_match:
|
|
227
|
+
comp_name = self.package_info.split('/')[0]
|
|
228
|
+
self.component_ver[comp_name] = self.package_info
|
|
229
|
+
return
|
|
230
|
+
|
|
231
|
+
log.info("按照 yml 格式解析配置文件.")
|
|
232
|
+
ret = self.__load_version_yml(package_info_path)
|
|
233
|
+
if not ret:
|
|
234
|
+
log.info("按照 /etc/package_info 格式解析配置文件.")
|
|
235
|
+
self.__load_version_file(package_info_path)
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# coding: utf-8
|
|
3
|
+
# Copyright (c) 2025 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
|
+
import os
|
|
13
|
+
import itertools
|
|
14
|
+
import json
|
|
15
|
+
import sys
|
|
16
|
+
import re
|
|
17
|
+
import stat
|
|
18
|
+
import shutil
|
|
19
|
+
import argparse
|
|
20
|
+
import importlib
|
|
21
|
+
import inspect
|
|
22
|
+
import functools
|
|
23
|
+
import random
|
|
24
|
+
from concurrent.futures import ProcessPoolExecutor, Future
|
|
25
|
+
from typing import List
|
|
26
|
+
|
|
27
|
+
from conans.model.manifest import FileTreeManifest
|
|
28
|
+
import yaml
|
|
29
|
+
|
|
30
|
+
from bmcgo import misc
|
|
31
|
+
from bmcgo.utils.fetch_component_code import FetchComponentCode
|
|
32
|
+
from bmcgo.component.component_dt_version_parse import ComponentDtVersionParse
|
|
33
|
+
from bmcgo.component.component_helper import (
|
|
34
|
+
ComponentHelper,
|
|
35
|
+
STAGE_DEV,
|
|
36
|
+
STAGE_STABLE,
|
|
37
|
+
STAGE_RC,
|
|
38
|
+
BUILD_TYPE_DT,
|
|
39
|
+
BUILD_TYPE_DEBUG,
|
|
40
|
+
BUILD_TYPE_RELEASE,
|
|
41
|
+
)
|
|
42
|
+
from bmcgo.misc import CommandInfo, CONAN_USER
|
|
43
|
+
from bmcgo.utils.tools import Tools
|
|
44
|
+
from bmcgo.bmcgo_config import BmcgoConfig
|
|
45
|
+
from bmcgo.component.build import BuildComp
|
|
46
|
+
from bmcgo.errors import BmcGoException
|
|
47
|
+
from bmcgo.tasks.misc import MODULE_SYMVERS, SDK_PATH
|
|
48
|
+
|
|
49
|
+
tool = Tools("build_full")
|
|
50
|
+
log = tool.log
|
|
51
|
+
command_info: CommandInfo = CommandInfo(
|
|
52
|
+
group="Misc commands",
|
|
53
|
+
name="build_full",
|
|
54
|
+
description=["获取组件源码并构建出组件的全量二进制"],
|
|
55
|
+
hidden=True,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def if_available(bconfig: BmcgoConfig):
|
|
60
|
+
if bconfig.conan_index:
|
|
61
|
+
return False
|
|
62
|
+
return True
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class BuildComponent:
|
|
66
|
+
def __init__(
|
|
67
|
+
self,
|
|
68
|
+
comp,
|
|
69
|
+
profile: str,
|
|
70
|
+
stage: str,
|
|
71
|
+
build_type: str,
|
|
72
|
+
options: dict,
|
|
73
|
+
code_path: str,
|
|
74
|
+
remote=misc.CONAN_REPO,
|
|
75
|
+
service_json="mds/service.json",
|
|
76
|
+
upload=False,
|
|
77
|
+
):
|
|
78
|
+
self.bconfig = BmcgoConfig()
|
|
79
|
+
self.comp_name, self.comp_version, *_ = re.split("@|/", comp)
|
|
80
|
+
self.profile = profile
|
|
81
|
+
self.stage = stage
|
|
82
|
+
self.build_type = build_type
|
|
83
|
+
self.options = options
|
|
84
|
+
self.code_path = code_path
|
|
85
|
+
self.option_cmd = ""
|
|
86
|
+
self.remote = remote
|
|
87
|
+
self.upload = upload
|
|
88
|
+
self.service_json = service_json
|
|
89
|
+
|
|
90
|
+
def run(self):
|
|
91
|
+
os.chdir(os.path.join(self.code_path, self.comp_name))
|
|
92
|
+
for key, value in self.options.items():
|
|
93
|
+
self.option_cmd = self.option_cmd + f" -o {self.comp_name}:{key}={value}"
|
|
94
|
+
command = (
|
|
95
|
+
f"--remote {self.remote} -nc --stage {self.stage} --build_type {self.build_type.lower()}"
|
|
96
|
+
f" --profile {self.profile} {self.option_cmd}"
|
|
97
|
+
)
|
|
98
|
+
log.info(f"执行构建命令bingo build {command}")
|
|
99
|
+
args = command.split()
|
|
100
|
+
build = BuildComp(self.bconfig, args, service_json=self.service_json)
|
|
101
|
+
# 恢复工作区为clean状态, 保证conan export时scm信息准确
|
|
102
|
+
tool.run_command("git restore .")
|
|
103
|
+
tool.run_command("git clean -fd")
|
|
104
|
+
build.run()
|
|
105
|
+
log.success("组件{}构建成功".format(self.comp_name))
|
|
106
|
+
if self.upload:
|
|
107
|
+
log.info("上传组件包至conan仓......")
|
|
108
|
+
tool.run_command(f'conan upload "*" --all --remote {self.remote} -c --no-overwrite')
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class BmcgoCommand:
|
|
112
|
+
def __init__(self, bconfig: BmcgoConfig, *args):
|
|
113
|
+
parser = argparse.ArgumentParser(description="Fetch component source code and build all binaries.")
|
|
114
|
+
parser.add_argument("-comp", "--component", help="软件包名, 示例: oms/1.2.6", required=True)
|
|
115
|
+
parser.add_argument("-r", "--remote", help="远端仓库名称", default=misc.CONAN_REPO)
|
|
116
|
+
parser.add_argument(
|
|
117
|
+
"-p",
|
|
118
|
+
"--path",
|
|
119
|
+
help="指定拉取源代码的存放路径\n默认:./temp/source_code",
|
|
120
|
+
default="./temp/source_code",
|
|
121
|
+
)
|
|
122
|
+
parser.add_argument("-pi", "--package_info", help="package_info文件路径", required=True)
|
|
123
|
+
parser.add_argument("-u", "--upload", action=misc.STORE_TRUE, help="上传组件包到conan仓")
|
|
124
|
+
parser.add_argument("--config_file", help="全量二进制配置文件")
|
|
125
|
+
parser.add_argument("--skip_fetch", action=misc.STORE_TRUE, help="跳过fetch")
|
|
126
|
+
parser.add_argument("--build_type", action="append", help="构建类型")
|
|
127
|
+
|
|
128
|
+
parsed_args, _ = parser.parse_known_args(*args)
|
|
129
|
+
self.bconfig = bconfig
|
|
130
|
+
self.comp = parsed_args.component
|
|
131
|
+
self.comp_name, self.comp_version, *_ = re.split("@|/", self.comp)
|
|
132
|
+
self.code_path = os.path.realpath(os.path.join(bconfig.cwd, parsed_args.path))
|
|
133
|
+
self.comp_path = os.path.join(self.code_path, self.comp_name)
|
|
134
|
+
self.remote = parsed_args.remote
|
|
135
|
+
self.package_info_path = os.path.realpath(os.path.join(bconfig.cwd, parsed_args.package_info))
|
|
136
|
+
self.upload = parsed_args.upload
|
|
137
|
+
self.config_file = parsed_args.config_file
|
|
138
|
+
self.skip_fetch = parsed_args.skip_fetch
|
|
139
|
+
self.profile_list = ["profile.dt.ini", "profile.luajit.ini"]
|
|
140
|
+
self.stage_list = [STAGE_STABLE]
|
|
141
|
+
self.built_type_list = [BUILD_TYPE_DT, BUILD_TYPE_DEBUG, BUILD_TYPE_RELEASE]
|
|
142
|
+
if parsed_args.build_type:
|
|
143
|
+
self.built_type_list = parsed_args.build_type
|
|
144
|
+
self.options_dict = {}
|
|
145
|
+
|
|
146
|
+
@staticmethod
|
|
147
|
+
def get_conan_file_cls(comp_path):
|
|
148
|
+
os.chdir(comp_path)
|
|
149
|
+
# 先生成conanbase.py文件
|
|
150
|
+
BuildComp(BmcgoConfig(), gen_conanbase=True)
|
|
151
|
+
# 去除ConanFile, Conanbase继承, 用于方便区分
|
|
152
|
+
tool.run_command("sed -i s/(ConanFile)/()/ conanbase.py")
|
|
153
|
+
tool.run_command("sed -i s/(ConanBase)/()/ conanfile.py")
|
|
154
|
+
# 动态导入conanfile.py模块
|
|
155
|
+
sys.path.append(comp_path)
|
|
156
|
+
conan_file_module = importlib.import_module("conanfile")
|
|
157
|
+
conan_base_cls = conan_file_module.ConanBase
|
|
158
|
+
cls_in_module = [member[1] for member in inspect.getmembers(conan_file_module) if inspect.isclass(member[1])]
|
|
159
|
+
|
|
160
|
+
# 删除导入的conanbase和conanfile, 保证后续组件的导入是最新的conanbase和conanfile模块
|
|
161
|
+
sys.modules.pop("conanbase")
|
|
162
|
+
sys.modules.pop("conanfile")
|
|
163
|
+
sys.path.pop()
|
|
164
|
+
# 清空编译的conanbase缓存, 防止后续构建时使用了缓存的conanbase(未继承ConanFile版本)
|
|
165
|
+
tool.run_command("rm -rf __pycache__")
|
|
166
|
+
# 恢复工作区为clean状态, 保证conan export时scm信息准确
|
|
167
|
+
tool.run_command("git restore .")
|
|
168
|
+
tool.run_command("git clean -fd")
|
|
169
|
+
|
|
170
|
+
conan_file_cls = None
|
|
171
|
+
for conan_cls in cls_in_module:
|
|
172
|
+
if conan_cls != conan_base_cls:
|
|
173
|
+
conan_file_cls = conan_cls
|
|
174
|
+
break
|
|
175
|
+
if hasattr(conan_file_cls, "options"):
|
|
176
|
+
return conan_file_cls
|
|
177
|
+
|
|
178
|
+
return conan_base_cls
|
|
179
|
+
|
|
180
|
+
@staticmethod
|
|
181
|
+
def get_build_options(conan_file_cls, config_file):
|
|
182
|
+
options_dict = {}
|
|
183
|
+
if hasattr(conan_file_cls, "options"):
|
|
184
|
+
options_dict = conan_file_cls.options
|
|
185
|
+
|
|
186
|
+
# 添加module_symver选项
|
|
187
|
+
module_symvers_path = os.path.join(SDK_PATH, MODULE_SYMVERS)
|
|
188
|
+
module_symver_key, module_symver_value = tool.get_module_symver_option(module_symvers_path)
|
|
189
|
+
if module_symver_key in options_dict:
|
|
190
|
+
options_dict[module_symver_key] = [module_symver_value]
|
|
191
|
+
if config_file:
|
|
192
|
+
with open(config_file, "r") as yaml_fp:
|
|
193
|
+
obj = yaml.safe_load(yaml_fp)
|
|
194
|
+
BmcgoCommand.exclude_com_options(conan_file_cls, obj, options_dict)
|
|
195
|
+
BmcgoCommand.exclude_all_options(obj, options_dict)
|
|
196
|
+
tool.log.info(f"组件全量options选项为: {options_dict}")
|
|
197
|
+
return options_dict
|
|
198
|
+
|
|
199
|
+
@staticmethod
|
|
200
|
+
def exclude_com_options(conan_file_cls, obj, options_dict):
|
|
201
|
+
if conan_file_cls.name in obj:
|
|
202
|
+
for exclude_option in obj[conan_file_cls.name]["exclude_options"]:
|
|
203
|
+
del options_dict[exclude_option]
|
|
204
|
+
|
|
205
|
+
@staticmethod
|
|
206
|
+
def exclude_all_options(obj, options_dict):
|
|
207
|
+
if obj.get("all", {}):
|
|
208
|
+
for exclude_option in obj["all"]["exclude_options"]:
|
|
209
|
+
if exclude_option in options_dict:
|
|
210
|
+
del options_dict[exclude_option]
|
|
211
|
+
|
|
212
|
+
@staticmethod
|
|
213
|
+
def copy_stable2rc(comp: str):
|
|
214
|
+
com_folder = os.path.join(tool.conan_data, comp)
|
|
215
|
+
for version in os.listdir(com_folder):
|
|
216
|
+
pkg = f"{comp}/{version}@{CONAN_USER}/{STAGE_STABLE}"
|
|
217
|
+
if not os.path.exists(os.path.join(tool.conan_data, pkg.replace("@", "/"))):
|
|
218
|
+
continue
|
|
219
|
+
tool.run_command(f"conan copy {pkg} {CONAN_USER}.release/{STAGE_RC} --all --force")
|
|
220
|
+
|
|
221
|
+
@staticmethod
|
|
222
|
+
def copy_all_stable2rc(tools: Tools):
|
|
223
|
+
comps = os.listdir(tools.conan_data)
|
|
224
|
+
tools.log.info(f"创建多进程获取复制conan data下所有组件的stable到rc版本...")
|
|
225
|
+
pool = ProcessPoolExecutor()
|
|
226
|
+
future_tasks: List[Future] = []
|
|
227
|
+
for comp in comps:
|
|
228
|
+
task = pool.submit(BmcgoCommand.copy_stable2rc, comp)
|
|
229
|
+
future_tasks.append(task)
|
|
230
|
+
|
|
231
|
+
pool.shutdown()
|
|
232
|
+
for task in future_tasks:
|
|
233
|
+
task_exception = task.exception()
|
|
234
|
+
if task_exception is not None:
|
|
235
|
+
raise task_exception
|
|
236
|
+
|
|
237
|
+
@staticmethod
|
|
238
|
+
def _replace_dev_version(temp_service_json: str):
|
|
239
|
+
version_parse = ComponentDtVersionParse(serv_file=temp_service_json)
|
|
240
|
+
for pkg in version_parse.conan_list:
|
|
241
|
+
component = pkg[misc.CONAN]
|
|
242
|
+
if "@" not in component:
|
|
243
|
+
continue
|
|
244
|
+
comp_version, user_channel = component.split("@")
|
|
245
|
+
if user_channel.endswith(STAGE_DEV):
|
|
246
|
+
pkg[misc.CONAN] = f"{comp_version}{ComponentHelper.get_user_channel(STAGE_DEV)}"
|
|
247
|
+
|
|
248
|
+
version_parse.write_to_serv_file()
|
|
249
|
+
|
|
250
|
+
@functools.cached_property
|
|
251
|
+
def _full_reference(self) -> str:
|
|
252
|
+
comp_pkg = self.comp if "@" in self.comp else f"{self.comp}@{CONAN_USER}.release/{STAGE_STABLE}"
|
|
253
|
+
return comp_pkg
|
|
254
|
+
|
|
255
|
+
@functools.cached_property
|
|
256
|
+
def _is_self_developed(self) -> bool:
|
|
257
|
+
tool.run_command(f"conan download {self._full_reference} --recipe -r {self.remote}")
|
|
258
|
+
comp_package_path = os.path.join(tool.conan_data, self.comp_name)
|
|
259
|
+
ret = tool.run_command(f"find {comp_package_path} -name 'conanbase.py'", capture_output=True)
|
|
260
|
+
return bool(ret.stdout)
|
|
261
|
+
|
|
262
|
+
def fetch_code(self):
|
|
263
|
+
conan_path = os.path.join(tool.conan_data, self.comp_name)
|
|
264
|
+
if os.path.isdir(conan_path):
|
|
265
|
+
shutil.rmtree(conan_path)
|
|
266
|
+
if os.path.isdir(self.code_path):
|
|
267
|
+
shutil.rmtree(self.code_path)
|
|
268
|
+
os.makedirs(self.code_path)
|
|
269
|
+
packages = {self.comp_name: self._full_reference}
|
|
270
|
+
FetchComponentCode(packages, self.code_path, self.remote).run()
|
|
271
|
+
|
|
272
|
+
def revise_comp_version(self, service_json: str):
|
|
273
|
+
"""修订version为当前指定的版本, 以支持x.y.z-build.x格式的补丁版本
|
|
274
|
+
|
|
275
|
+
Args:
|
|
276
|
+
service_json (str): service.json文件路径
|
|
277
|
+
"""
|
|
278
|
+
os.chdir(self.comp_path)
|
|
279
|
+
file_open_mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
|
|
280
|
+
with os.fdopen(os.open(service_json, flags=os.O_RDWR, mode=file_open_mode), "w+") as file_handler:
|
|
281
|
+
service_json_data = json.load(file_handler)
|
|
282
|
+
service_json_data["version"] = self.comp_version
|
|
283
|
+
file_handler.seek(0)
|
|
284
|
+
file_handler.truncate()
|
|
285
|
+
json.dump(service_json_data, file_handler, indent=4, ensure_ascii=False)
|
|
286
|
+
file_handler.close()
|
|
287
|
+
|
|
288
|
+
def revise_service_dependencies(self, service_json: str):
|
|
289
|
+
"""修订build/test的依赖组件的版本为patch范围版本
|
|
290
|
+
|
|
291
|
+
Args:
|
|
292
|
+
service_json (str): service.json文件路径
|
|
293
|
+
"""
|
|
294
|
+
os.chdir(self.comp_path)
|
|
295
|
+
with open(service_json, "r", encoding="UTF-8") as file_handler:
|
|
296
|
+
service_json_data = json.load(file_handler)
|
|
297
|
+
dependencies = service_json_data.get(misc.CONAN_DEPDENCIES_KEY, {})
|
|
298
|
+
if not dependencies:
|
|
299
|
+
# service.json中没有依赖,可直接构建
|
|
300
|
+
return
|
|
301
|
+
ComponentDtVersionParse(serv_file=service_json).manifest_version_revise(
|
|
302
|
+
self.package_info_path, use_patch_range=True
|
|
303
|
+
)
|
|
304
|
+
self._replace_dev_version(service_json)
|
|
305
|
+
|
|
306
|
+
def run(self):
|
|
307
|
+
if not self.skip_fetch:
|
|
308
|
+
if not self._is_self_developed:
|
|
309
|
+
tool.log.warning(f"非自研组件{self.comp}不支持该功能。")
|
|
310
|
+
return
|
|
311
|
+
self.fetch_code()
|
|
312
|
+
self._package_docs_from_source()
|
|
313
|
+
conan_file_cls = self.get_conan_file_cls(self.comp_path)
|
|
314
|
+
self.options_dict = self.get_build_options(conan_file_cls, self.config_file)
|
|
315
|
+
service_json = self._create_temp_service_json()
|
|
316
|
+
self.revise_comp_version(service_json)
|
|
317
|
+
self.revise_service_dependencies(service_json)
|
|
318
|
+
self.build_all_packages(service_json)
|
|
319
|
+
self.copy_all_stable2rc(tool)
|
|
320
|
+
if self.upload:
|
|
321
|
+
log.info("上传组件包至conan仓......")
|
|
322
|
+
tool.run_command(f'conan upload "*" --all --remote {self.remote} -c --no-overwrite')
|
|
323
|
+
|
|
324
|
+
def build_all_packages(self, service_json: str):
|
|
325
|
+
"""构建出组件所有组合的package包
|
|
326
|
+
|
|
327
|
+
Args:
|
|
328
|
+
service_json (str): 显式指定用于生成conanbase.py依赖的service.json路径
|
|
329
|
+
"""
|
|
330
|
+
|
|
331
|
+
all_attributes = {
|
|
332
|
+
"profile": self.profile_list,
|
|
333
|
+
"stage": self.stage_list,
|
|
334
|
+
"build_type": self.built_type_list,
|
|
335
|
+
}
|
|
336
|
+
# 不参与构建二进制的选项
|
|
337
|
+
block_options = ["asan", "gcov"]
|
|
338
|
+
options_dict = self.options_dict
|
|
339
|
+
for block in block_options:
|
|
340
|
+
options_dict.pop(block, None)
|
|
341
|
+
|
|
342
|
+
all_attributes = {**all_attributes, **options_dict}
|
|
343
|
+
# 设置变量让所有场景(包括DT)构建lua代码时都进行编译
|
|
344
|
+
os.environ["TRANSTOBIN"] = "true"
|
|
345
|
+
log.info(f"构建组件{self.comp}的全量二进制, 选项包含:{options_dict}")
|
|
346
|
+
all_build_params = list(itertools.product(*all_attributes.values()))
|
|
347
|
+
if not self.skip_fetch:
|
|
348
|
+
random.shuffle(all_build_params)
|
|
349
|
+
for build_args in all_build_params:
|
|
350
|
+
profile, stage, build_type, *option_values = build_args
|
|
351
|
+
if profile == "profile.dt.ini" and build_type.lower() != BUILD_TYPE_DT.lower():
|
|
352
|
+
continue
|
|
353
|
+
if profile != "profile.dt.ini" and build_type.lower() == BUILD_TYPE_DT.lower():
|
|
354
|
+
continue
|
|
355
|
+
build_options = dict(zip(options_dict.keys(), option_values))
|
|
356
|
+
task = BuildComponent(
|
|
357
|
+
self.comp,
|
|
358
|
+
profile,
|
|
359
|
+
stage,
|
|
360
|
+
build_type,
|
|
361
|
+
build_options,
|
|
362
|
+
self.code_path,
|
|
363
|
+
remote=self.remote,
|
|
364
|
+
service_json=service_json,
|
|
365
|
+
upload=self.upload,
|
|
366
|
+
)
|
|
367
|
+
task.run()
|
|
368
|
+
|
|
369
|
+
def _create_temp_service_json(self):
|
|
370
|
+
temp_path = os.path.join(self.comp_path, "temp")
|
|
371
|
+
os.makedirs(temp_path, exist_ok=True)
|
|
372
|
+
temp_service_json = os.path.join(temp_path, "service.json")
|
|
373
|
+
if not os.path.isfile(temp_service_json):
|
|
374
|
+
tool.copy(os.path.join(self.comp_path, "mds/service.json"), temp_service_json)
|
|
375
|
+
return temp_service_json
|
|
376
|
+
|
|
377
|
+
def _package_docs_from_source(self):
|
|
378
|
+
os.chdir(self.comp_path)
|
|
379
|
+
current_path = os.getcwd()
|
|
380
|
+
package_folder = []
|
|
381
|
+
for entry in os.listdir(current_path):
|
|
382
|
+
entry_l = entry.lower()
|
|
383
|
+
if entry_l == "mds" or entry_l == "docs":
|
|
384
|
+
package_folder.append(entry)
|
|
385
|
+
elif "changelog" in entry_l or entry_l.endswith(".md"):
|
|
386
|
+
package_folder.append(entry)
|
|
387
|
+
if not package_folder:
|
|
388
|
+
tool.log.info("无docs文档, 跳过文档打包。")
|
|
389
|
+
return
|
|
390
|
+
tar_cmd = ["tar", "-czvf", f"{self.code_path}/{self.comp_name}_docs.tar.gz"] + package_folder
|
|
391
|
+
tool.run_command(tar_cmd)
|