README_zh.md
1# GN脚本生成工具VS code插件说明
2
3## 简介
4
5GN脚本生成工具,它可以根据用户给定三方库项目的CMakeLists.txt文件,转换生成BUILD.gn文件。目前工具支持可执行文件、VS Code插件两种入口,本文主要介绍VS Code插件使用说明。
6
7## 目录
8
9 ├── napi_generator/src/vscode_plugin/cmake2gn # GN脚本生成工具
10 │ ├── gn_vs_plugin # VS Code插件代码
11 │ │ ├── docs # VS Code插件说明
12 │ │ ├── src # VS Code插件源码
13 │ │ └── README_zh # VS Code插件说明
14
15## 约束
16
17系统:建议Ubuntu 20.04或者Windows 10
18
19依赖版本:VS Code 1.62.0
20
21## 使用方法
22
23### 使用对象
24
25系统开发者
26
27### 使用场景
28
291)移植CMakeLists.txt编译方式的三方库到OpenHarmony源码中。
30
31### 工具使用
32
33插件下载路径如下:
34
35[下载链接](http://ftpkaihongdigi.i234.me:5000/fsdownload/1OjtRhtGf/gn-gen-0.0.1)
36
37具体的工具使用步骤,可以左键单击以下链接了解:
38
39[工具使用说明](https://gitee.com/openharmony/napi_generator/tree/master/src/vscode_plugin/cmake2gn/gn_vs_plugin/docs/usage/INSTRUCTION_ZH.md)
40
41### 工具输出
42
43根据使用者指定三方库的CMakeLists.txt文件,工具会输出对应的BUILD.gn文件。为了方便使用者快速上手工具,可供测试的三方库项目目录如下:
44
45 harmony@Ubuntu-64:~/OpenHarmony/third_party/mbedtls-development$ ls
46 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
47
48在linux环境下的,根据输入三方库项目的CMakeLists.txt文件,生成的输出文件,如下所示:
49
50 harmony@Ubuntu-64:~/OpenHarmony/third_party/mbedtls-development$ ls
51 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
52 harmony@Ubuntu-64:~/OpenHarmony/third_party/mbedtls-development$ cd build_tmp/
53 harmony@Ubuntu-64:~/OpenHarmony/third_party/mbedtls-development/build_tmp$ ls
54 3rdparty BUILD.gn cmake CMakeCache.txt CMakeFiles cmake_install.cmake CTestTestfile.cmake DartConfiguration.tcl include library Makefile ohos.toolchain.cmake programs scripts tests
55
56其中生成的BUILD.gn文件,内容如下所示:
57
58```
59import("//build/ohos.gni")
60
61group("all_targets") {
62 deps = [
63 #静态库
64 "//third_party/mbedtls-development/build_tmp/library:mbedcrypto",
65 "//third_party/mbedtls-development/build_tmp/library:mbedx509",
66 "//third_party/mbedtls-development/build_tmp/library:mbedtls",
67
68 #可执行程序
69 "//third_party/mbedtls-development/build_tmp/programs/aes:crypt_and_hash",
70 "//third_party/mbedtls-development/build_tmp/programs/cipher:cipher_aead_demo",
71 "//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_x509crl",
72 "//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_x509csr",
73 "//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_pubkey",
74 "//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_pkcs7",
75 "//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_privkey",
76 "//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_client",
77 "//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_dtlsserver",
78 "//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_dtlsclient",
79 "//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_x509crt",
80 "//third_party/mbedtls-development/build_tmp/programs/fuzz:fuzz_server",
81 "//third_party/mbedtls-development/build_tmp/programs/hash:generic_sum",
82 "//third_party/mbedtls-development/build_tmp/programs/hash:hello",
83 "//third_party/mbedtls-development/build_tmp/programs/hash:md_hmac_demo",
84 "//third_party/mbedtls-development/build_tmp/programs/pkey:mpi_demo",
85 "//third_party/mbedtls-development/build_tmp/programs/pkey:key_app",
86 "//third_party/mbedtls-development/build_tmp/programs/pkey:pk_encrypt",
87 "//third_party/mbedtls-development/build_tmp/programs/pkey:gen_key",
88 "//third_party/mbedtls-development/build_tmp/programs/pkey:ecdsa",
89 "//third_party/mbedtls-development/build_tmp/programs/pkey:rsa_encrypt",
90 "//third_party/mbedtls-development/build_tmp/programs/pkey:dh_client",
91 "//third_party/mbedtls-development/build_tmp/programs/pkey:dh_server",
92 "//third_party/mbedtls-development/build_tmp/programs/pkey:dh_genprime",
93 "//third_party/mbedtls-development/build_tmp/programs/pkey:ecdh_curve25519",
94 "//third_party/mbedtls-development/build_tmp/programs/pkey:pk_decrypt",
95 "//third_party/mbedtls-development/build_tmp/programs/pkey:pk_sign",
96 "//third_party/mbedtls-development/build_tmp/programs/pkey:key_app_writer",
97 "//third_party/mbedtls-development/build_tmp/programs/pkey:pk_verify",
98 "//third_party/mbedtls-development/build_tmp/programs/pkey:rsa_decrypt",
99 "//third_party/mbedtls-development/build_tmp/programs/pkey:rsa_genkey",
100 "//third_party/mbedtls-development/build_tmp/programs/pkey:rsa_sign",
101 "//third_party/mbedtls-development/build_tmp/programs/pkey:rsa_sign_pss",
102 "//third_party/mbedtls-development/build_tmp/programs/pkey:rsa_verify",
103 "//third_party/mbedtls-development/build_tmp/programs/pkey:rsa_verify_pss",
104 "//third_party/mbedtls-development/build_tmp/programs/psa:key_ladder_demo",
105 "//third_party/mbedtls-development/build_tmp/programs/psa:crypto_examples",
106 "//third_party/mbedtls-development/build_tmp/programs/psa:aead_demo",
107 "//third_party/mbedtls-development/build_tmp/programs/psa:hmac_demo",
108 "//third_party/mbedtls-development/build_tmp/programs/psa:psa_constant_names",
109 "//third_party/mbedtls-development/build_tmp/programs/random:gen_entropy",
110 "//third_party/mbedtls-development/build_tmp/programs/random:gen_random_ctr_drbg",
111 "//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_pthread_server",
112 "//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_client1",
113 "//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_client2",
114 "//third_party/mbedtls-development/build_tmp/programs/ssl:mini_client",
115 "//third_party/mbedtls-development/build_tmp/programs/ssl:dtls_server",
116 "//third_party/mbedtls-development/build_tmp/programs/ssl:dtls_client",
117 "//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_server",
118 "//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_server2",
119 "//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_context_info",
120 "//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_fork_server",
121 "//third_party/mbedtls-development/build_tmp/programs/ssl:ssl_mail_client",
122 "//third_party/mbedtls-development/build_tmp/programs/test:selftest",
123 "//third_party/mbedtls-development/build_tmp/programs/test:benchmark",
124 "//third_party/mbedtls-development/build_tmp/programs/test:udp_proxy",
125 "//third_party/mbedtls-development/build_tmp/programs/test:query_compile_time_config",
126 "//third_party/mbedtls-development/build_tmp/programs/test:zeroize",
127 "//third_party/mbedtls-development/build_tmp/programs/util:pem2der",
128 "//third_party/mbedtls-development/build_tmp/programs/util:strerror",
129 "//third_party/mbedtls-development/build_tmp/programs/x509:load_roots",
130 "//third_party/mbedtls-development/build_tmp/programs/x509:cert_req",
131 "//third_party/mbedtls-development/build_tmp/programs/x509:cert_write",
132 "//third_party/mbedtls-development/build_tmp/programs/x509:crl_app",
133 "//third_party/mbedtls-development/build_tmp/programs/x509:req_app",
134 "//third_party/mbedtls-development/build_tmp/programs/x509:cert_app",
135 "//third_party/mbedtls-development/build_tmp/tests:test_suite_x509write",
136 "//third_party/mbedtls-development/build_tmp/tests:test_suite_x509parse",
137 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_its",
138 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_storage_format.current",
139 "//third_party/mbedtls-development/build_tmp/tests:test_suite_timing",
140 "//third_party/mbedtls-development/build_tmp/tests:test_suite_ssl",
141 "//third_party/mbedtls-development/build_tmp/tests:test_suite_rsa",
142 "//third_party/mbedtls-development/build_tmp/tests:test_suite_entropy",
143 "//third_party/mbedtls-development/build_tmp/tests:test_suite_shax",
144 "//third_party/mbedtls-development/build_tmp/tests:test_suite_hmac_drbg.pr",
145 "//third_party/mbedtls-development/build_tmp/tests:test_suite_dhm",
146 "//third_party/mbedtls-development/build_tmp/tests:test_suite_ecdsa",
147 "//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.des",
148 "//third_party/mbedtls-development/build_tmp/tests:test_suite_poly1305",
149 "//third_party/mbedtls-development/build_tmp/tests:test_suite_ctr_drbg",
150 "//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.null",
151 "//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.gcm",
152 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_storage_format.misc",
153 "//third_party/mbedtls-development/build_tmp/tests:test_suite_ccm",
154 "//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.camellia",
155 "//third_party/mbedtls-development/build_tmp/tests:test_suite_chachapoly",
156 "//third_party/mbedtls-development/build_tmp/tests:test_suite_mdx",
157 "//third_party/mbedtls-development/build_tmp/tests:test_suite_des",
158 "//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.chacha20",
159 "//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum.generated",
160 "//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum_mod",
161 "//third_party/mbedtls-development/build_tmp/tests:test_suite_chacha20",
162 "//third_party/mbedtls-development/build_tmp/tests:test_suite_aria",
163 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_not_supported.generated",
164 "//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.padding",
165 "//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.nist_kw",
166 "//third_party/mbedtls-development/build_tmp/tests:test_suite_aes.ofb",
167 "//third_party/mbedtls-development/build_tmp/tests:test_suite_hmac_drbg.nopr",
168 "//third_party/mbedtls-development/build_tmp/tests:test_suite_aes.ecb",
169 "//third_party/mbedtls-development/build_tmp/tests:test_suite_hkdf",
170 "//third_party/mbedtls-development/build_tmp/tests:test_suite_aes.cfb",
171 "//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.ccm",
172 "//third_party/mbedtls-development/build_tmp/tests:test_suite_pkcs5",
173 "//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.aes",
174 "//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum.misc",
175 "//third_party/mbedtls-development/build_tmp/tests:test_suite_aes.rest",
176 "//third_party/mbedtls-development/build_tmp/tests:test_suite_cmac",
177 "//third_party/mbedtls-development/build_tmp/tests:test_suite_camellia",
178 "//third_party/mbedtls-development/build_tmp/tests:test_suite_ecdh",
179 "//third_party/mbedtls-development/build_tmp/tests:test_suite_md",
180 "//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.chachapoly",
181 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_storage_format.v0",
182 "//third_party/mbedtls-development/build_tmp/tests:test_suite_asn1parse",
183 "//third_party/mbedtls-development/build_tmp/tests:test_suite_asn1write",
184 "//third_party/mbedtls-development/build_tmp/tests:test_suite_base64",
185 "//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum_mod_raw.generated",
186 "//third_party/mbedtls-development/build_tmp/tests:test_suite_oid",
187 "//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.misc",
188 "//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum_core.misc",
189 "//third_party/mbedtls-development/build_tmp/tests:test_suite_ecjpake",
190 "//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum_core.generated",
191 "//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum_mod_raw",
192 "//third_party/mbedtls-development/build_tmp/tests:test_suite_random",
193 "//third_party/mbedtls-development/build_tmp/tests:test_suite_aes.cbc",
194 "//third_party/mbedtls-development/build_tmp/tests:test_suite_pk",
195 "//third_party/mbedtls-development/build_tmp/tests:test_suite_version",
196 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_se_driver_hal_mocks",
197 "//third_party/mbedtls-development/build_tmp/tests:test_suite_bignum_mod.generated",
198 "//third_party/mbedtls-development/build_tmp/tests:test_suite_debug",
199 "//third_party/mbedtls-development/build_tmp/tests:test_suite_pkcs1_v21",
200 "//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.aes128_de",
201 "//third_party/mbedtls-development/build_tmp/tests:test_suite_cipher.aria",
202 "//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.aes128_en",
203 "//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.aes192_de",
204 "//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.camellia",
205 "//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.aes192_en",
206 "//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.aes256_de",
207 "//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.aes256_en",
208 "//third_party/mbedtls-development/build_tmp/tests:test_suite_gcm.misc",
209 "//third_party/mbedtls-development/build_tmp/tests:test_suite_hmac_drbg.misc",
210 "//third_party/mbedtls-development/build_tmp/tests:test_suite_hmac_drbg.no_reseed",
211 "//third_party/mbedtls-development/build_tmp/tests:test_suite_lms",
212 "//third_party/mbedtls-development/build_tmp/tests:test_suite_mps",
213 "//third_party/mbedtls-development/build_tmp/tests:test_suite_memory_buffer_alloc",
214 "//third_party/mbedtls-development/build_tmp/tests:test_suite_net",
215 "//third_party/mbedtls-development/build_tmp/tests:test_suite_nist_kw",
216 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_metadata",
217 "//third_party/mbedtls-development/build_tmp/tests:test_suite_pkparse",
218 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_hash",
219 "//third_party/mbedtls-development/build_tmp/tests:test_suite_pem",
220 "//third_party/mbedtls-development/build_tmp/tests:test_suite_pkcs12",
221 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_attributes",
222 "//third_party/mbedtls-development/build_tmp/tests:test_suite_aes.xts",
223 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_op_fail.generated",
224 "//third_party/mbedtls-development/build_tmp/tests:test_suite_pkcs1_v15",
225 "//third_party/mbedtls-development/build_tmp/tests:test_suite_pkcs7",
226 "//third_party/mbedtls-development/build_tmp/tests:test_suite_pkwrite",
227 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto",
228 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_not_supported.misc",
229 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_driver_wrappers",
230 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_entropy",
231 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_generate_key.generated",
232 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_init",
233 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_op_fail.misc",
234 "//third_party/mbedtls-development/build_tmp/tests:test_suite_error",
235 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_pake",
236 "//third_party/mbedtls-development/build_tmp/tests:test_suite_lmots",
237 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_persistent_key",
238 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_se_driver_hal",
239 "//third_party/mbedtls-development/build_tmp/tests:test_suite_ecp",
240 "//third_party/mbedtls-development/build_tmp/tests:test_suite_psa_crypto_slot_management",
241
242 ]
243}
244```
245
246
247
248## 开发说明
249
250### 对象
251
252工具的开发者
253
254### 开发场景
255
256若当前工具的功能已经不能满足开发者的全部需求,则开发者可以基于已有的源码对工具进行二次开发,来增强工具的能力,编译打包生成自定义的可执行文件和插件。
257### 开发步骤
258
259开发者可以根据如下的步骤来完成对工具VSCode插件的开发:
260
261[工具开发说明](https://gitee.com/openharmony/napi_generator/tree/master/src/vscode_plugin/cmake2gn/gn_vs_plugin/docs/guide/DEVELOP_ZH.md)
262
263## FAQ
264
265对于常见问题解决方法指导如下:
266
267[FAQ](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/cmake2gn/docs/guide/FAQ.md)
268
269## 相关仓
270
271暂无