mirror of
https://gitee.com/openharmony/napi_generator
synced 2024-11-23 16:30:17 +00:00
增加各个工具使用文档
Signed-off-by: gou-jingjing <goujingjing@kaihong.com>
This commit is contained in:
parent
03bc4ff826
commit
4a50f32cb3
139
README.md
139
README.md
@ -1,118 +1,33 @@
|
||||
# Readme
|
||||
# 简介
|
||||
|
||||
## 简介
|
||||
- dts2cpp工具可以根据用户指定路径下的ts(typescript)接口文件一键生成NAPI框架代码、业务代码框架、GN文件等。
|
||||
|
||||
napi_generator仓包含以下工具:NAPI框架代码生成工具(dts2cpp)可以根据用户指定路径下的ts(typescript)接口文件一键生成NAPI框架代码、业务代码框架、GN文件等。TS接口生成工具(h2dts)可以根据定义在c++头文件中的接口,生成type-script语言的ts接口文件。GN脚本生成工具(cmake2gn),它可以根据三方库的CMakeLists.txt文件,编译转换生成BUILD.gn脚本文件。SERVICE框架生成工具(h2sa),它可以根据一个定义远程方法的.h头文件,生成整个Service框架的代码,包含Ability注册、proxy/stub类实现、MessageParcel数据包构造、Service子系统编译及开机自启动相关配置文件。NATIVE生成工具(h2dtscpp),它可以根据定义在c++头文件中的接口,生成type-script语言的ts接口文件、NAPI框架代码、和自动化测试用例代码。dts2ets工具,它可以根据用户指定路径下的ts(typescript)接口文件生成ets页面代码。API扫描工具,它可以扫描三方库中包含OpenHarmony源码不包含的接口,并输出result.xlsx文档。
|
||||
[readme](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/dts2cpp/dts2cpp_README_ZH.md)
|
||||
|
||||
## 目录
|
||||
[版本说明](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/dts2cpp/docs/release-notes)
|
||||
|
||||
```
|
||||
├── napi_generator # 工具集
|
||||
│ ├── docs # 工具索引文档
|
||||
│ │ ├── readme.md # 所有工具 readme 索引
|
||||
│ │ ├── develop.md # 工具设计文档索引
|
||||
│ │ ├── usage.md # 工具使用文档索引
|
||||
│ │ ├── log
|
||||
│ │ │ ├── meeting.md # 会议纪要
|
||||
│ │ │ ├── release-notes.md # 工具版本说明和规划索引
|
||||
│ ├── src # 工具源码
|
||||
│ │ ├── cli # 脚手架源码
|
||||
│ │ | ├── cmake2gn # gn脚本生成工具
|
||||
│ │ | | ├── docs
|
||||
│ │ | | | ├── figures # 文档图片资源
|
||||
│ │ | | | ├── guide # 开发文档
|
||||
│ │ | | | ├── usage # 使用文档
|
||||
│ │ | | | ├── release-notes # 版本说明文档
|
||||
│ │ | | ├── src # 源码
|
||||
│ │ | | ├── README_ZH.md
|
||||
│ │ | |── dts2cpp # napi框架生成工具
|
||||
│ │ | | ├── docs
|
||||
│ │ | | | ├── figures # 文档图片资源
|
||||
│ │ | | | ├── guide # 开发文档
|
||||
│ │ | | | ├── usage # 使用文档
|
||||
│ │ | | | ├── release-notes # 版本说明文档
|
||||
│ │ | | | ├── requirement # roadmap.md
|
||||
│ │ | | ├── src # 源码
|
||||
│ │ | | ├── README_ZH.md
|
||||
│ │ | |── dts2ets # ets页面生成工具
|
||||
│ │ | | ├── appCodeGen # 源码
|
||||
│ │ | |── h2dts # ts生成工具
|
||||
│ │ | | ├── docs
|
||||
│ │ | | | ├── figures # 文档图片资源
|
||||
│ │ | | | ├── guide # 开发文档
|
||||
│ │ | | | ├── usage # 使用文档
|
||||
│ │ | | | ├── release-notes # 版本说明文档
|
||||
│ │ | | | ├── requirement # roadmap.md
|
||||
│ │ | | ├── src # 源码
|
||||
│ │ | | ├── examples # 工具输入示例.h文件
|
||||
│ │ | | ├── README_ZH.md
|
||||
│ │ | |── h2dtscpp # native生成工具
|
||||
│ │ | | ├── docs
|
||||
│ │ | | | ├── figures # 文档图片资源
|
||||
│ │ | | | ├── guide # 开发文档
|
||||
│ │ | | | ├── usage # 使用文档
|
||||
│ │ | | ├── src # 源码
|
||||
│ │ | | ├── README_ZH.md
|
||||
│ │ | |── h2sa # service生成工具
|
||||
│ │ | | ├── docs
|
||||
│ │ | | | ├── figures # 文档图片资源
|
||||
│ │ | | | ├── guide # 开发文档
|
||||
│ │ | | | ├── usage # 使用文档
|
||||
│ │ | | | ├── release-notes # 版本说明文档
|
||||
│ │ | | | ├── requirement # roadmap.md
|
||||
│ │ | | ├── src # 源码
|
||||
│ │ | | ├── examples # 工具输入示例.h文件
|
||||
│ │ | | ├── README_ZH.md
|
||||
│ │ ├── intellij_plugin
|
||||
│ │ | ├── cmake2gn # gn脚本生成工具
|
||||
│ │ | | | ├── gn_IntelliJ_plugin # IntelliJ插件
|
||||
│ │ | |── dts2cpp # napi框架生成工具
|
||||
│ │ | | | ├── napi_IntelliJ_plugin # IntelliJ插件
|
||||
│ │ | |── h2dts # ts生成工具
|
||||
│ │ | | | ├── ts_IntelliJ_plugin # IntelliJ插件
|
||||
│ │ | |── h2dtscpp # native生成工具
|
||||
│ │ | | | ├── native_IntelliJ_plugin # IntelliJ插件
|
||||
│ │ | |── h2sa # service生成工具
|
||||
│ │ | | | ├── service_IntelliJ_plugin # IntelliJ插件
|
||||
│ │ | |── assist # 统一入口插件
|
||||
│ │ | | | ├── assist_tools_IntelliJ_plugin # IntelliJ插件
|
||||
│ │ ├── vscode_plugin
|
||||
│ │ | ├── cmake2gn # gn脚本生成工具
|
||||
│ │ | | | ├── gn_vs_plugin # vs插件
|
||||
│ │ | |── dts2cpp # napi框架生成工具
|
||||
│ │ | | | ├── napi_vs_plugin # vs插件
|
||||
│ │ | |── h2dts # ts生成工具
|
||||
│ │ | | | ├── ts_vs_plugin # vs插件
|
||||
│ │ | |── h2sa # service生成工具
|
||||
│ │ | | | ├── service_vs_plugin # vs插件
|
||||
│ │ | |── assist # 统一入口插件
|
||||
│ │ | | | ├── assist_tools_vs_plugin # vs插件
|
||||
│ │ ├── tool
|
||||
│ │ | |── api # api扫描工具
|
||||
│ │ | | ├── api_scan_IntelliJ_plugin # api扫描工具IntelliJ插件
|
||||
│ │ | | ├── api_scan_vs_plugin # api扫描工具vs插件
|
||||
│ │ | | ├── docs # 文档
|
||||
│ │ | | ├── figures # 文档图片资源
|
||||
│ │ | | ├── src # api扫描工具源码
|
||||
│ │ | | ├── FAQ.md
|
||||
│ │ | | ├── README_ZH.md
|
||||
│ ├── test
|
||||
│ │ ├── dts2cpp # dts2cpp工具使用example
|
||||
│ │ | |── ts
|
||||
│ │ | |── README.md
|
||||
│ │ ├── storytest # dts2cpp工具st
|
||||
│ │ ├── unittest # dts2cpp工具ut
|
||||
│ │ ├── debug_entry.js
|
||||
│ │ ├── README_zh.md
|
||||
│ ├── sample # 样例
|
||||
│ │ ├── napitutorials
|
||||
│ └── README.md # readme
|
||||
```
|
||||
- h2dts工具可以根据定义在c++头文件中的接口,生成type-script语言的ts接口文件。
|
||||
|
||||
## 工具介绍
|
||||
[readme](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/h2dts/h2dts_README_ZH.md)
|
||||
|
||||
所有工具相关文档介绍如下所示:
|
||||
[readme索引](https://gitee.com/openharmony/napi_generator/blob/master/docs/readme.md)
|
||||
[usage索引](https://gitee.com/openharmony/napi_generator/blob/master/docs/usage.md)
|
||||
[develop索引](https://gitee.com/openharmony/napi_generator/blob/master/docs/develop.md)
|
||||
[release-notes索引](https://gitee.com/openharmony/napi_generator/blob/master/docs/log/release-notes.md)
|
||||
[版本说明](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/h2dts/docs/release-notes/ts_Gen-1.0.md)
|
||||
|
||||
- cmake2gn工具可以根据三方库的CMakeLists.txt文件,编译转换生成BUILD.gn脚本文件。
|
||||
|
||||
[readme](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/cmake2gn/cmake2gn_README_ZH.md)
|
||||
|
||||
[版本说明](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/cmake2gn/docs/release-notes/gn-gen-release-notes-0.0.2.md)
|
||||
|
||||
- h2sa工具可以根据一个定义远程方法的.h头文件,生成整个Service框架的代码,包含Ability注册、proxy/stub类实现、MessageParcel数据包构造、Service子系统编译及开机自启动相关配置文件。
|
||||
|
||||
[readme](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/h2sa/h2sa_README_ZH.md)
|
||||
|
||||
[版本说明](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/h2sa/docs/release-notes/Service-1.0.md)
|
||||
|
||||
- h2dtscpp工具可以根据定义在c++头文件中的接口,生成type-script语言的ts接口文件、NAPI框架代码、和自动化测试用例代码。
|
||||
|
||||
[readme](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/h2dtscpp/h2dtscpp_README_ZH.md)
|
||||
|
||||
- scan工具,它可以扫描三方库中包含OpenHarmony源码不包含的接口,并输出result.xlsx文档。
|
||||
|
||||
[readme](https://gitee.com/openharmony/napi_generator/blob/master/src/tool/api/scan_README_ZH.md)
|
@ -2,25 +2,7 @@
|
||||
|
||||
## 简介
|
||||
|
||||
cmake2gn工具,即GN脚本转换工具,它可以根据三方库的CMakeLists.txt文件,编译转换生成BUILD.gn脚本文件。当前OpenHarmony源码只支持BUILD.gn文件编译,开发者无法移植CMakeLists.txt编译方式的三方库到OpenHarmony中。此时,开发者可使用GN脚本转换工具,根据CMakeLists.txt文件生成BUILD.gn脚本文件,降低移植难度,提高开发效率。目前工具支持可执行文件、VS Code插件两种入口。
|
||||
|
||||
├── napi_generator # 工具集
|
||||
│ ├── ... # 其它文件
|
||||
│ ├── src
|
||||
│ │ ├── ...
|
||||
│ │ ├── cli
|
||||
│ │ | ├── ... # 其它工具
|
||||
│ │ | ├── cmake2gn
|
||||
│ │ | | ├── src
|
||||
│ │ | | | ├── main.js # 工具源码入口
|
||||
│ │ | | | ├── package.json # package.json文件
|
||||
│ │ | | | |── src
|
||||
│ │ | | | | |── analyze_cmake.js # cmake解析器
|
||||
│ │ | | | | |── analyze_command.js # command解析器
|
||||
│ │ | | | | |── analyze_make.js # make解析器
|
||||
│ │ | | | | |── generate_gn.js # 生成器
|
||||
│ │ | | | | |── logger.js # log日志
|
||||
│ │ | | | | |── tool.js # 公共模块代码
|
||||
cmake2gn工具,它可以根据三方库的CMakeLists.txt文件,编译转换生成BUILD.gn脚本文件。当前OpenHarmony源码只支持BUILD.gn文件编译,开发者无法移植CMakeLists.txt编译方式的三方库到OpenHarmony中。此时,开发者可使用GN脚本转换工具,根据CMakeLists.txt文件生成BUILD.gn脚本文件,降低移植难度,提高开发效率。
|
||||
|
||||
## 约束
|
||||
系统:建议Ubuntu 20.04或者Windows 10
|
||||
@ -29,271 +11,63 @@ cmake2gn工具,即GN脚本转换工具,它可以根据三方库的CMakeLists
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 使用对象
|
||||
### 生成
|
||||
|
||||
系统开发者
|
||||
### 使用场景
|
||||
1、安装cmake,安装命令如下:
|
||||
|
||||
1) 移植CMakeLists.txt编译方式的三方库到OpenHarmony源码中。
|
||||
sudo apt-get install cmake
|
||||
|
||||
### 工具获取
|
||||
2.下载res文件夹,并放置到napi_generator/src/cli/cmake2gn/src目录下,下载链接如下:
|
||||
|
||||
工具有两种类型,分别是可执行文件、VS Code插件。其中的可执行文件可根据工具使用者的开发环境选择,支持Windows,Linux和Mac。可执行文件、VS Code插件下载路径如下:
|
||||
// todo
|
||||
|
||||
[下载链接](http://ftpkaihongdigi.i234.me:5000/fsdownload/1OjtRhtGf/gn-gen-0.0.1)
|
||||
3.安装typescript:在napi_generator/src/cli/cmake2gn/src/src目录下执行命令:
|
||||
|
||||
### 工具输入
|
||||
npm i typescript
|
||||
|
||||
以CmakeLists.txt编译方式的三方库
|
||||
4.安装stdio:在napi_generator/src/cli/cmake2gn/src目录下执行命令:
|
||||
|
||||
根据使用者指定三方库的CMakeLists.txt文件,工具会输出对应的BUILD.gn文件。为了方便使用者快速上手工具,可供测试的三方库项目目录如下:
|
||||
npm i stdio
|
||||
|
||||
5.根据使用者指定三方库的CMakeLists.txt文件,工具会输出对应的BUILD.gn文件。将待转换的三方库拷贝到OpenHarmony/third_party下,为了方便使用者快速上手工具,可供测试的三方库项目目录如下:
|
||||
|
||||
```
|
||||
Openharmony@Ubuntu-64:~/OpenHarmony/third_party/mbedtls-development$ ls
|
||||
3rdparty BUGS.md ChangeLog cmake configs DartConfiguration.tcl docs include LICENSE programs scripts SUPPORT.md visualc BRANCHES.md ChangeLog.d CMakeLists.txt CONTRIBUTING.md dco.txt doxygen library Makefile README.md SECURITY.md tests
|
||||
```
|
||||
|
||||
### 工具使用
|
||||
|
||||
具体的工具使用步骤,可以左键单击以下链接了解:
|
||||
|
||||
[工具使用说明](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/cmake2gn/docs/usage/INSTRUCTION_ZH.md)
|
||||
|
||||
### 工具输出
|
||||
|
||||
在linux环境下的,根据输入三方库项目的CMakeLists.txt文件,生成的输出文件,如下所示:
|
||||
|
||||
OpenHarmony@Ubuntu-64:~/OpenHarmony/third_party/mbedtls-development$ ls
|
||||
3rdparty BUGS.md ChangeLog cmake configs DartConfiguration.tcl docs include LICENSE programs scripts SUPPORT.md visualc BRANCHES.md build_tmp ChangeLog.d CMakeLists.txt CONTRIBUTING.md dco.txt doxygen library Makefile README.md SECURITY.md tests
|
||||
OpenHarmony@Ubuntu-64:~/OpenHarmony/third_party/mbedtls-development$ cd build_tmp/
|
||||
OpenHarmony@Ubuntu-64:~/OpenHarmony/third_party/mbedtls-development/build_tmp$ ls
|
||||
3rdparty BUILD.gn cmake CMakeCache.txt CMakeFiles cmake_install.cmake CTestTestfile.cmake DartConfiguration.tcl include library Makefile ohos.toolchain.cmake programs scripts tests
|
||||
|
||||
其中生成的BUILD.gn文件,内容如下所示:
|
||||
6.在napi_generator/src/cli/cmake2gn/src/src下执行以下命令:
|
||||
|
||||
```
|
||||
import("//build/ohos.gni")
|
||||
|
||||
group("all_targets") {
|
||||
deps = [
|
||||
#静态库
|
||||
"//third_party/mbedtls-development/build_tmp/library:mbedcrypto",
|
||||
"//third_party/mbedtls-development/build_tmp/library:mbedx509",
|
||||
"//third_party/mbedtls-development/build_tmp/library:mbedtls",
|
||||
|
||||
#可执行程序
|
||||
"//third_party/mbedtls-development/build_tmp/programs/aes:crypt_and_hash",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/cipher:cipher_aead_demo",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_x509crl",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_x509csr",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_pubkey",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_pkcs7",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_privkey",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_client",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_dtlsserver",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_dtlsclient",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_x509crt",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_server",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/hash:generic_sum",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/hash:hello",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/hash:md_hmac_demo",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:mpi_demo",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:key_app",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:pk_encrypt",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:gen_key",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:ecdsa",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:rsa_encrypt",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:dh_client",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:dh_server",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:dh_genprime",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:ecdh_curve25519",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:pk_decrypt",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:pk_sign",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:key_app_writer",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:pk_verify",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:rsa_decrypt",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:rsa_genkey",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:rsa_sign",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:rsa_sign_pss",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:rsa_verify",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/pkey:rsa_verify_pss",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/psa:key_ladder_demo",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/psa:crypto_examples",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/psa:aead_demo",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/psa:hmac_demo",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/psa:psa_constant_names",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/random:gen_entropy",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/random:gen_random_ctr_drbg",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_pthread_server",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_client1",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_client2",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/ssl:mini_client",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/ssl:dtls_server",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/ssl:dtls_client",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_server",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_server2",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_context_info",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_fork_server",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_mail_client",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/test:selftest",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/test:benchmark",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/test:udp_proxy",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/test:query_compile_time_config",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/test:zeroize",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/util:pem2der",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/util:strerror",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/x509:load_roots",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/x509:cert_req",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/x509:cert_write",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/x509:crl_app",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/x509:req_app",
|
||||
"//third_party/mbedtls-development/build_tmp/programs/x509:cert_app",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_x509write",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_x509parse",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_its",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_storage_format.current",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_timing",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_ssl",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_rsa",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_entropy",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_shax",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_hmac_drbg.pr",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_dhm",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_ecdsa",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.des",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_poly1305",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_ctr_drbg",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.null",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.gcm",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_storage_format.misc",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_ccm",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.camellia",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_chachapoly",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_mdx",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_des",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.chacha20",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum.generated",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum_mod",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_chacha20",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_aria",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_not_supported.generated",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.padding",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.nist_kw",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_aes.ofb",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_hmac_drbg.nopr",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_aes.ecb",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_hkdf",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_aes.cfb",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.ccm",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_pkcs5",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.aes",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum.misc",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_aes.rest",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_cmac",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_camellia",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_ecdh",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_md",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.chachapoly",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_storage_format.v0",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_asn1parse",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_asn1write",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_base64",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum_mod_raw.generated",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_oid",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.misc",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum_core.misc",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_ecjpake",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum_core.generated",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum_mod_raw",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_random",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_aes.cbc",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_pk",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_version",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_se_driver_hal_mocks",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum_mod.generated",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_debug",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_pkcs1_v21",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.aes128_de",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.aria",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.aes128_en",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.aes192_de",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.camellia",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.aes192_en",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.aes256_de",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.aes256_en",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.misc",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_hmac_drbg.misc",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_hmac_drbg.no_reseed",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_lms",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_mps",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_memory_buffer_alloc",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_net",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_nist_kw",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_metadata",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_pkparse",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_hash",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_pem",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_pkcs12",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_attributes",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_aes.xts",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_op_fail.generated",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_pkcs1_v15",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_pkcs7",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_pkwrite",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_not_supported.misc",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_driver_wrappers",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_entropy",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_generate_key.generated",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_init",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_op_fail.misc",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_error",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_pake",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_lmots",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_persistent_key",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_se_driver_hal",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_ecp",
|
||||
"//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_slot_management",
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
node main.js -o out/rk3568 -p /home/OpenHarmony -f third_party/mbedtls-development/CMakeLists.txt -t cmake -s test_subsystem -m mbedtls-development
|
||||
```
|
||||
|
||||
其中,参数详情如下:
|
||||
|
||||
-o:必填参数,ohos产品输出相对路径(例如:out/rk3568);
|
||||
|
||||
-p:必填参数,ohos项目路径(例如:/home/OpenHarmony);
|
||||
|
||||
-f:必选参数,待转换三方库cmake文件相对路径(例如:third_party/mbedtls-development/CMakeLists.txt);
|
||||
|
||||
-t:可选参数,默认为cmake;
|
||||
|
||||
-s:可选参数,默认填写“test_subsystem”,使用者可根据实际情况修改子系统名称;
|
||||
|
||||
-m:可选参数,工具默认填写“test_part”,使用者可根据实际情况修改组件名称;
|
||||
|
||||
-d:可选参数,工具默认填写待转换三方库cmake文件所在文件夹相对路径,使用者可根据实际情况修改路径;
|
||||
|
||||
-a:可选参数,待转换三方库中引用其它三方库时需填写该选项,具体填写方法可参考FAQ中libcoap转换时问题解决方法,详细FAQ内容可左键单击以下链接了解:[FAQ](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/cmake2gn/docs/guide/FAQ.md);
|
||||
|
||||
7.运行成功后会在/OpenHarmony/third_party/mbedtls-development目录下生成build_tmp文件夹,build_tmp文件夹中包含BUILD.gn文件,如下所示:
|
||||
|
||||
![](./docs/figures/pic-build-tmp.png)
|
||||
|
||||
### 集成
|
||||
|
||||
具体的将三方库集成到OpenHarmony的步骤,可以左键单击以下链接了解:
|
||||
|
||||
[将三方库集成到OpenHarmony的方法](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/cmake2gn/docs/usage/ENSEMBLE_METHOD_ZH.md)
|
||||
|
||||
## 工具开发说明
|
||||
|
||||
### 对象
|
||||
|
||||
工具的开发者
|
||||
|
||||
### 开发场景
|
||||
|
||||
若当前工具的功能已经不能满足开发者的全部需求,则开发者可以基于已有的源码对工具进行二次开发,来增强工具的能力,编译打包生成自定义的可执行文件和插件。
|
||||
|
||||
### 开发步骤
|
||||
|
||||
开发者可以根据如下的步骤来完成对工具的开发:
|
||||
|
||||
[工具开发说明](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/cmake2gn/docs/guide/DEVELOP_ZH.md)
|
||||
|
||||
## 版本说明
|
||||
|
||||
[版本说明](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/cmake2gn/docs/release-notes/gn-gen-release-notes-0.0.2.md)
|
||||
|
||||
## FAQ
|
||||
|
||||
[FAQ](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/cmake2gn/docs/guide/FAQ.md)
|
||||
|
||||
## 参与贡献
|
||||
|
||||
暂无
|
||||
|
||||
## 相关仓
|
||||
|
||||
暂无
|
||||
|
BIN
src/cli/dts2cpp/docs/figures/dts2cpp_outResult.png
Normal file
BIN
src/cli/dts2cpp/docs/figures/dts2cpp_outResult.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
@ -1,133 +0,0 @@
|
||||
# dts2cpp工具
|
||||
|
||||
## 简介
|
||||
dts2cpp工具,即NAPI框架生成工具,它可以根据用户指定路径下的ts(typescript)接口文件一键生成NAPI框架代码、业务代码框架、GN文件等。在开发JS应用与NAPI间接口时,底层框架开发者无需关注js语法、C++与JS之间的数据类型转换等上层应用转换逻辑,只关注底层业务逻辑即可,专业的人做专业的事,从而可以大大提高开发效率。目前工具支持可执行文件、VS Code插件、DevEco Studio上使用的IntelliJ插件三种入口。
|
||||
|
||||
## 目录
|
||||
|
||||
├── napi_generator # 工具集
|
||||
│ ├── ... # 其它文件
|
||||
│ ├── src
|
||||
│ │ ├── ...
|
||||
│ │ ├── cli
|
||||
│ │ | ├── ... # 其它工具
|
||||
│ │ | ├── dts2cpp
|
||||
│ │ | | ├── src/gen # napi工具源码
|
||||
│ │ | | | ├── analyze # 解析器
|
||||
│ │ | | | |── extend # 扩展模块,包括gn文件生成、linux环境适配代码等
|
||||
│ │ | | | |── generate # 生成器
|
||||
│ │ | | | └── tools # 公共模块代码,包括消息体校验、文件读写、正则表达式转换等
|
||||
│ │ | │ └── README # 工具使用指导
|
||||
|
||||
## 约束
|
||||
系统:建议Ubuntu 20.04或者Windows 10
|
||||
|
||||
依赖版本:VS Code 1.62.0
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 使用对象
|
||||
|
||||
系统开发者
|
||||
|
||||
### 使用场景
|
||||
|
||||
1) 系统框架层新增子系统,需对应用层提供接口。
|
||||
2) 系统框架层子系统能力增强后,需对应用层提供新接口。
|
||||
|
||||
### 工具获取
|
||||
|
||||
工具有三种类型,分别是可执行文件、VS Code插件、DevEco Studio上使用的IntelliJ插件。其中的可执行文件可根据工具使用者的开发环境选择,支持Windows,Linux和Mac。
|
||||
|
||||
可执行文件下载路径如下(由于网络原因,可能会导致有的下载链接失效,因此提供了以下三个下载链接):
|
||||
|
||||
[可执行文件下载链接1](http://ftpkaihongdigi.i234.me:5000/sharing/yaRiKSjBI)
|
||||
|
||||
[可执行文件下载链接2](http://ftp.kaihong.com:5000/fsdownload/yaRiKSjBI/)
|
||||
|
||||
[可执行文件下载链接3](http://ftp.kaihongdigi.com:5000/fsdownload/yaRiKSjBI/)
|
||||
|
||||
访问密码:kaihong
|
||||
|
||||
压缩包解压密码:kaihong20231121
|
||||
|
||||
DevEco Studio上使用的IntelliJ插件下载路径如下:
|
||||
|
||||
[DevEco Studio上使用的IntelliJ插件下载链接](https://plugins.jetbrains.com/plugin/19593-napi-generator/versions)
|
||||
|
||||
### 工具输入
|
||||
|
||||
根据使用者指定的typescript文件,工具会输出NAPI框架代码、业务代码框架、GN脚本等文件。
|
||||
|
||||
为了方便使用者快速上手工具,可供测试的typescript文件@ohos.napitest.d.ts示例如下:
|
||||
|
||||
```
|
||||
declare namespace napitest {
|
||||
function funcTest(v1: number, v2: number): number;
|
||||
}
|
||||
|
||||
export default napitest;
|
||||
```
|
||||
|
||||
### 工具使用
|
||||
|
||||
具体的工具使用步骤,可以左键单击以下链接了解:
|
||||
|
||||
[工具使用说明](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/dts2cpp/docs/usage/dts2cpp_INSTRUCTION_ZH.md)
|
||||
|
||||
### 工具输出
|
||||
|
||||
在window环境下的,根据输入文件@ohos.napitest.d.ts生成的输出文件,如下所示:
|
||||
|
||||
![](./docs/figures/pic-d-ts-transition_result.png)
|
||||
|
||||
### 代码集成
|
||||
|
||||
为了实现工具生成的接口被其它子系统或者应用调用,需将生成的代码编译集成到OpenHarmony系统中,编译生成动态库。
|
||||
|
||||
把工具的生成代码集成到OpenHarmony的具体操作步骤,可以左键单击以下链接了解:
|
||||
|
||||
[生成代码集成到OpenHarmony的方法](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/dts2cpp/docs/usage/dts2cpp_ENSEMBLE_METHOD_ZH.md)
|
||||
|
||||
### 测试调用
|
||||
|
||||
为验证工具生成的接口是否可被应用调用,需编写app进行测试。具体如何操作可左键单击以下链接了解:
|
||||
|
||||
[工具集成测试](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/dts2cpp/docs/usage/dts2cpp_INTEGRATION_TESTING_ZH.md)
|
||||
|
||||
## 工具开发说明
|
||||
|
||||
### 对象
|
||||
|
||||
工具的开发者
|
||||
|
||||
### 开发场景
|
||||
|
||||
若当前工具的功能已经不能满足开发者的全部需求,则开发者可以基于已有的源码对工具进行二次开发,来增强工具的能力,编译打包生成自定义的可执行文件和插件。
|
||||
|
||||
### 开发步骤
|
||||
|
||||
开发者可以根据如下的步骤来完成对工具的开发:
|
||||
|
||||
[工具开发说明](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/dts2cpp/docs/guide/DEVELOP_ZH.md)
|
||||
|
||||
## 版本说明
|
||||
|
||||
当前版本已支持的特性和待开发的特性,如下所示:
|
||||
|
||||
[已支持特性](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/dts2cpp/docs/release-notes)
|
||||
|
||||
[待支持特性](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/dts2cpp/docs/requirement/ROADMAP_ZH.md)
|
||||
|
||||
## FAQ
|
||||
对于常见问题解决方法指导如下:
|
||||
|
||||
[FAQ](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/dts2cpp/docs/guide/FAQ.md)
|
||||
|
||||
## 参与贡献
|
||||
|
||||
暂无
|
||||
|
||||
## 相关仓
|
||||
|
||||
[ts生成工具README_zh](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/h2dts/README_ZH.md)
|
68
src/cli/dts2cpp/dts2cpp_README_ZH.md
Normal file
68
src/cli/dts2cpp/dts2cpp_README_ZH.md
Normal file
@ -0,0 +1,68 @@
|
||||
# dts2cpp工具
|
||||
|
||||
## 简介
|
||||
dts2cpp工具,它可以根据用户指定路径下的ts(typescript)接口文件一键生成NAPI框架代码、业务代码框架、GN文件等。在开发JS应用与NAPI间接口时,底层框架开发者无需关注js语法、C++与JS之间的数据类型转换等上层应用转换逻辑,只关注底层业务逻辑即可,专业的人做专业的事,从而可以大大提高开发效率。
|
||||
|
||||
## 约束
|
||||
系统:建议Ubuntu 20.04或者Windows 10
|
||||
|
||||
依赖版本:VS Code 1.62.0
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 生成框架
|
||||
|
||||
1.安装typescript:在napi_generator/src/cli/dts2cpp/src目录下执行命令:
|
||||
|
||||
npm i typescript
|
||||
|
||||
2.安装stdio:在napi_generator/src/cli/dts2cpp目录下执行命令:
|
||||
|
||||
npm i stdio
|
||||
|
||||
3.将待转换的文件@ohos.napitest.d.ts拷贝到napi_generator/src/cli/dts2cpp/src下,并在该目录下新建out目录;@ohos.napitest.d.ts如下所示:
|
||||
|
||||
```
|
||||
declare namespace napitest {
|
||||
function funcTest(v: boolean): string;
|
||||
}
|
||||
export default napitest;
|
||||
```
|
||||
|
||||
4.在napi_generator/src/cli/dts2cpp/src下执行以下命令生成napi框架代码:
|
||||
|
||||
```
|
||||
node gen\cmd_gen.js -f @ohos.napitest.d.ts -o out
|
||||
```
|
||||
|
||||
其中,参数详情如下:
|
||||
|
||||
-f, 待转换的.d.ts文件,若同时转换多个文件,文件之间用“,”隔开;
|
||||
|
||||
-d, 根据指定路径转换该文件夹中所有.d.ts文件;
|
||||
|
||||
-i, 可选参数,默认false,待转换.d.ts文件中引用非basic.d.ts的ts文件时打开开关;
|
||||
|
||||
-o, 可选参数,默认为当前目录,指定生成框架代码输出路径;
|
||||
|
||||
-n, 可选参数,默认为uint32_t,指定生成框架代码中number类型全部为指定类型;
|
||||
|
||||
-s, 可选参数,默认为不配置业务代码,指定生成框架代码的业务配置文件,用于粘合工具代码和业务代码的配置。
|
||||
|
||||
备注1:-f与-d两个参数只选其中一个参数即可。
|
||||
|
||||
备注2:若.d.ts文件中声明了其它.d.ts文件,将此类文件放置在待转换.d.ts文件同级目录。
|
||||
|
||||
5.输出文件如下所示:
|
||||
|
||||
![](./docs/figures/dts2cpp_outResult.png)
|
||||
|
||||
### 集成
|
||||
|
||||
[生成代码集成到OpenHarmony的方法](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/dts2cpp/docs/usage/dts2cpp_ENSEMBLE_METHOD_ZH.md)
|
||||
|
||||
### 调用
|
||||
|
||||
NAPI框架代码生成后,系统框架开发者进行二次开发后,即可集成到OpenHarmony编译系统,生成对应的库文件,供应用开发者调用接口。工具集成测试的具体操作步骤可以左键单击以下链接了解:
|
||||
|
||||
[工具集成测试](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/dts2cpp/docs/usage/dts2cpp_INTEGRATION_TESTING_ZH.md)
|
@ -1,18 +1,7 @@
|
||||
# h2dts工具
|
||||
|
||||
## 简介
|
||||
h2dts工具,即Ts接口生成工具,它可以根据定义在c++头文件中的接口,生成type-script语言的ts接口文件。若某个服务实现方式为c++,且供应用层访问的接口已在.h文件中定义,此时,NAPI接口开发者使用此工具可一键生成对应的ts文件,进而将生成的ts文件作为NAPI框架生成代码工具的输入,生成NAPI框架代码。串行使用ts接口生成工具、NAPI框架代码生成工具,形成工具链,达到降低NAPI接口开发难度,提高开发效率。目前工具支持可执行文件、IntelliJ插件两种入口。
|
||||
|
||||
├── napi_generator # 工具集
|
||||
│ ├── ... # 其它文件
|
||||
│ ├── src
|
||||
│ │ ├── ...
|
||||
│ │ ├── cli
|
||||
│ │ | ├── ... # 其它工具
|
||||
│ │ | ├── h2dts/src # 工具源码
|
||||
│ │ │ │ ├── tsGen # Ts框架工具源码
|
||||
│ │ | │ │ ├── header_parser.py # 解析C++头文件并生成表示类的数据结构
|
||||
│ │ | │ │ |── tsMain.js # Ts框架工具源码入口
|
||||
h2dts工具,即Ts接口生成工具,它可以根据定义在c++头文件中的接口,生成type-script语言的ts接口文件。若某个服务实现方式为c++,且供应用层访问的接口已在.h文件中定义,此时,NAPI接口开发者使用此工具可一键生成对应的ts文件,进而将生成的ts文件作为NAPI框架生成代码工具的输入,生成NAPI框架代码。串行使用ts接口生成工具、NAPI框架代码生成工具,形成工具链,达到降低NAPI接口开发难度,提高开发效率。
|
||||
|
||||
## 约束
|
||||
系统:建议Ubuntu 20.04或者Windows 10
|
||||
@ -21,108 +10,53 @@ h2dts工具,即Ts接口生成工具,它可以根据定义在c++头文件中
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 使用对象
|
||||
1.安装typescript:在napi_generator/src/cli/h2dts/src目录下执行命令:
|
||||
|
||||
系统开发者、应用Native开发者
|
||||
npm i typescript
|
||||
|
||||
### 使用场景
|
||||
2.安装stdio:在napi_generator/src/cli/h2dts目录下执行命令:
|
||||
|
||||
1) 系统框架层新增子系统,需对应用层提供接口。
|
||||
2) 系统框架层子系统能力增强后,需对应用层提供新接口。
|
||||
3) 应用层引入C++三方库,需增加OpenHarmony应用层接口。
|
||||
npm i stdio
|
||||
|
||||
### 工具获取
|
||||
|
||||
工具有两种类型,分别是可执行文件、IntelliJ插件。其中的可执行文件可根据工具使用者的开发环境选择,支持Windows,Linux和Mac。可执行文件、IntelliJ插下载路径如下:
|
||||
|
||||
[下载链接](http://ftp.kaihongdigi.com:5000/fsdownload/mKjfCmPjk/generator_outputs_NAPI_0930)
|
||||
|
||||
### 工具输入
|
||||
|
||||
根据使用者指定的.h文件,工具会输出对应的ts接口文件。为了方便使用者快速上手工具,可供测试的test.h文件样例如下:
|
||||
3.将待转换的文件tsTest.h拷贝到napi_generator/src/cli/h2dts/src/tsGen下;TsGenTest.h文件如下所示:
|
||||
|
||||
```
|
||||
#ifndef TSGENTEST_H
|
||||
#define TSGENTEST_H
|
||||
|
||||
#include < string >
|
||||
#include < vector >
|
||||
using namespace std;
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
|
||||
class TestA {
|
||||
public:
|
||||
char16_t string1;
|
||||
void add(string v, long double v1[]);
|
||||
};
|
||||
double count(double v, double v1[]);
|
||||
|
||||
namespace Space {
|
||||
class TestBB {
|
||||
public:
|
||||
short string4;
|
||||
bool ifExist(bool v, bool v1[]);
|
||||
};
|
||||
uint32_t max(uint32_t v, uint32_t v1[]);
|
||||
}
|
||||
namespace OHOS {
|
||||
class TsGenTest {
|
||||
public:
|
||||
std::string getServName();
|
||||
std::string getServTime();
|
||||
int32_t doSum(int32_t num1, int32_t num2);
|
||||
double addCount(double newNum);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
```
|
||||
|
||||
### 工具使用
|
||||
4.在napi_generator/src/cli/h2dts/src/tsGen下执行以下命令生成ts声明文件:
|
||||
|
||||
具体的工具使用步骤,可以左键单击以下链接了解:
|
||||
```
|
||||
node cmd_gen.js -f TsGenTest.h
|
||||
```
|
||||
|
||||
[工具使用说明](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/h2dts/docs/usage/INSTRUCTION_ZH.md)
|
||||
其中,参数详情如下:
|
||||
-f, 待转换的.h文件,若同时转换多个文件,文件之间用“,”隔开;
|
||||
-d, 根据指定路径转换该文件夹中所有.h文件;
|
||||
-t, 区分ts生成与napi转换工具,值为true时表示ts生成,false表示napi转换,默认为false;
|
||||
-o, 可选参数,默认为当前目录,指定生成框架代码输出路径。
|
||||
|
||||
### 工具输出
|
||||
备注:-f与-d两个参数只选其中一个参数即可。
|
||||
|
||||
在window环境下的,根据输入文件test.h,生成的输出文件,如下所示:
|
||||
5.执行成功后在napi_generator/src/cli/h2dts/src/tsGen下生成TsGenTest.d.ts声明文件
|
||||
|
||||
![](./docs/figures/h-2-ts-succ.png)
|
||||
```
|
||||
TsGenTest.d.ts
|
||||
```
|
||||
|
||||
|
||||
其中生成的"test.d.ts"文件,定义了应用开发接口,如下所示:
|
||||
|
||||
declare class TestA {
|
||||
string1: string;
|
||||
add(v: string, v1: Array<number>): void;
|
||||
}
|
||||
declare namespace Space {
|
||||
function max(v: number, v1: Array<number>): number;
|
||||
class TestBB {
|
||||
string4: number;
|
||||
ifExist(v: boolean, v1: Array<boolean>): boolean;
|
||||
}
|
||||
}
|
||||
declare function count(v: number, v1: Array<number>): number;
|
||||
|
||||
export default Space;
|
||||
|
||||
|
||||
## 工具开发说明
|
||||
|
||||
### 对象
|
||||
|
||||
工具的开发者
|
||||
|
||||
### 开发场景
|
||||
|
||||
若当前工具的功能已经不能满足开发者的全部需求,则开发者可以基于已有的源码对工具进行二次开发,来增强工具的能力,编译打包生成自定义的可执行文件和插件。
|
||||
|
||||
### 开发步骤
|
||||
|
||||
开发者可以根据如下的步骤来完成对工具的开发:
|
||||
|
||||
[工具开发说明](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/h2dts/docs/guide/DEVELOP_ZH.md)
|
||||
|
||||
## 版本说明
|
||||
|
||||
[版本说明](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/h2dts/docs/release-notes/ts_Gen-1.0.md)
|
||||
|
||||
## FAQ
|
||||
|
||||
[FAQ](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/h2dts/docs/guide/FAQ.md)
|
||||
|
||||
## 参与贡献
|
||||
|
||||
暂无
|
||||
|
||||
## 相关仓
|
||||
|
||||
暂无
|
||||
|
63
src/cli/h2dtscpp/h2dtscpp_README.md
Normal file
63
src/cli/h2dtscpp/h2dtscpp_README.md
Normal file
@ -0,0 +1,63 @@
|
||||
# h2dtscpp工具
|
||||
|
||||
## 简介
|
||||
|
||||
h2dtscpp工具即NATIVE生成工具,该工具由C++语法解释器和代码生成器两部分组成。C++语法解释器解析用户输入的.h文件内容,通过C++语法解析,将文件内容分解为类、方法、入参、成员属性等元素;代码生成器根据从语法解析器得到的这些元素,转换为对应的typescript语法的接口、方法、参数代码,生成.ts文件内容;同时通过语法解析器得到的元素,生成.h文件对应的napi框架代码和接口调用测试代码。
|
||||
|
||||
## 约束
|
||||
|
||||
系统:建议Windows 10
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 生成
|
||||
|
||||
1.安装typescript:使用管理员身份在napi_generator/src/cli/h2dtscpp/src目录下执行命令:
|
||||
|
||||
npm i typescript
|
||||
|
||||
2.安装stdio:使用管理员身份在napi_generator/src/cli/h2dtscpp/src目录下执行命令:
|
||||
|
||||
npm i stdio
|
||||
|
||||
3.将待转换的.h文件拷贝到napi_generator/src/cli/h2dtscpp/src下,如 [cJSON测试三方库](https://gitee.com/openharmony/napi_generator/releases/tag/测试用资源) 的cJSON.h,并新建out目录。
|
||||
|
||||
4.在napi_generator/src/cli/h2dtscpp/src执行以下命令:
|
||||
|
||||
```
|
||||
node src\main.js -f cJSON.h -o out
|
||||
```
|
||||
|
||||
其中,参数详情如下:
|
||||
|
||||
-f, 必选参数,待转换的.h文件;如cJSON.h。
|
||||
|
||||
-t, 可选参数,测试用例文件Ability.test.ets文件路径,默认路径为.h文件目录下testout文件夹下创建的xxxAbility.test.ets文件路径(如:testout/cJSONAbility.test.ets)。
|
||||
|
||||
-i, 可选参数,ts声明文件index.s.ts文件路径,默认路径为.h文件目录下tsout文件夹下创建的index.d.ts文件路径(如:tsout/index.d.ts)
|
||||
|
||||
index.d.ts文件路径;
|
||||
|
||||
-o, 可选参数,生成的.cpp文件所在路径,默认路径为.h文件目录下创建的cppout文件夹路径;
|
||||
|
||||
5.执行成功后在out目录下生成以下文件夹
|
||||
|
||||
![](./docs/figures/h2dtscpp_out_example.png)
|
||||
|
||||
tsout文件夹下内容如下所示:
|
||||
|
||||
![](./docs/figures/h2dtscpp_dtsout_example.png)
|
||||
|
||||
testout文件夹下内容如下所示:
|
||||
|
||||
![](./docs/figures/h2dtscpp_testout_example.png)
|
||||
|
||||
cppout文件夹下内容(部分文件截图)如下所示:
|
||||
|
||||
![](./docs/figures/h2dtscpp_cppout_example.png)
|
||||
|
||||
### 测试
|
||||
|
||||
查看生成代码是否能正确编译,点击下面链接查看:
|
||||
|
||||
[工具使用说明](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/h2dtscpp/docs/usage/INSTRUCTION_ZH.md)
|
BIN
src/cli/h2sa/docs/figures/h2sa_outRes.png
Normal file
BIN
src/cli/h2sa/docs/figures/h2sa_outRes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -2,19 +2,7 @@
|
||||
|
||||
## 简介
|
||||
|
||||
h2sa工具,即SERVICE框架生成工具,当开发者为OpenHarmony系统框架开发某些功能时,有时需要将这个功能包装成一个独立的服务进程运行在系统中,为了其它应用进程能够调用此服务,开发人员需要基于系统IPC通信框架编写一套远程接口调用实现。实现Service远程调用接口需要开发人员熟悉IPC通信框架,了解proxy/stub的继承与实现方式,掌握C++类型转为MessageParcel数据包的各种API方法,有一定的学习成本。而Service代码生成工具能够帮助使用者生成框架代码,提升开发效率。用户只需提供一个定义远程方法的.h头文件,工具会自动生成整个Service框架的代码,包含Ability注册、proxy/stub类实现、MessageParcel数据包构造、Service子系统编译及开机自启动相关配置文件。目前工具支持命令行和VS Code插件两种入口。
|
||||
|
||||
├── napi_generator # NAPI框架代码生成工具
|
||||
│ ├── ... # 其它文档
|
||||
│ ├── src
|
||||
│ │ ├── ...
|
||||
│ │ ├── cli # 脚手架源码
|
||||
│ │ | ├── h2sa/src # 工具源码
|
||||
│ │ | | ├── src
|
||||
│ │ | | | ├── tools # 公共模块代码,包括消息体校验、文件读写、正则表达式转换等
|
||||
│ │ | | | ├── gen # 生成器
|
||||
│ │ | | ├── package.json # 配置文件
|
||||
│ │ | ├── ... # 其它工具
|
||||
h2sa工具,即SERVICE框架生成工具,当开发者为OpenHarmony系统框架开发某些功能时,有时需要将这个功能包装成一个独立的服务进程运行在系统中,为了其它应用进程能够调用此服务,开发人员需要基于系统IPC通信框架编写一套远程接口调用实现。实现Service远程调用接口需要开发人员熟悉IPC通信框架,了解proxy/stub的继承与实现方式,掌握C++类型转为MessageParcel数据包的各种API方法,有一定的学习成本。而Service代码生成工具能够帮助使用者生成框架代码,提升开发效率。用户只需提供一个定义远程方法的.h头文件,工具会自动生成整个Service框架的代码,包含Ability注册、proxy/stub类实现、MessageParcel数据包构造、Service子系统编译及开机自启动相关配置文件。
|
||||
|
||||
## 约束
|
||||
系统:建议Ubuntu 20.04或者Windows 10
|
||||
@ -23,16 +11,17 @@ h2sa工具,即SERVICE框架生成工具,当开发者为OpenHarmony系统框
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 使用对象
|
||||
### 生成
|
||||
|
||||
系统开发者
|
||||
### 使用场景
|
||||
1.安装typescript:在napi_generator/src/cli/h2sa/src/src目录下执行命令:
|
||||
|
||||
1) 开发者为OpenHarmony系统框架开发某些功能,并将该功能包装成一个独立的服务进程运行在系统中。
|
||||
npm i typescript
|
||||
|
||||
### 工具输入
|
||||
2.安装stdio:在napi_generator/src/cli/h2sa/src目录下执行命令:
|
||||
|
||||
根据使用者指定的.h头文件,工具会输出SERVICE框架代码。为了方便使用者快速上手工具,可供测试的.h文件如下所示:
|
||||
npm i stdio
|
||||
|
||||
3.将待转换的文件test.h文件拷贝到napi_generator/src/cli/h2sa/src/src/gen目录下;test.h文件示例如下所示:
|
||||
|
||||
```
|
||||
#ifndef TEST_H
|
||||
@ -62,58 +51,27 @@ namespace OHOS {
|
||||
*/
|
||||
```
|
||||
|
||||
### 工具使用
|
||||
4.在napi_generator/src/cli/h2sa/src目录下执行命令生成service框架代码:
|
||||
|
||||
#### 命令行使用方法
|
||||
```
|
||||
node main.js -f test.h
|
||||
```
|
||||
|
||||
[命令行使用说明](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/h2sa/docs/usage/h2sa_INSTRUCTION_ZH.md)
|
||||
其中,参数详情如下:
|
||||
-f,定义远程服务的.h文件;
|
||||
-l, 日志级别(0-3),默认为1;
|
||||
-o,生成框架代码输入到指定路径下;
|
||||
-s,指定serviceID。
|
||||
|
||||
#### VS Code插件使用方法
|
||||
5.输出testservice文件夹,其中的文件如下所示:
|
||||
|
||||
具体的插件使用步骤,可以左键单击以下链接了解:
|
||||
![](./docs/figures/h2sa_outRes.png)
|
||||
|
||||
[vscode工具使用说明](https://gitee.com/openharmony/napi_generator/tree/master/src/vscode_plugin/h2sa/service_vs_plugin/docs/usage/INSTRUCTION_ZH.md)
|
||||
### 集成
|
||||
|
||||
### 工具输出
|
||||
Service框架代码生成后,系统框架开发者进行二次开发后,即可集成到OpenHarmony编译系统,生成对应的库文件,供应用开发者调用接口。工具集成到OpenHarmony的具体操作步骤可以左键单击以下链接了解:
|
||||
|
||||
在window环境下的,根据输入.h文件生成的输出文件,如下所示:
|
||||
[工具集成](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/h2sa/docs/usage/h2sa_ENSEMBLE_METHOD_ZH.md)
|
||||
|
||||
![](./docs/figures/service_framework.png)
|
||||
|
||||
### 工具集成
|
||||
|
||||
[工具输出文件集成到OpenHarmony](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/h2sa/docs/usage/h2sa_ENSEMBLE_METHOD_ZH.md)
|
||||
|
||||
## 工具开发说明
|
||||
|
||||
### 对象
|
||||
|
||||
工具的开发者
|
||||
|
||||
### 开发场景
|
||||
|
||||
若当前工具的功能已经不能满足开发者的全部需求,则开发者可以基于已有的源码对工具进行二次开发,来增强工具的能力,编译打包生成自定义的可执行文件和插件。
|
||||
|
||||
### 开发步骤
|
||||
|
||||
开发者可以根据如下的步骤来完成对工具的开发:
|
||||
|
||||
[工具开发说明](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/h2sa/docs/guide/DEVELOP_ZH.md)
|
||||
|
||||
## 版本说明
|
||||
|
||||
[已支持特性](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/h2sa/docs/release-notes/Service-1.0.md)
|
||||
|
||||
[待开发特性](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/h2sa/docs/requirement/ROADMAP_ZH.md)
|
||||
|
||||
## FAQ
|
||||
|
||||
[FAQ](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/h2sa/docs/guide/FAQ.md)
|
||||
|
||||
## 参与贡献
|
||||
|
||||
暂无
|
||||
|
||||
## 相关仓
|
||||
|
||||
暂无
|
||||
|
@ -2,14 +2,7 @@
|
||||
|
||||
## 简介
|
||||
|
||||
scan工具即API扫描工具,它可以扫描三方库中包含OpenHarmony源码不包含的接口,并输出result.xlsx文档。开发者移植三方库到OpenHarmony源码中,若三方库中包含一些OpenHarmony中不存在的接口,便会增加移植难度。此时可使用API扫描工具,提前预知风险接口,降低移植难度,提高开发效率。目前工具支持命令行和VS Code插件两种入口。
|
||||
|
||||
├── napi_generator
|
||||
│ ├── ... # 其它文档
|
||||
│ ├── src/tool
|
||||
│ │ ├── api # api扫描工具
|
||||
│ │ | ├── api_scan_vs_plugin # VS Code插件源码
|
||||
│ │ | ├── ...
|
||||
scan工具可以扫描三方库中包含OpenHarmony源码不包含的接口,并输出result.xlsx文档。开发者移植三方库到OpenHarmony源码中,若三方库中包含一些OpenHarmony中不存在的接口,便会增加移植难度。此时可使用API扫描工具,提前预知风险接口,降低移植难度,提高开发效率。
|
||||
|
||||
## 约束
|
||||
系统:建议Ubuntu 20.04或者Windows 10
|
||||
@ -18,46 +11,33 @@ scan工具即API扫描工具,它可以扫描三方库中包含OpenHarmony源
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 使用对象
|
||||
1.下载Andr_N_Games_api.xlsx文件,并放置在napi_generator/src/tool/api/src文件夹下,下载链接如下:
|
||||
|
||||
系统开发者
|
||||
### 使用场景
|
||||
// todo
|
||||
|
||||
移植三方库到OpenHarmony前预知风险接口。
|
||||
2.安装typescript:在napi_generator/src/tool/api/src目录下执行命令:
|
||||
|
||||
### 工具获取
|
||||
npm i typescript
|
||||
|
||||
#### 命令行
|
||||
3.安装stdio:在napi_generator/src/tool/api/src目录下执行命令:
|
||||
|
||||
命令行工具可根据源码自行打包,打包步骤如下:
|
||||
npm i stdio
|
||||
|
||||
[工具开发说明](https://gitee.com/openharmony/napi_generator/tree/master/src/tool/api/api_scan_vs_plugin/docs/DEVELOP_ZH.md)
|
||||
|
||||
#### vscode插件
|
||||
|
||||
工具支持VS Code插件,可在VS Code插件市场直接下载。
|
||||
|
||||
### 工具输入
|
||||
|
||||
根据使用者指定三方库项目源码,工具会输出风险接口。为了方便使用者快速上手工具,此处使用opencv项目为例,项目目录如下:
|
||||
4.根据使用者指定三方库项目源码,工具会输出风险接口。为了方便使用者快速上手工具,此处使用opencv项目为例,项目目录如下:
|
||||
|
||||
![](./figures/opencv.png)
|
||||
|
||||
### 工具使用
|
||||
5.在napi_generator/src/tool/api/src下执行以下命令:
|
||||
|
||||
#### 命令行
|
||||
```
|
||||
node scan.js -d E:\aboutTest\opencv-4.x\opencv-4.x -o E:\aboutTest\opencv-4.x\opencv-4.x
|
||||
```
|
||||
|
||||
[命令行使用说明](https://gitee.com/openharmony/napi_generator/blob/master/src/tool/api/docs/scan_INSRTUCTION_ZH.md)
|
||||
其中,参数详情如下:
|
||||
-d, 被扫描项目的路径
|
||||
-o, 可选参数,默认为当前路径下,输出结果存放路径。
|
||||
|
||||
#### vscode插件
|
||||
|
||||
具体的工具使用步骤,可以左键单击以下链接了解:
|
||||
|
||||
[工具使用说明](https://gitee.com/openharmony/napi_generator/tree/master/src/tool/api/api_scan_vs_plugin/docs/INSTRUCTION_ZH.md)
|
||||
|
||||
### 工具输出
|
||||
|
||||
在window环境下的,根据输入三方库项目,生成的输出文件result.xlsx,如下所示:
|
||||
6.在window环境下的,根据输入三方库项目,生成的输出文件result.xlsx,如下所示:
|
||||
|
||||
![](./figures/opencv_result.png)
|
||||
|
||||
@ -66,19 +46,3 @@ scan工具即API扫描工具,它可以扫描三方库中包含OpenHarmony源
|
||||
![](./figures/opencv_include.png)
|
||||
|
||||
![](./figures/opencv_h.png)
|
||||
|
||||
## 版本说明
|
||||
|
||||
暂无
|
||||
|
||||
## FAQ
|
||||
|
||||
[FAQ](https://gitee.com/openharmony/napi_generator/tree/master/src/tool/api/FAQ.md)
|
||||
|
||||
## 参与贡献
|
||||
|
||||
暂无
|
||||
|
||||
## 相关仓
|
||||
|
||||
暂无
|
||||
|
Loading…
Reference in New Issue
Block a user