README.md
1# System Capability Encoder and Decoder Tools
2
3SysCap(SystemCapability) encoder and decoder tools common usage scenarios as follow:
4
5APP development: IDE collect APP required SysCap and API verssion as in rpcid encoder input. And IDE will decode pcid to device SysCap list when it imported. This tool is only for use by the IDE, developers will not be used directly.
6
7Main function:
8
91. pcid Encode: Encode SysCap list to pcid.
10
112. pcid Decode: Decode pcid to get system SysCap list.
12
133. rpcid Encode: Encode APP required SysCap list to rpcid.
14
154. rpcid Decode: Decode rpcid to get APP required SysCap list.
16
17## File Structure
18
19```
20/developtools
21├── syscap_codec # syscap codec代码目录
22│ ├── include
23│ │ ├──code_config # syscap_tool_shared对外接口定义
24│ │ │ └──syscap_define.h
25│ │ ├── context_tool.h
26│ │ ├── create_pcid.h
27│ │ └── syscap_tool.h
28│ ├── interfaces/inner_api # 提供部件之间的接口
29│ │ ├── syscap_interface.c
30│ │ └── syscap_interface.h
31│ ├── napi # napi 接口实现
32│ │ ├── BUILD.gn
33│ │ ├── napi_query_syscap.cpp
34│ │ └── query_syscap.js
35│ ├── src
36│ │ ├── common_method.c
37│ │ ├── common_method.h
38│ │ ├── context_tool.c
39│ │ ├── create_pcid.c
40│ │ ├── endian_internal.h # 内部实现的大小端转换接口定义(便于win、mac、linux平台通用)
41│ │ ├── endian_internal.c # 大小端转换实现
42│ │ ├── main.c # syscap_tool命令行工具代码实现
43│ │ └── syscap_tool.c # syscap_tool编解码接口的实现
44│ └── test
45│ │ └── unittest/common # inner 接口测试代码实现
46│ │ ├── BUILD.gn
47│ │ ├── include
48│ │ │ └── syscap_codec_test.h
49│ │ └── syscap_codec_test.cpp # syscap_tool功能测试代码实现
50| |—— tools
51| │ ├── requirements.txt
52│ │ ├── syscap_check.py # syscap一致性检查脚本
53│ │ ├── syscap_collector.py
54| │ └── syscap_config_merge.py
55```
56
57### API
58
59PC tools, no API provided.
60
61### Building Manually
62
63syscap_tool binary building steps as follow:
64
651. Build commands:SysCap tools binary building and installation will be tiggered by SDK compiling procedure. How to build SDK please refer to https://gitee.com/openharmony/build/blob/master/README_zh.md.
66
672. Building cmd should be adjust for host platform as same as SDK compiling, the archive will in corresponding platform directoty.
68
69Note: Ubuntu host only avaiable for windows/linux building, MacOs binary should building on MacOs host.
70
71### Downloading Binary
72
731. Downlaod SDK(recommonded)
74
75Download daily builds( https://ci.openharmony.cn/workbench/cicd/dailybuild/dailylist ) which included SDK.
76
772. Supported Host
78
79Windows x86_64/Linux x86_64/Darwin x86_64
80
81### Help
82
83SysCap tools usually integrate to IDE, APP store and bundle tools. Follow instructions for debugging manually:
84
85./syscap_tool -h or ./syscap_tool --help:
86
87```
88./syscap_tool --help
89
90./syscap_tool -R/P -e/d -i filepath [-o outpath]
91
92-h, --help : how to use
93
94-R, --rpcid : encode or decode rpcid
95
96-P, --pcid : encode or decode pcid
97
98-e, --encode : to encode
99
100-d, --encode : to decode
101
102-i filepath, --input filepath : input file
103
104-o outpath, --input outpath : output path
105```
106
107## Syscap consistency check tool
108
109### Functions and dependencies
110
111The tool provides the following functions:
112
1131. Collect syscap fields of all components (or specified components), compare them with arraySyscap in developtools/ syscap_codec/include/syscap_define.h, and output the check results. If they are inconsistent, output the cause of the discrepancy.
1142. Collect the syscap fields of all components and compare them with the @syscap property set in *.d.ts in the Interface/sdk-js/api directory. If the check results are inconsistent, output the cause of the inconsistency.
1153. Compare syscap attributes in *.d.ts in all interface/ sdK-JS/API directories with arraySyscap in developtools/syscap_codec/include/syscap_define.h. If they are inconsistent, output the cause of the inconsistency.
116
117### How to use it
118
119This tool is written in Python language and needs to be executed using the Python interpreter.
120
121requirements:
122
123```txt
124prettytable==3.3.0
125```
126
127usage:
128
129```shell
130# check syscap field in all components for consistency with arraySyscap in syscap_define.h
131python3 syscap_check.py -p path_of_openarmony -t component_codec
132
133# check that the SYSCAP field in bundle.json of the specified part is consistent with arraySyscap in syscap_define.h. Note: --bundles is valid only if --check_target is component_codec
134python3 syscap_check.py -p path_of_openarmony -t component_codec -b path_of_component1/bundle.json path_of_component2/bundle.json
135
136# check the consistency of the syscap field of all components with the "@syscap" property set in *.d.ts
137python3 syscap_check.py -p path_of_openarmony -t component_sdk
138
139# check the "@syscap" attribute set in *.d.ts for consistency with arraSyscap in syscap_define.h
140python3 syscap_check.py -p path_of_openarmony -t sdk_codec
141```
142
143### Release Note
144
145v1.0.0 2022-3-8 first release, SysCap codec supported for Windows/Linux/Mac host.
146