1# SERVICE框架生成工具开发说明 2 3若当前工具功能不满足开发者需求,开发者需增强工具能力,则可基于已有源码进行工具二次开发,编译打包生成自定义的可执行文件和插件。 4 5## 工具开发 6 7### 可执行文件开发说明 8 9#### 环境说明 10 11系统:建议Ubuntu 20.04或者Windows 10 12 13#### 开发步骤 14 15##### Linux 16 171.安装typescript:在napi_generator/hdc/service/service-gen/src目录下执行命令: 18 19 npm i typescript 20 212.安装stdio:在napi_generator/hdc/service/service-gen目录下执行命令: 22 23 npm i stdio 24 253.安装pkg : 在napi_generator/hdc/service/service-gen目录下执行命令: 26 27 sudo npm i -g pkg 28 294.打包三个版本 : 执行命令: 30 31 pkg . 32 33执行以上步骤后,即可在napi_generator/hdc/service/service-gen目录下生成Windows、linux、mac系统下的可执行程序: 34 35 service-gen-win.exe、service-gen-linux、service-gen-macos 36 375.根据需求打包指定系统下的可执行文件。若想只打包windows系统下可执行文件,可执行命令: 38 39 pkg -t node14-win . -o service-gen-win.exe 40 41若想只打包linux系统下可执行文件,可执行命令: 42 43 pkg -t node14-linux . -o service-gen-linux 44 45若想只打包macos系统下可执行文件,可执行命令: 46 47 pkg -t node14-macos . -o service-gen-macos 48 49备注:参数-t为指定系统,参数-o为指定可执行文件名称。 50 516.编译生成 header_parser.exe 52 536.1 安装python库 CppHeaderParser,在header_parser/src_code中下载CppHeaderParser.zip,解压后替换本地Python文件夹中CppHeaderParser(如 /usr/local/lib/python3.8/dist-packages/CppHeaderParser)目录下的全部文件 54 55``` 56sudo pip install CppHeaderParser 57``` 58 59[下载链接1](http://ftpkaihongdigi.i234.me:5000/sharing/kBG1c7CvT) 60 61[下载链接2](http://ftp.kaihong.com:5000/sharing/kBG1c7CvT) 62 63[下载链接3](http://ftp.kaihongdigi.com:5000/sharing/kBG1c7CvT) 64 656.2 安装pyinstaller 66 67``` 68sudo pip install pyinstaller 69``` 70 716.3 将python脚本打包成独立可执行文件 72 73进入 ./src/tsGen 目录后执行如下命令: 74 75``` 76pyinstaller -F header_parser.py 77``` 78 79打包后的可执行文件在dist目录中 80 81``` 82./src/tsGen/dist/header_parser.exe 83``` 84 85 86##### Windows 87 881.安装typescript:使用管理员身份在napi_generator/hdc/service/service-gen/src目录下执行命令: 89 90 npm i typescript 91 922.安装stdio:使用管理员身份在napi_generator/hdc/service/service-gen目录下执行命令: 93 94 npm i stdio 95 963.安装pkg : 使用管理员身份在napi_generator/hdc/service/service-gen目录下执行命令: 97 98 npm i -g pkg 99 1004.打包三个版本 : 使用管理员身份执行命令: 101 102 pkg . 103 104执行以上步骤后,即可在napi_generator/hdc/service/service-gen目录下生成Windows、linux、mac系统下的可执行程序: 105 106 service-gen-win.exe、service-gen-linux、service-gen-macos 107 1085.根据需求打包指定系统下的可执行文件。若想只打包windows系统下可执行文件,可执行命令: 109 110 pkg -t node14-win . -o service-gen-win.exe 111 112若想只打包linux系统下可执行文件,可执行命令: 113 114 pkg -t node14-linux . -o service-gen-linux 115 116若想只打包macos系统下可执行文件,可执行命令: 117 118 pkg -t node14-macos . -o service-gen-macos 119 1206.编译生成 header_parser.exe 121 1226.1 安装python库 CppHeaderParser,在header_parser/src_code中下载CppHeaderParser.zip,解压后替换本地Python文件夹中CppHeaderParser(如 C:\Python310\Lib\site-packages\CppHeaderParser)目录下的全部文件 123 124``` 125pip install CppHeaderParser 126``` 127 128[下载链接1](http://ftpkaihongdigi.i234.me:5000/sharing/kBG1c7CvT) 129 130[下载链接2](http://ftp.kaihong.com:5000/sharing/kBG1c7CvT) 131 132[下载链接3](http://ftp.kaihongdigi.com:5000/sharing/kBG1c7CvT) 133 1346.2 安装pyinstaller 135 136``` 137pip install pyinstaller 138``` 139 1406.3 将python脚本打包成独立可执行文件 141 142进入 ./src/tsGen 目录后执行如下命令: 143 144``` 145pyinstaller -F header_parser.py 146``` 147 148打包后的可执行文件在dist目录中 149 150``` 151./src/tsGen/dist/header_parser.exe 152``` 153 154### VS插件开发说明 155 156具体的插件开发步骤,可以左键单击以下链接了解: 157 158[VS插件开发说明](https://gitee.com/openharmony/napi_generator/blob/master/hdc/service/service_vs_plugin/docs/DEVELOP_ZH.md) 159