系统能力(SystemCapability, 本文中使用SysCap缩写)编解码工具应用场景如下:
应用开发时,IDE会根据应用配置的SysCap和API版本生成描述RPCID(Required Product Compatibility ID)的json文件,并调用编解码工具syscap_tool将该json文件编码成RPCID。另一方面,IDE拿到开发者导入PCID(Product Compatibility ID),使用该工具解码出设备的SysCap集合。该工具仅供IDE使用,对用户不可见。
提供的主要功能:
PCID编码:对描述SysCap集合的文件编码生成PCID。
PCID解码:对编码后的PCID文件解码获取SysCap集合。
RPCID编码:对描述应用所需的SysCap集合的文件编码生成RPCID。
RPCID解码:对编码后的RPCID文件解码获取应用所需的SysCap集合。
编码字符串:将sc后缀形式的PCID/RPCID编码为字符串形式。
PCID与RPCID比较:查询PCID是否满足RPCID的要求,并输出不满足的地方。
/developtools
├── syscap_codec # syscap codec代码目录
│ ├── include # syscap_tool_shared对外接口定义
│ │ ├── syscap_define.h
│ │ └── syscap_tool.h
│ ├── interfaces/inner_api # 提供部件之间的接口
│ │ ├── syscap_interface.c
│ │ └── syscap_interface.h
│ ├── napi # napi 接口实现
│ │ ├── BUILD.gn
│ │ ├── napi_query_syscap.cpp
│ │ └── syscap_interface.h
│ ├── src
│ │ ├── endian_internel.h # 内部实现的大小端转换接口定义(便于win、mac、linux平台通用)
│ │ ├── endian_internel.c # 大小端转换实现
│ │ ├── main.c # syscap_tool命令行工具代码实现
│ │ └── syscap_tool.c # syscap_tool编解码接口的实现
│ └── test
│ │ ├── unittest/common # inner 接口测试代码实现
│ │ │ ├── BUILD.gn
│ │ │ ├── include
│ │ │ │ └── syscap_codec_test.h
│ │ │ └── syscap_codec_test.cpp
│ │ └── syscap_tool_test.c # syscap_tool功能测试代码实现
| |—— tools
| │ │
| │ └── syscap_check.py # syscap一致性检查脚本
PC端工具,不对外提供API。
syscap_tool PC端可执行文件编译步骤:
注意:ubuntu环境下只能编译windows/linux版本工具,mac版需要在macos开发机上编译。
本工具一般被IDE、应用市场和包管理器集成,手工调试时可参考以下说明。
使用./syscap_tool -h或者./syscap_tool --help查看:
syscap_tool -R/P -e/d -i filepath [-o outpath]
-h, --help : how to use
-R, --RPCID : encode or decode RPCID
-P, --PCID : encode or decode PCID
-C, --compare : compare pcid with rpcid string format.
-s, --string : input string.
-e, --encode : encode to sc format.
-s, --string : encode to string format.
-d, --decode : decode to json format.
-s, --string : decode string format.
-i filepath, --input filepath : input file
-o outpath, --input outpath : output path
-v, --version : print syscap_tool version information.
syscap_tool v1.1.1
# 将 RPCID.json 编码为SC格式,文件名RPCID.sc
syscap_tool -Rei RPCID.json -o path/
# 将 RPCID.sc 编码为JSON格式,文件名RPCID.json
syscap_tool -Rdi RPCID.sc -o path/
# 将 PCID.json 编码为SC格式,文件名PCID.sc
syscap_tool -Pei PCID.json -o path/
# 将 PCID.sc 编码为JSON格式,文件名PCID.json
syscap_tool -Pdi PCID.sc -o path/
# 将 RPCID.sc 编码为字符串格式,文件名RPCID.txt
syscap_tool -Resi RPCID.sc -o path/
# 将 PCID.sc 编码为字符串格式,文件名PCID.txt
syscap_tool -Pesi PCID.sc -o path/
# 比较字符串格式的PCID和RPCID,pcid 符合条件返回成功提示,不符合则提示原因。
syscap_tool -C pcid.txt rpcid.txt
# 功能类似 -C 选项,区别为 -SC 选项为直接输入字符串。
syscap_tool -sC "pcidstring" "rpcidstring"
# 将字符串格式的 pcid 转为 json 格式,文件名 PCID.json。
syscap_tool -Pdsi pcid.txt -o path/
说明: -o 选项指定输出目录,缺省为当前目录。
本工具主要提供如下功能:
本工具使用python语言编写,需使用python解释器进行执行。
requirements:
prettytable==3.3.0
使用python3 syscap-check.py -h或python3 syscap-check.py --help查看用法:
usage: syscap_check.py [-h] [-p PROJECT_PATH] -t {component_codec,component_sdk,sdk_codec}
[-b [BUNDLES [BUNDLES ...]]]
optional arguments:
-h, --help show this help message and exit
-p PROJECT_PATH, --project_path PROJECT_PATH
root path of project. default: ./
-t {component_codec,component_sdk,sdk_codec}, --check_target {component_codec,component_sdk,sdk_codec}
the target to be compared
-b [BUNDLES [BUNDLES ...]], --bundles [BUNDLES [BUNDLES ...]]
this option will take effect only when the check_target is component_codec. allow multiple
json file. default: all bundle.json file
使用示例:
# 检查所有部件的syscap字段与syscap_define.h中的arraySyscap一致性情况
python3 syscap_check.py -p path_of_openarmony -t component_codec
# 检查指定的部件的bundle.json中的syscap字段与syscap_define.h中的arraySyscap一致性情况,注意,只要当--check_target为component_codec时,--bundles才生效
python3 syscap_check.py -p path_of_openarmony -t component_codec -b path_of_component1/bundle.json path_of_component2/bundle.json
# 检查所有部件的syscap字段与*.d.ts中的“@syscap”属性集合的一致性情况
python3 syscap_check.py -p path_of_openarmony -t component_sdk
# 检查*.d.ts中的“@syscap"属性集合与syscap_define.h中的arraSyscap的一致性情况
python3 syscap_check.py -p path_of_openarmony -t sdk_codec
v1.1.0 2022-6-17 添加转字符串格式以及比较功能。
v1.0.0 2022-3-8 首版本,提供Windows/Linux/Mac平台的系统能力编解码。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型