当前位置: 首页 > 科技观察

移植案例与原理-HPM包描述文件Bundle.Json

时间:2023-03-22 15:44:20 科技观察

更多信息请访问:鸿蒙技术社区,与华为官方共建https://ost.51cto。com1,HPMBundle的基本概念Bundle是OpenHarmony中用来表示一个分发单元的术语,相当于一个包。一个Bundle通常包含以下内容:分发的二进制文件(二进制类型)。要分发的源代码文件(源代码/代码片段类型)。编译脚本(分发类型需要)。它自己的文档。bundle.json:元数据声明(名称、版本、依赖项等)。LICENSE:许可协议的文本。README.md:自述文件。CHANGELOG.md:变更日志(可选)。Bundle发布到HPM服务器(https://hpm.harmonyos.com)后,其他开发者可以通过hpm包管理器下载安装。Bundle在命名空间中有唯一的名称(命名格式为:@scope/name),可以进行独立的版本演化。一个bundle包通常有以下代码组织结构:demo├──headers#头文件(样本)│└──main.h└──src#源代码(样本)│└─main.c├──bundle。json#元数据声明文件└──LICENSE#许可协议文本└──Makefile#编译描述文件(示例)└──README.md#Bundlereadme文件2、bundle.json文件格式定义文件bundle.json一般有以下格式。各个属性值的解释见评论区。因为是json文件,所以要注意是对象还是数组。对象由用花括号{}括起来的逗号分隔的成员组成,成员是字符串键,值由逗号分隔的键值对组成。数组是用方括号[]括起来的一组值。{"name":"@ohos/",#HPM组件的英文名称,由@conform、组织名称、组件名称组成。"description":"componentdescription",#组件描述"version":"3.1.0",#版本号,3.1应该走的OpenHarmony版本号"homePage":"https://gitee.com/openharmony",#组件主页"license":"BSD3-claus",#组件的版权协议,根据组件的license填写"publishAs":"code-segment",#发布形式,generallycode-segment"segment":{#组件的代码路径"destPath":"/"},"dirs":[],#HPM包的目录结构"scripts":{},#HPM包定义了需要执行的脚本"component":{#组件的属性信息"name":""#组件的名称要与"@ohos/"中的名称一致"subsystem":"xxxsubsystem",#组件所属的子系统"syscap":["SystemCapability..."]#该组件为应用程序提供的系统能力"features":["_"]#组件的特性列表"adapted_system_type":[""]#该组件适用的系统类型:轻型(mini)、小型(small)andstandard(标准)"rom":"xxxKB",#ROM占用"ram":"xxxKB",#RAM占用"deps":{"components":[#该组件依赖的其他组件"xxx_component"],"third_party":[#组件依赖于三方开源软件""]},"build":{#组件编译构建配置,多个"sub_component":["/////"],#组件子组件编译入口"inner_kits":[#组件内部接口,多个{"header":{#内部头文件信息"header_base":"///interface/innerkits/",#内部头文件目录"header_files":["xxx.h"]#headerfilename},"name":"///interface/innerkits/"#内部接口名称}]"test":["///test"]#组件测试用例编译入口,可以有多个testsuite入口}}}3.bundle.json示例查看bundle.json文件的分布情况,存在于各个子系统和三个-partylibrary开发板移植时不需要,如果需要开发HPM包,需要写bundle.json文件,具体例子可以打开一个查看~/openharmony$find./-namebundle.json./ark/js_runtime/bundle.json......./base/account/os_account/bundle.json......./build/common/bundle.json./developtools/bytrace_standard/bundle.json......./drivers/adapter/bundle.json./drivers/peripheral/audio/bundle.json......./foundation/aafwk/standard/bundle.json......./kernel/linux/build/bundle.json./kernel/liteos_a/bundle.json./kernel/liteos_m/bundle.json./test/xts/acts/bundle.json......./third_party/abseil-cpp/bundle.json......./utils/native/bundle.json......看例子openharmony\foundation\communication\dsoftbus\bundle.json分布式软总线。⑴定义了HPM包名称,与⑶处的组件名称相同,为dsoftbus_standard。⑵处的脚本与npm包类似,在执行hpminstall时安装hpm包。⑷设置hpm包属于哪个子系统,已经适配了子系统类型、包含的特性等。(5)设置依赖的其他组件和第三方库。(6)设置hpm包的编译构建信息。(7)设置hpm包的测试套件信息。{⑴"name":"@openharmony/dsoftbus_standard","version":"3.1.0","description":"dsoftbus_standard","publishAs":"code-segment","scripts":{⑵"install":"DEST_PATH=${DEP_BUNDLE_BASE}/foundation/communication/dsoftbus&&mkdir-p$DEST_PATH&&cp-r./*$DEST_PATH"},"author":{},"repository":"","license":"ApacheLicense2.0","component":{⑶"name":"dsoftbus_standard",⑷"subsystem":"communication","adapted_system_type":["mini","small","standard"],"features":[“dsoftbus_standard_feature_conn_p2p”,“dsoftbus_standard_feature_disc_ble”,“dsoftbus_standard_feature_conn_br”,“dsoftbus_standard_feature_conn_ble”],“rom”:“967KB”,“ram”:“28MB”,⑸“deps”:{“组件”:[“libhilog”,"libipc_single","libwifi_sdk","libsystem_ability_fwk","libsyspara","samgr_proxy","utils_base"],"third_party":["libcoap","libmbedtls","bounds_checking_function"]},⑩"build":{"sub_component":["//foundation/communication/dsoftbus/core:softbus_server","//foundation/communication/dsoftbus/sdk:softbus_client","//foundation/communication/dsoftbus/core/frame/standard/sa_profile:softbus_sa_profile","//foundation/communication/dsoftbus/tools:tool"],"inner_kits":[{"name":"//foundation/communication/dsoftbus/sdk:softbus_client","header":{"header_files":["bus_center/softbus_bus_center.h","common/softbus_common.h","discovery/discovery_service.h","transport/session.h"],"header_base":"//foundation/communication/dsoftbus/interfaces/kits"}}],⑺"test":["//foundation/communication/dsoftbus/tests/adapter/unittest:unittest","//foundation/communication/dsoftbus/tests/sdk/discovery/unittest:unittest","//foundation/communication/dsoftbus/tests/sdk/transmission/trans_channel:unittest","//foundation/communication/dsoftbus/tests/sdk/bus_center/unittest:unittest","//foundation/communication/dsoftbus/tests/core/authentication:unittest","//foundation/communication/dsoftbus/tests/core/bus_center/lnn:unittest","//foundation/communication/dsoftbus/tests/core/common/utils:unittest","//foundation/communication/dsoftbus/tests/core/connection:connectionTest","//foundation/communication/dsoftbus/tests/core/discovery/manager:unittest","//foundation/communication/dsoftbus/tests/core/transmission/trans_channel/tcp_direct:unittest"]}}}参考站点OpenHarmony/docs/zh-cn/device-dev/bundles总结本文介绍HPM包描述文件bundle.json的信息。更多信息请访问:与华为共建的鸿蒙技术社区https://ost.51cto.com