6 Star 1 Fork 167

OpenHarmony / developtools_syscap_codec

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

系统能力编解码工具

系统能力(SystemCapability, 本文中使用SysCap缩写)编解码工具应用场景如下:

应用开发时,IDE会根据应用配置的SysCap和API版本生成描述RPCID(Required Product Compatibility ID)的json文件,并调用编解码工具syscap_tool将该json文件编码成RPCID。另一方面,IDE拿到开发者导入PCID(Product Compatibility ID),使用该工具解码出设备的SysCap集合。该工具仅供IDE使用,对用户不可见。

提供的主要功能:

  1. PCID编码:对描述SysCap集合的文件编码生成PCID。

  2. PCID解码:对编码后的PCID文件解码获取SysCap集合。

  3. RPCID编码:对描述应用所需的SysCap集合的文件编码生成RPCID。

  4. RPCID解码:对编码后的RPCID文件解码获取应用所需的SysCap集合。

  5. 编码字符串:将sc后缀形式的PCID/RPCID编码为字符串形式。

  6. 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一致性检查脚本

API

PC端工具,不对外提供API。

PC端编译说明

syscap_tool PC端可执行文件编译步骤:

  1. 编译命令:参考编译构建文档,执行其指定的sdk编译命令来编译整个sdk,syscap_tool会被编译打包到里面。
  2. 编译:在目标开发机上运行上面调整好的sdk编译命令,正常编译syscap_tool会输出到sdk平台相关目录下。

注意:ubuntu环境下只能编译windows/linux版本工具,mac版需要在macos开发机上编译。

PC端获取说明

  1. 下载sdk获取(建议)
    通过访问本社区门禁每日构建网站,下载最新的ohos-sdk压缩包,并从相应平台的toolchains压缩包中提取syscap_tool。
  2. 支持运行环境
    Windows x86_64/Linux x86_64/Darwin x86_64

命令帮助

本工具一般被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 选项指定输出目录,缺省为当前目录。

syscap一致性检查工具

功能及依赖

本工具主要提供如下功能:

  1. 收集所有部件(或指定部件)的syscap字段并与developtools/sysap_codec/include/syscap_define.h中的arraySyscap比较,输出检查结果,若不一致,输出不一致的原因
  2. 收集所有部件的syscap字段并与interface/sdk-js/api目录下的*.d.ts中的“@syscap”属性集合比较,输出检查结果,若不一致,输出不一致的原因
  3. 收集所有interface/sdk-js/api目录下的*.d.ts中的syscap属性与developtools/syscap_codec/include/syscap_define.h中的arraySyscap比较,若不一致,输出不一致的原因

使用方法

本工具使用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

syscap_define.h 文件规则

  • 每一个 SyscapNum 枚举值都唯一对应于一个 syscap 字符串。
  • 如果弃用某个 syscap,在对应的枚举值后面注释 "// abandoned" 即可,请勿删除和修改。对应的 syscap 字符串也不需要修改。
  • 添加 syscap,请在 SyscapNum 和 g_arraySyscap 末尾添加相应数据。
  • 数组 g_arraySyscap 按照 SyscapNum 枚举值从小到大排序。

Release Note

v1.1.0 2022-6-17 添加转字符串格式以及比较功能。
v1.0.0 2022-3-8 首版本,提供Windows/Linux/Mac平台的系统能力编解码。

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS

简介

OpenHarmony系统能力编解码工具。 展开 收起
C 等 4 种语言
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/openharmony/developtools_syscap_codec.git
git@gitee.com:openharmony/developtools_syscap_codec.git
openharmony
developtools_syscap_codec
developtools_syscap_codec
master

搜索帮助