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