1# 编译构建调试指导
2
3## Vs Code插件配置
4
5建议初学者配置Vs Code并安装插件实现高效Openharmony项目的高效开发。以下列出了常用的插件列表以及功能,开发者可以按需进行配置和使用。
6
7| 插件               | 作用                                                  |
8| ------------------ | ----------------------------------------------------- |
9| Remote-SSH         | 连接远程服务器                                        |
10| GN                 | GN语法高亮                                            |
11| GN format          | GN格式化工具,实现右键格式化GN文件                    |
12| GN Language Server | GN关键字说明、提示、补全、跳转                        |
13| python             | Python语法高亮,debug                                 |
14| Pylance            | Python代码补全,API说明                               |
15| gitlens            | 增强Git功能,可视化本地分支、远程分支以及历史提交信息 |
16| clangd             | LLVM官方插件,实现代码跳转,自动补全,语义检查等功能  |
17
18插件Remote-SSH示例:
19
20![remote_ssh](./figures/remote_ssh.png)
21
22### Preloader、Loader阶段调试
23
24#### 1.背景介绍
25
26建议开发者在阅读本教程前先查看[编译构建指导文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-build-all.md),对整个Openharmony的产品、子系统、部件、模块以及构建系统GN和Ninja等概念有基本了解。接下来介绍整个Openahrmony的编译流程和各阶段的调试定位方法。
27
28Openharmony完整的编译构建流程主要可以分成以下四个阶段:Preloader、Loader、GN以及Ninja过程。
29
30![preloader_loader](./figures/preloader_loader_gn_ninja.png)
31
32​	Preloader和Loader阶段主要是执行python脚本preloader.pyloader.py,Preloader阶段根据vendor仓的产品配置config.json文件对产品配置进行解析,并将解析结果输出到out/preloader/{product_name}目录下,loader阶段进行部件化配置的加载,并将解析结果输出到out/{product_name}/build_configs文件夹下。以下主要介绍preloader和loader阶段的调试过程,帮助开发者更好的调试Openharmony代码,定位preloader和loader阶段的错误,提升开发效率。
33
34![preloader_out](./figures/preloader_out.png)
35
36#### 2. preloader阶段调试
37
38- 配置launch.json
39
40点击Vs Code左侧”运行与调试按钮“,配置launch.json内容
41
42![launch_json](./figures/launch_json.png)
43
44```
45{
46    // 使用 IntelliSense 了解相关属性。
47    // 悬停以查看现有属性的描述。
48    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
49    "version": "0.2.0",
50    "configurations": [
51        {
52            "name": "hb_debug",
53            "type": "python",
54            "request": "launch",
55            "program": "/mnt/xiaoxiaoliang/code/ohos/build.py",
56            "console": "integratedTerminal",
57            "args": [ "-p" , "rk3568" ],
58            "cwd": "/mnt/xiaoxiaoliang/code/ohos",
59            "justMyCode": false
60        }
61    ]
62}
63```
64
65各字段含义:
66
67| 字段       | 含义                                                         |
68| ---------- | ------------------------------------------------------------ |
69| name       | 调试器名称,随便取一个就可以                                 |
70| type       | 必填项,调试类型,选择相应语言类型                           |
71| request    | 必填项,有两种类型,分别是 `launch` 和 `attach`,这里选launch即可 |
72| program    | 需要调试的脚本路径                                           |
73| console    | integratedTerminal、internalConsole、externalTerminal,这里选择integratedTerminal即可 |
74| args       | 传递给脚本的参数                                             |
75| cwd        | 脚本所在路径                                                 |
76| justMyCode | true或false,设置为true,只调试用户自己编写的代码,false则会调试标准库的代码 |
77
78- 开始调试,设置断点,然后点击hb_debug按钮进行调试
79
80![vscode_debug](./figures/vs_code_debug.png)
81
82| 字段     | 含义                             |
83| -------- | -------------------------------- |
84| 变量     | 查看变量的值,监控变量的变化情况 |
85| 监视     | 选择自己想要监控的变量           |
86| 调用堆栈 | 查看函数的调用堆栈               |
87| 断点     | 查看所有设置的断点信息           |
88
89- 单步调试等
90
91![单步调试](./figures/step_in.png)
92
93- 调试preloader、loader过程
94
95建议开发者基于以上方法对preloader和loader进行调试,从而查看产物与函数之间的一一对应关系,当编译出错时,分清楚出错阶段,进行对阶段的产物进行横向对比分析,找到问题根源
96
97## GN调试
98
99以下列表列出了常见的GN调试命令供开发者查阅和使用,主要介绍了命令以及它的详细使用方法。
100
101| 命令           | 作用                                                         | 详细命令                                                     |
102| -------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
103| gn gen         | 产生ninja文件                                                | gn gen [--check] [<ide options>] <out_dir>                   |
104| gn ls          | 列出目录下所有的target                                       | gn ls <out_dir> [<label_pattern>] [--default-toolchain] [--as=...] |
105| gn args        | 列出所有的gn参数                                             | gn args <out_dir> [--list] [--short] [--args] [--overrides-only] |
106| gn desc        | 列出target/config的所有信息                                  | gn desc <out_dir> <label or pattern> [<what to show>] [--blame]           [--format=json] |
107| gn path        | 查看两个target之间的依赖路径                                 | gn path <out_dir> <target_one> <target_two>                  |
108| gn refs        | 查看依赖关系                                                 | gn refs <out_dir> (<label_pattern>\|<label>\|<file>\|@<response_file>)* [--all]           [--default-toolchain] [--as=...] [--testonly=...] [--type=...] |
109| gn check       | 检查头文件的依赖是否正确                                     | gn check <out_dir> [<label_pattern>] [--force] [--check-generated] |
110| gn analyze     | 分析哪些目标受到文件列表的影响                               | gn analyze <out_dir> <input_path> <output_path>              |
111| gn meta        | 列出target的metadata的收集结果                               | gn meta <out_dir> <target>* --data=<key>[,<key>*]* [--walk=<key>[,<key>*]*]           [--rebase=<dest dir>] |
112| gn help        | 查看帮助文档                                                 | gn help <anything>                                           |
113| gn format      | 格式化gn文件                                                 | gn format [--dump-tree] (--stdin \| <list of build_files...>) |
114| gn clean       | 删除输出目录中除args.gn之外的内容                            | gn clean <out_dir>...                                        |
115| gn clean_stale | 从生成目录中删除不再需要的输出文件,同时删除它们的ninja构建记录 | gn clean_stale [--ninja-executable=...] <out_dir>...         |
116
117#### Thirdparty/gn调试过程
118
119建议初学者以Openharmony三方库的gn仓为例进行学习,首先进入third_party/gn/examples/simple_build文件夹,该文件描述了一个最基本的C++文件的编译配置,如下可执行程序hello依赖了动态库文件hello_shared以及静态库hello_static。
120
121```
122# Copyright 2014 The Chromium Authors. All rights reserved.
123# Use of this source code is governed by a BSD-style license that can be
124# found in the LICENSE file.
125executable("hello") {
126  sources = [ "hello.cc" ]
127  deps = [
128    ":hello_shared",
129    ":hello_static",
130  ]
131}
132shared_library("hello_shared") {
133  sources = [
134    "hello_shared.cc",
135    "hello_shared.h",
136  ]
137
138  defines = [ "HELLO_SHARED_IMPLEMENTATION" ]
139}
140static_library("hello_static") {
141  sources = [
142    "hello_static.cc",
143    "hello_static.h",
144  ]
145}
146```
147
148在目录下执行gn gen -C out同时进入out文件夹下,分别执行以下命令。
149
150- gn ls out
151
152  ```
153  //:hello
154  //:hello_shared
155  //:hello_static
156  ```
157
158  该命令列出了gn编译过程中的所有target列表,可以看出,包含一个可执行程序//:hello、一个动态库//:hello_shared和一个静态库//:hello_static。
159
160- gn refs out //:hello_shared
161
162  ```
163  //:hello
164  ```
165
166​       gn refs列出了哪些目标依赖了目标//:hello_shared,从上面可以看出目标//:hello依赖了目标//:hello_shared,从GN配置文件也可以看出来。
167
168- gn desc out //:hello_shared
169
170  ```
171  Target //:hello_shared
172  type: shared_library
173  toolchain: //build/toolchain:gcc
174
175  visibility
176    *
177
178  metadata
179    {
180
181    }
182
183  testonly
184    false
185
186  check_includes
187    true
188
189  allow_circular_includes_from
190
191  sources
192    //hello_shared.cc
193    //hello_shared.h
194
195  public
196    [All headers listed in the sources are public.]
197
198  configs (in order applying, try also --tree)
199    //build:compiler_defaults
200
201  outputs
202    //out/libhello_shared.so
203
204  cflags
205    -fPIC
206    -pthread
207
208  defines
209    HELLO_SHARED_IMPLEMENTATION
210
211  Direct dependencies (try also "--all", "--tree", or even "--all --tree")
212
213  externs
214  ```
215
216  gn desc查看目标//:hello_shared的所有信息,这个命令非常实用,记录了目标的visibility、metadata、cflags、defines等重要信息,建议开发者多使用该功能进行调试。
217
218- gn path out //:hello //:hello_shared
219
220  ```
221  //:hello --[private]-->
222  //:hello_shared
223
224  1 non-data path found. It is not public.
225  ```
226
227  查看两个目标之间的依赖路径。从上面我们可以看出,//:hello和//:hello_shared是私有依赖的关系,且两者是直接依赖的。
228
229- gn args --list out
230
231  ```
232  current_cpu
233      Current value (from the default) = ""
234        (Internally set; try `gn help current_cpu`.)
235
236  current_os
237      Current value (from the default) = ""
238        (Internally set; try `gn help current_os`.)
239
240  host_cpu
241      Current value (from the default) = "x64"
242        (Internally set; try `gn help host_cpu`.)
243
244  host_os
245      Current value (from the default) = "linux"
246        (Internally set; try `gn help host_os`.)
247
248  target_cpu
249      Current value (from the default) = ""
250        (Internally set; try `gn help target_cpu`.)
251
252  target_os
253      Current value (from the default) = ""
254        (Internally set; try `gn help target_os`.)
255  ```
256
257  查看编译过程中的gn参数列表。
258
259- gn check out
260
261  ```
262  Header dependency check OK
263  ```
264
265  查看编译过程中的头文件依赖是否正确。
266
267- gn format `find . -name "*.gni" -o -name "*.gn"`
268
269  上述命令可以格式化当前文件夹下的所有GN文件,包括.gni文件和.gn文件。
270
271#### Openharmony调试过程
272
273以编译rk3568为例,执行编译命令./build.sh --product-name rk3568并进入out/rk3568文件夹。
274
275- gn desc out/rk3568 //build/rust/tests/test_dylib_crate:test_dylib_crate
276
277  ```
278  Target //build/rust/tests/test_dylib_crate:test_dylib_crate
279  type: executable
280  toolchain: //build/toolchain/ohos:ohos_clang_arm
281
282  crate_name
283    test_dylib_crate
284
285  crate_root
286    //build/rust/tests/test_dylib_crate/src/main.rs
287
288  visibility
289    *
290
291  metadata
292    {
293      install_modules = [
294        {
295          module_def = "//build/rust/tests/test_dylib_crate:test_dylib_crate(//build/toolchain/ohos:ohos_clang_arm)",
296          module_info_file = "obj/build/rust/tests/test_dylib_crate/test_dylib_crate_module_info.json",
297          part_name = "common",
298          subsystem_name = "common",
299          toolchain = "//build/toolchain/ohos:ohos_clang_arm",
300          toolchain_out_dir = "."
301        }
302      ]
303    }
304
305  testonly
306    false
307
308  check_includes
309    true
310
311  allow_circular_includes_from
312
313  sources
314    //build/rust/tests/test_dylib_crate/src/main.rs
315
316  public
317    [All headers listed in the sources are public.]
318
319  configs (in order applying, try also --tree)
320    //build/config:feature_flags
321    //build/config/compiler:afdo
322    ......
323    //build/rust:libstd.dylib.so__config
324    //build/rust:libtest.dylib.so__config
325
326  public_configs (in order applying, try also --tree)
327    //build/rust:libstd.dylib.so__config
328
329  outputs
330    //out/rk3568/exe.unstripped/common/common/test_dylib_crate
331    //out/rk3568/common/common/test_dylib_crate
332
333  arflags
334    -T
335
336  asmflags
337    -fno-strict-aliasing
338    ......
339    -g2
340    --sysroot=obj/third_party/musl
341    -fno-common
342    -fPIE
343
344  cflags
345    -fno-strict-aliasing
346    ......
347    -Wtautological-overlap-compare
348    -fPIE
349    -ftrivial-auto-var-init=zero
350    -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
351
352  cflags_c
353    --sysroot=obj/third_party/musl
354
355  cflags_cc
356    -std=c++17
357    -fno-exceptions
358    -fno-rtti
359    --sysroot=obj/third_party/musl
360    -fvisibility-inlines-hidden
361
362  cflags_objc
363    --sysroot=obj/third_party/musl
364
365  cflags_objcc
366    -std=c++17
367    -fno-exceptions
368    -fno-rtti
369    --sysroot=obj/third_party/musl
370
371  defines
372    V8_DEPRECATION_WARNINGS
373    _GNU_SOURCE
374    HAVE_SYS_UIO_H
375    ......
376    NDEBUG
377    NVALGRIND
378    DYNAMIC_ANNOTATIONS_ENABLED=0
379
380  include_dirs
381    //out/rk3568/obj/third_party/musl/usr/include/arm-linux-ohos/
382    //out/rk3568/override/third_party/
383    //
384    //out/rk3568/gen/
385
386  ldflags
387    -Wl,--pack-dyn-relocs=android+relr
388    -Wl,--fatal-warnings
389    -Wl,--build-id=md5
390    -fPIC
391    -Wl,-z,noexecstack
392    ......
393    -Wl,--gdb-index
394    --sysroot=obj/third_party/musl
395    -nostdlib
396    -Lobj/third_party/musl/usr/lib/arm-linux-ohos
397    -L../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/15.0.4/lib/arm-linux-ohos
398    -Wl,--warn-shared-textrel
399    -Bdynamic
400    -Wl,-z,nocopyreloc
401    -pie
402
403  Direct dependencies (try also "--all", "--tree", or even "--all --tree")
404    //build/config:executable_deps
405    ......
406    //build/rust/tests/test_dylib_crate:test_dylib_crate_info
407
408  libs
409    unwind
410    //prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/15.0.4/lib/arm-linux-ohos/libclang_rt.builtins.a
411    c++
412    c
413    //prebuilts/clang/ohos/linux-x86_64/llvm/lib/arm-linux-ohos/libc++abi.a
414    dl
415    m
416    //out/rk3568/obj/build/rust/libstd.dylib.so
417    //out/rk3568/obj/build/rust/libtest.dylib.so
418  ```
419
420​       可以看出,gn desc命令用处非常大,它可以帮助我们看到编译目标所有的关键信息,cflags、ldflags、outputs等等。
421
422- gn ls out/rk3568
423
424  ```
425  The build continued as if that argument was unspecified.
426
427  //applications/standard/admin_provisioning:adminprovisioning_app_profile
428  //applications/standard/admin_provisioning:adminprovisioning_app_profile__metadata
429  //applications/standard/admin_provisioning:adminprovisioning_hap
430  //applications/standard/admin_provisioning:adminprovisioning_hap__compile_resources
431  //applications/standard/admin_provisioning:adminprovisioning_hap__js_assets
432  //applications/standard/admin_provisioning:adminprovisioning_hap__metadata
433  //applications/standard/admin_provisioning:adminprovisioning_hap__notice
434  //applications/standard/admin_provisioning:adminprovisioning_hap_info
435  ......
436  ```
437
438  列出目录下所有的编译目标。
439
440- gn args --list out/rk3568
441
442  ```
443  ......
444  api_version
445      Current value (from the default) = "10"
446        From //build/version.gni:17
447
448  appexecfwk_lite_path
449      Current value (from the default) = "//foundation/bundlemanager/bundle_framework_lite"
450        From //build/lite/config/subsystem/aafwk/path.gni:18
451
452  appspawn_featrue
453      Current value (from the default) = true
454        From //base/startup/init/services/modules/seccomp/BUILD.gn:26
455
456  appspawn_report_event
457      Current value (from the default) = true
458        From //base/startup/appspawn/appspawn.gni:23
459
460  appspawn_support_nweb
461      Current value (from the default) = true
462        From //base/startup/appspawn/appspawn.gni:22
463
464  archive_component
465      Current value (from the default) = false
466        From //build/ohos_var.gni:130
467  ......
468  ```
469
470  查看gn的编译参数,可以看到具体的参数值和定义的位置。
471
472- gn check out/rk3568
473
474  ```
475  The build continued as if that argument was unspecified.
476
477  ERROR at //applications/standard/settings/napi/settings/native_module.cpp:20:11: Include not allowed.
478  #include "napi/native_api.h"
479            ^----------------
480  It is not in any dependency of
481    //applications/standard/settings/napi/settings:settings
482  The include file is in the target(s):
483    //foundation/arkui/napi:napi_header
484  which should somehow be reachable.
485  ___________________
486  ERROR at //arkcompiler/ets_frontend/es2panda/typescript/types/type.cpp:16:11: Can't include this header from here.
487  #include "type.h"
488            ^-----
489  The target:
490    //arkcompiler/ets_frontend/es2panda:es2panda_lib
491  is including a file from the target:
492    //arkcompiler/runtime_core/libpandafile:libarkfile_type_gen_h
493
494  It's usually best to depend directly on the destination target.
495  In some cases, the destination target is considered a subcomponent
496  of an intermediate target. In this case, the intermediate target
497  should depend publicly on the destination to forward the ability
498  to include headers.
499
500  Dependency chain (there may also be others):
501    //arkcompiler/ets_frontend/es2panda:es2panda_lib -->
502    //arkcompiler/runtime_core/compiler:libarkcompiler_frontend_static --[private]-->
503    //arkcompiler/runtime_core/libpandafile:libarkfile_type_gen_h
504  ```
505
506  检查头文件依赖关系是否正确。
507
508## Ninja调试
509
510| 字段          | 含义                                                         |
511| ------------- | ------------------------------------------------------------ |
512| -v            | 可以将详细的编译命令打印出来                                 |
513| -d explain    | 增量编译时显示重新被编译的原因                               |
514| -dkeeprsp     | 保留编译过程中的rsp文件,rsp文件主要用来存储较长的编译命令   |
515| -dkeepdepfile | 保留编译过程中的depfile文件,depfile文件主要用来保存当前编译需要依赖的文件 |
516| -t deps       | 查找一个目标的依赖,读取的是.ninja_deps文件                  |
517| -t commands   | 查看编译目标需要的编译命令                                   |
518| -t targets    | 查看编译目标名字:ninja -t targets \| grep "xxx"             |
519| -t garph      | 查看目标的依赖图                                             |
520
521#### Thirdparty/gn调试过程
522
523- ninja -C out -v
524
525  ```
526  ninja: Entering directory `out'
527  [1/6] g++ -MMD -MF obj/libhello_static.hello_static.o.d   -fPIC -pthread  -c ../hello_static.cc -o obj/libhello_static.hello_static.o
528  [2/6] g++ -MMD -MF obj/libhello_shared.hello_shared.o.d -DHELLO_SHARED_IMPLEMENTATION  -fPIC -pthread  -c ../hello_shared.cc -o obj/libhello_shared.hello_shared.o
529  [3/6] g++ -MMD -MF obj/hello.hello.o.d   -fPIC -pthread  -c ../hello.cc -o obj/hello.hello.o
530  [4/6] rm -f obj/libhello_static.a && ar rcs obj/libhello_static.a obj/libhello_static.hello_static.o
531  [5/6] g++ -shared  -o ./libhello_shared.so -Wl,-soname=libhello_shared.so @libhello_shared.so.rsp
532  [6/6] g++ -Wl,-rpath=\$ORIGIN/ -Wl,-rpath-link= -o hello -Wl,--start-group @hello.rsp  -Wl,--end-group
533  ```
534
535  该命令可以查看所有编译目标的详细编译命令,可以看出,首先编译出了libhello_static.hello_static.olibhello_shared.hello_shared.ohello.hello.o三个目标文件,并将目标文件放在obj文件夹下,最后链接成hello的可执行程序。
536
537- ninja -t deps
538
539  ```
540  obj/libhello_static.hello_static.o: #deps 2, deps mtime 1681441611760382343 (VALID)
541      ../hello_static.cc
542      ../hello_static.h
543
544  obj/libhello_shared.hello_shared.o: #deps 2, deps mtime 1681441611760382343 (VALID)
545      ../hello_shared.cc
546      ../hello_shared.h
547
548  obj/hello.hello.o: #deps 3, deps mtime 1681441611768382257 (VALID)
549      ../hello.cc
550      ../hello_shared.h
551      ../hello_static.h
552  ```
553
554  查看目标的依赖关系,如obj/libhello_static.hello_static.o目标文件依赖了../hello_static.cc源文件和../hello_static.h头文件。
555
556- ninja -t targets all
557
558  ```
559  build.ninja: gn
560  obj/hello.hello.o: cxx
561  hello: link
562  obj/libhello_shared.hello_shared.o: cxx
563  libhello_shared.so: solink
564  obj/libhello_static.hello_static.o: cxx
565  obj/libhello_static.a: alink
566  hello_shared: phony
567  hello_static: phony
568  :hello: phony
569  :hello_shared: phony
570  :hello_static: phony
571  all: phony
572  ```
573
574  列出ninja阶段的所有编译目标以及编译使用的工具。
575
576- ninja -t commands hello
577
578  ```
579  g++ -MMD -MF obj/hello.hello.o.d   -fPIC -pthread  -c ../hello.cc -o obj/hello.hello.o
580  g++ -MMD -MF obj/libhello_shared.hello_shared.o.d -DHELLO_SHARED_IMPLEMENTATION  -fPIC -pthread  -c ../hello_shared.cc -o obj/libhello_shared.hello_shared.o
581  g++ -shared  -o ./libhello_shared.so -Wl,-soname=libhello_shared.so @libhello_shared.so.rsp
582  g++ -MMD -MF obj/libhello_static.hello_static.o.d   -fPIC -pthread  -c ../hello_static.cc -o obj/libhello_static.hello_static.o
583  rm -f obj/libhello_static.a && ar rcs obj/libhello_static.a obj/libhello_static.hello_static.o
584  g++ -Wl,-rpath=\$ORIGIN/ -Wl,-rpath-link= -o hello -Wl,--start-group @hello.rsp  -Wl,--end-group
585  ```
586
587  查看编译单个目标的详细编译命令。
588
589- ninja -t graph obj/hello.hello.o|dot -Tpng -o rk.png
590
591  ![target_deps](./figures/target_deps.png)
592
593  查看目标的依赖图。
594
595- ninja -t commands| grep  obj/hello.hello.o
596
597  ```
598  g++ -MMD -MF obj/hello.hello.o.d   -fPIC -pthread  -c ../hello.cc -o obj/hello.hello.o
599  ```
600
601​       该命令也可以看到单独编译每个目标的详细编译命令。
602
603#### Openharmony的调试过程
604
605在Openharmony上查看详细的编译过程可以通过--ninja-args形式将ninja阶段的参数传递到 ninja命令里。
606
607- 查看详细的编译命令
608
609  使用如下编译命令,可以在build.log里面查看每一个编译目标的详细编译命令
610
611  ```
612  ./build.sh --product-name rk3568 --ninja-args=-v
613  ```
614
615- 编译时保留rsp文件,并查看详细编译命令
616
617  该命令在编译目标报错且会生成rsp文件时,保留目标的rsp文件,因为默认编译是不会保留的
618
619  ```
620  ./build.sh --product-name rk3568 --ninja-args=-v  --ninja-args=-dkeeprsp
621  ```
622
623- 进入out/rk3568文件夹,执行以下命令查看所有的编译目标
624
625  ```
626  ninja -t targets all
627  ```
628
629  编译目标:
630
631  ```
632  ......
633  obj/base/notification/distributed_notification_service/test/fuzztest/notificationlongtextcontentannex_fuzzer/NotificationLongTextContentAnnexFuzzTest_resource_copy.stamp: stamp
634  obj/base/notification/distributed_notification_service/test/fuzztest/notificationlongtextcontentannex_fuzzer/fuzztest.stamp: stamp
635  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmediacontent_fuzzer/NotificationMediaContentFuzzTest/notificationmediacontent_fuzzer.o: cxx
636  tests/fuzztest/distributed_notification_service/fuzztest/NotificationMediaContentFuzzTest: link
637  exe.unstripped/tests/fuzztest/distributed_notification_service/fuzztest/NotificationMediaContentFuzzTest: link
638  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmediacontent_fuzzer/NotificationMediaContentFuzzTest_resource_copy.json: __base_notification_distributed_notification_service_test_fuzztest_notificationmediacontent_fuzzer_NotificationMediaContentFuzzTest_resource_copy___build_toolchain_ohos_ohos_clang_arm__rule
639  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmediacontent_fuzzer/NotificationMediaContentFuzzTest_resource_copy.stamp: stamp
640  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmediacontent_fuzzer/fuzztest.stamp: stamp
641  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmultilinecontent_fuzzer/NotificationMultiLineContentFuzzTest/notificationmultilinecontent_fuzzer.o: cxx
642  tests/fuzztest/distributed_notification_service/fuzztest/NotificationMultiLineContentFuzzTest: link
643  exe.unstripped/tests/fuzztest/distributed_notification_service/fuzztest/NotificationMultiLineContentFuzzTest: link
644  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmultilinecontent_fuzzer/NotificationMultiLineContentFuzzTest_resource_copy.json: __base_notification_distributed_notification_service_test_fuzztest_notificationmultilinecontent_fuzzer_NotificationMultiLineContentFuzzTest_resource_copy___build_toolchain_ohos_ohos_clang_arm__rule
645  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmultilinecontent_fuzzer/NotificationMultiLineContentFuzzTest_resource_copy.stamp: stamp
646  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmultilinecontent_fuzzer/fuzztest.stamp: stamp
647  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmultilinecontentannex_fuzzer/NotificationMultiLineContentAnnexFuzzTest/notificationmultilinecontentannex_fuzzer.o: cxx
648  ......
649  ```
650
651- 进入out/rk3568,执行如下命令查看所有目标的依赖情况
652
653  ```
654  ninja -t deps
655  ```
656
657  查看所有目标的依赖情况
658
659  ```
660  ......
661  obj/third_party/openssl/crypto/dh/crypto_source/dh_kdf.o: #deps 46, deps mtime 1681891589799107971 (VALID)
662      ../../third_party/openssl/crypto/dh/dh_kdf.c
663      ../../third_party/openssl/e_os.h
664      ../../third_party/openssl/include/openssl/opensslconf.h
665      ../../third_party/openssl/include/openssl/opensslv.h
666      ../../third_party/openssl/include/openssl/e_os2.h
667      ../../third_party/openssl/include/openssl/crypto.h
668      ../../third_party/openssl/include/openssl/safestack.h
669      ../../third_party/openssl/include/openssl/stack.h
670      ../../third_party/openssl/include/openssl/ossl_typ.h
671      ../../third_party/openssl/include/openssl/cryptoerr.h
672      ../../third_party/openssl/include/openssl/symhacks.h
673      ../../third_party/openssl/include/internal/nelem.h
674      ../../third_party/openssl/include/openssl/dh.h
675      ../../third_party/openssl/include/openssl/bio.h
676      ../../third_party/openssl/include/openssl/bioerr.h
677      ../../third_party/openssl/include/openssl/asn1.h
678      ../../third_party/openssl/include/openssl/asn1err.h
679      ../../third_party/openssl/include/openssl/bn.h
680      ../../third_party/openssl/include/openssl/bnerr.h
681      ../../third_party/openssl/include/openssl/dherr.h
682      ../../third_party/openssl/include/openssl/evp.h
683      ../../third_party/openssl/include/openssl/evperr.h
684      ../../third_party/openssl/include/openssl/objects.h
685      ../../third_party/openssl/include/openssl/obj_mac.h
686      ../../third_party/openssl/include/openssl/objectserr.h
687      ../../third_party/openssl/include/openssl/cms.h
688      ../../third_party/openssl/include/openssl/x509.h
689      ../../third_party/openssl/include/openssl/buffer.h
690      ../../third_party/openssl/include/openssl/buffererr.h
691      ../../third_party/openssl/include/openssl/ec.h
692      ../../third_party/openssl/include/openssl/ecerr.h
693      ../../third_party/openssl/include/openssl/rsa.h
694      ../../third_party/openssl/include/openssl/rsaerr.h
695      ../../third_party/openssl/include/openssl/dsa.h
696      ../../third_party/openssl/include/openssl/dsaerr.h
697      ../../third_party/openssl/include/openssl/sha.h
698      ../../third_party/openssl/include/openssl/x509err.h
699      ../../third_party/openssl/include/openssl/x509_vfy.h
700      ../../third_party/openssl/include/openssl/lhash.h
701      ../../third_party/openssl/include/openssl/pkcs7.h
702      ../../third_party/openssl/include/openssl/pkcs7err.h
703      ../../third_party/openssl/include/openssl/x509v3.h
704      ../../third_party/openssl/include/openssl/conf.h
705      ../../third_party/openssl/include/openssl/conferr.h
706      ../../third_party/openssl/include/openssl/x509v3err.h
707      ../../third_party/openssl/include/openssl/cmserr.h
708
709  obj/third_party/openssl/crypto/dh/crypto_source/dh_key.o: #deps 27, deps mtime 1681891589779107209 (VALID)
710      ../../third_party/openssl/crypto/dh/dh_key.c
711      ../../third_party/openssl/include/internal/cryptlib.h
712      ../../third_party/openssl/include/openssl/crypto.h
713      ../../third_party/openssl/include/openssl/e_os2.h
714      ../../third_party/openssl/include/openssl/opensslconf.h
715      ../../third_party/openssl/include/openssl/opensslv.h
716      ../../third_party/openssl/include/openssl/safestack.h
717      ../../third_party/openssl/include/openssl/stack.h
718      ../../third_party/openssl/include/openssl/ossl_typ.h
719      ../../third_party/openssl/include/openssl/cryptoerr.h
720      ../../third_party/openssl/include/openssl/symhacks.h
721      ../../third_party/openssl/include/openssl/buffer.h
722      ../../third_party/openssl/include/openssl/buffererr.h
723      ../../third_party/openssl/include/openssl/bio.h
724      ../../third_party/openssl/include/openssl/bioerr.h
725      ../../third_party/openssl/include/openssl/err.h
726      ../../third_party/openssl/include/openssl/lhash.h
727      ../../third_party/openssl/include/internal/nelem.h
728      ../../third_party/openssl/crypto/dh/dh_local.h
729      ../../third_party/openssl/include/openssl/dh.h
730      ../../third_party/openssl/include/openssl/asn1.h
731      ../../third_party/openssl/include/openssl/asn1err.h
732      ../../third_party/openssl/include/openssl/bn.h
733      ../../third_party/openssl/include/openssl/bnerr.h
734      ../../third_party/openssl/include/openssl/dherr.h
735      ../../third_party/openssl/include/internal/refcount.h
736      ../../third_party/openssl/include/crypto/bn.h
737  ......
738  ```
739
740  其他命令就不详细一一进行介绍了,开发者可以自己探索和使用
741
742## 加快本地编译的参数
743
744```
745本地编译技巧
746
747   1、安装ccache:用来缓存编译过的.o文件等
748       export CCACHE_NOHASHDIR="true" && export CCACHE_SLOPPINESS="include_file_ctime" :设置ccache在做hash的时候不hash路径、不检查文    件的change time
749   2、--fast-rebuild:直接从ninja开始编译,跳过前面的产品配置解析和gn解析,需要在不修改gn的时候可以使用
750   3、--gn-args enable_notice_collection=false:取消收集开源notice的过程,建议加上
751   4、--disable-package-image:取消最后的image压缩成tar包的动作
752   5、--build-only-gn:重新执行Preloader、loader、gn,不进行最后的编译动作
753   6、--build-target:可以单独指定某个编译目标,在out/rk3568下面执行ninja -t targets | grep "xxx"
754   7、--gn-args enable_lto_O0=true:在链接的时候会减弱优化的等级,建议在只考虑编译是否成功的时候使用(会影响最后的so的性能和rom大小)
755   8、--gn-args archive_ndk=false:编译sdk的时候不执行输出压缩包的动作
756   9、尽量不删除out,走增量编译
757  10、export NO_DEVTOOL=1 && ./build.sh xxx: 取消webpack打包过程中生成sourcemap的动作
758
759  11、--disable-post-build:取消Postbuild过程,最后的ninja trace解析、每个子系统的的rom size统计等动作会没有
760
761  12、--gn-args skip_generate_module_list_file=true:跳过为test 生成记录文件的过程,节省gn解析的过程,只要不跑tdd测试用例,这个参数都可以加上,编译tdd用例也没关系
762
763  13、在不编译image的时候:-T packages --gn-args skip_gen_module_info=true,去掉gn阶段module info的生成
764  14、在不编译test用例的时候可以加上--load-test-config=false,来去掉gn阶段test相关编译目标的解析
765  15、在不修改编译目标的external_deps且out输出目录不删除的情况,可以尝试使用--gn-args ohos_skip_parse_external_deps=true来缩短增量构建的gn解析时间
766  16、--build-only-load:重新执行Preloader、loader,不进行最后的gn, ninja动作
767```
768