• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    --param=ssp-buffer-size=4
339    ......
340    -g2
341    --sysroot=obj/third_party/musl
342    -fno-common
343    -fPIE
344
345  cflags
346    -fno-strict-aliasing
347    --param=ssp-buffer-size=4
348    ......
349    -Wtautological-overlap-compare
350    -fPIE
351    -ftrivial-auto-var-init=zero
352    -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
353
354  cflags_c
355    --sysroot=obj/third_party/musl
356
357  cflags_cc
358    -std=c++17
359    -fno-exceptions
360    -fno-rtti
361    --sysroot=obj/third_party/musl
362    -fvisibility-inlines-hidden
363
364  cflags_objc
365    --sysroot=obj/third_party/musl
366
367  cflags_objcc
368    -std=c++17
369    -fno-exceptions
370    -fno-rtti
371    --sysroot=obj/third_party/musl
372
373  defines
374    V8_DEPRECATION_WARNINGS
375    _GNU_SOURCE
376    HAVE_SYS_UIO_H
377    ......
378    NDEBUG
379    NVALGRIND
380    DYNAMIC_ANNOTATIONS_ENABLED=0
381
382  include_dirs
383    //out/rk3568/obj/third_party/musl/usr/include/arm-linux-ohos/
384    //out/rk3568/override/third_party/
385    //
386    //out/rk3568/gen/
387
388  ldflags
389    -Wl,--pack-dyn-relocs=android+relr
390    -Wl,--fatal-warnings
391    -Wl,--build-id=md5
392    -fPIC
393    -Wl,-z,noexecstack
394    ......
395    -Wl,--gdb-index
396    --sysroot=obj/third_party/musl
397    -nostdlib
398    -Lobj/third_party/musl/usr/lib/arm-linux-ohos
399    -L../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/15.0.4/lib/arm-linux-ohos
400    -Wl,--warn-shared-textrel
401    -Bdynamic
402    -Wl,-z,nocopyreloc
403    -pie
404
405  Direct dependencies (try also "--all", "--tree", or even "--all --tree")
406    //build/config:executable_deps
407    ......
408    //build/rust/tests/test_dylib_crate:test_dylib_crate_info
409
410  libs
411    unwind
412    //prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/15.0.4/lib/arm-linux-ohos/libclang_rt.builtins.a
413    c++
414    c
415    //prebuilts/clang/ohos/linux-x86_64/llvm/lib/arm-linux-ohos/libc++abi.a
416    dl
417    m
418    //out/rk3568/obj/build/rust/libstd.dylib.so
419    //out/rk3568/obj/build/rust/libtest.dylib.so
420  ```
421
422​       可以看出,gn desc命令用处非常大,它可以帮助我们看到编译目标所有的关键信息,cflags、ldflags、outputs等等。
423
424- gn ls out/rk3568
425
426  ```
427  The build continued as if that argument was unspecified.
428
429  //applications/standard/admin_provisioning:adminprovisioning_app_profile
430  //applications/standard/admin_provisioning:adminprovisioning_app_profile__metadata
431  //applications/standard/admin_provisioning:adminprovisioning_hap
432  //applications/standard/admin_provisioning:adminprovisioning_hap__compile_resources
433  //applications/standard/admin_provisioning:adminprovisioning_hap__js_assets
434  //applications/standard/admin_provisioning:adminprovisioning_hap__metadata
435  //applications/standard/admin_provisioning:adminprovisioning_hap__notice
436  //applications/standard/admin_provisioning:adminprovisioning_hap_info
437  ......
438  ```
439
440  列出目录下所有的编译目标。
441
442- gn args --list out/rk3568
443
444  ```
445  ......
446  api_version
447      Current value (from the default) = "10"
448        From //build/version.gni:17
449
450  appexecfwk_lite_path
451      Current value (from the default) = "//foundation/bundlemanager/bundle_framework_lite"
452        From //build/lite/config/subsystem/aafwk/path.gni:18
453
454  appspawn_featrue
455      Current value (from the default) = true
456        From //base/startup/init/services/modules/seccomp/BUILD.gn:26
457
458  appspawn_report_event
459      Current value (from the default) = true
460        From //base/startup/appspawn/appspawn.gni:23
461
462  appspawn_support_nweb
463      Current value (from the default) = true
464        From //base/startup/appspawn/appspawn.gni:22
465
466  archive_component
467      Current value (from the default) = false
468        From //build/ohos_var.gni:130
469  ......
470  ```
471
472  查看gn的编译参数,可以看到具体的参数值和定义的位置。
473
474- gn check out/rk3568
475
476  ```
477  The build continued as if that argument was unspecified.
478
479  ERROR at //applications/standard/settings/napi/settings/native_module.cpp:20:11: Include not allowed.
480  #include "napi/native_api.h"
481            ^----------------
482  It is not in any dependency of
483    //applications/standard/settings/napi/settings:settings
484  The include file is in the target(s):
485    //foundation/arkui/napi:napi_header
486  which should somehow be reachable.
487  ___________________
488  ERROR at //arkcompiler/ets_frontend/es2panda/typescript/types/type.cpp:16:11: Can't include this header from here.
489  #include "type.h"
490            ^-----
491  The target:
492    //arkcompiler/ets_frontend/es2panda:es2panda_lib
493  is including a file from the target:
494    //arkcompiler/runtime_core/libpandafile:libarkfile_type_gen_h
495
496  It's usually best to depend directly on the destination target.
497  In some cases, the destination target is considered a subcomponent
498  of an intermediate target. In this case, the intermediate target
499  should depend publicly on the destination to forward the ability
500  to include headers.
501
502  Dependency chain (there may also be others):
503    //arkcompiler/ets_frontend/es2panda:es2panda_lib -->
504    //arkcompiler/runtime_core/compiler:libarkcompiler_frontend_static --[private]-->
505    //arkcompiler/runtime_core/libpandafile:libarkfile_type_gen_h
506  ```
507
508  检查头文件依赖关系是否正确。
509
510## Ninja调试
511
512| 字段          | 含义                                                         |
513| ------------- | ------------------------------------------------------------ |
514| -v            | 可以将详细的编译命令打印出来                                 |
515| -d explain    | 增量编译时显示重新被编译的原因                               |
516| -dkeeprsp     | 保留编译过程中的rsp文件,rsp文件主要用来存储较长的编译命令   |
517| -dkeepdepfile | 保留编译过程中的depfile文件,depfile文件主要用来保存当前编译需要依赖的文件 |
518| -t deps       | 查找一个目标的依赖,读取的是.ninja_deps文件                  |
519| -t commands   | 查看编译目标需要的编译命令                                   |
520| -t targets    | 查看编译目标名字:ninja -t targets \| grep "xxx"             |
521| -t garph      | 查看目标的依赖图                                             |
522
523#### Thirdparty/gn调试过程
524
525- ninja -C out -v
526
527  ```
528  ninja: Entering directory `out'
529  [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
530  [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
531  [3/6] g++ -MMD -MF obj/hello.hello.o.d   -fPIC -pthread  -c ../hello.cc -o obj/hello.hello.o
532  [4/6] rm -f obj/libhello_static.a && ar rcs obj/libhello_static.a obj/libhello_static.hello_static.o
533  [5/6] g++ -shared  -o ./libhello_shared.so -Wl,-soname=libhello_shared.so @libhello_shared.so.rsp
534  [6/6] g++ -Wl,-rpath=\$ORIGIN/ -Wl,-rpath-link= -o hello -Wl,--start-group @hello.rsp  -Wl,--end-group
535  ```
536
537  该命令可以查看所有编译目标的详细编译命令,可以看出,首先编译出了libhello_static.hello_static.olibhello_shared.hello_shared.ohello.hello.o三个目标文件,并将目标文件放在obj文件夹下,最后链接成hello的可执行程序。
538
539- ninja -t deps
540
541  ```
542  obj/libhello_static.hello_static.o: #deps 2, deps mtime 1681441611760382343 (VALID)
543      ../hello_static.cc
544      ../hello_static.h
545
546  obj/libhello_shared.hello_shared.o: #deps 2, deps mtime 1681441611760382343 (VALID)
547      ../hello_shared.cc
548      ../hello_shared.h
549
550  obj/hello.hello.o: #deps 3, deps mtime 1681441611768382257 (VALID)
551      ../hello.cc
552      ../hello_shared.h
553      ../hello_static.h
554  ```
555
556  查看目标的依赖关系,如obj/libhello_static.hello_static.o目标文件依赖了../hello_static.cc源文件和../hello_static.h头文件。
557
558- ninja -t targets all
559
560  ```
561  build.ninja: gn
562  obj/hello.hello.o: cxx
563  hello: link
564  obj/libhello_shared.hello_shared.o: cxx
565  libhello_shared.so: solink
566  obj/libhello_static.hello_static.o: cxx
567  obj/libhello_static.a: alink
568  hello_shared: phony
569  hello_static: phony
570  :hello: phony
571  :hello_shared: phony
572  :hello_static: phony
573  all: phony
574  ```
575
576  列出ninja阶段的所有编译目标以及编译使用的工具。
577
578- ninja -t commands hello
579
580  ```
581  g++ -MMD -MF obj/hello.hello.o.d   -fPIC -pthread  -c ../hello.cc -o obj/hello.hello.o
582  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
583  g++ -shared  -o ./libhello_shared.so -Wl,-soname=libhello_shared.so @libhello_shared.so.rsp
584  g++ -MMD -MF obj/libhello_static.hello_static.o.d   -fPIC -pthread  -c ../hello_static.cc -o obj/libhello_static.hello_static.o
585  rm -f obj/libhello_static.a && ar rcs obj/libhello_static.a obj/libhello_static.hello_static.o
586  g++ -Wl,-rpath=\$ORIGIN/ -Wl,-rpath-link= -o hello -Wl,--start-group @hello.rsp  -Wl,--end-group
587  ```
588
589  查看编译单个目标的详细编译命令。
590
591- ninja -t graph obj/hello.hello.o|dot -Tpng -o rk.png
592
593  ![target_deps](./figures/target_deps.png)
594
595  查看目标的依赖图。
596
597- ninja -t commands| grep  obj/hello.hello.o
598
599  ```
600  g++ -MMD -MF obj/hello.hello.o.d   -fPIC -pthread  -c ../hello.cc -o obj/hello.hello.o
601  ```
602
603​       该命令也可以看到单独编译每个目标的详细编译命令。
604
605#### Openharmony的调试过程
606
607在Openharmony上查看详细的编译过程可以通过--ninja-args形式将ninja阶段的参数传递到 ninja命令里。
608
609- 查看详细的编译命令
610
611  使用如下编译命令,可以在build.log里面查看每一个编译目标的详细编译命令
612
613  ```
614  ./build.sh --product-name rk3568 --ninja-args=-v
615  ```
616
617- 编译时保留rsp文件,并查看详细编译命令
618
619  该命令在编译目标报错且会生成rsp文件时,保留目标的rsp文件,因为默认编译是不会保留的
620
621  ```
622  ./build.sh --product-name rk3568 --ninja-args=-v  --ninja-args=-dkeeprsp
623  ```
624
625- 进入out/rk3568文件夹,执行以下命令查看所有的编译目标
626
627  ```
628  ninja -t targets all
629  ```
630
631  编译目标:
632
633  ```
634  ......
635  obj/base/notification/distributed_notification_service/test/fuzztest/notificationlongtextcontentannex_fuzzer/NotificationLongTextContentAnnexFuzzTest_resource_copy.stamp: stamp
636  obj/base/notification/distributed_notification_service/test/fuzztest/notificationlongtextcontentannex_fuzzer/fuzztest.stamp: stamp
637  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmediacontent_fuzzer/NotificationMediaContentFuzzTest/notificationmediacontent_fuzzer.o: cxx
638  tests/fuzztest/distributed_notification_service/fuzztest/NotificationMediaContentFuzzTest: link
639  exe.unstripped/tests/fuzztest/distributed_notification_service/fuzztest/NotificationMediaContentFuzzTest: link
640  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
641  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmediacontent_fuzzer/NotificationMediaContentFuzzTest_resource_copy.stamp: stamp
642  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmediacontent_fuzzer/fuzztest.stamp: stamp
643  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmultilinecontent_fuzzer/NotificationMultiLineContentFuzzTest/notificationmultilinecontent_fuzzer.o: cxx
644  tests/fuzztest/distributed_notification_service/fuzztest/NotificationMultiLineContentFuzzTest: link
645  exe.unstripped/tests/fuzztest/distributed_notification_service/fuzztest/NotificationMultiLineContentFuzzTest: link
646  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
647  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmultilinecontent_fuzzer/NotificationMultiLineContentFuzzTest_resource_copy.stamp: stamp
648  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmultilinecontent_fuzzer/fuzztest.stamp: stamp
649  obj/base/notification/distributed_notification_service/test/fuzztest/notificationmultilinecontentannex_fuzzer/NotificationMultiLineContentAnnexFuzzTest/notificationmultilinecontentannex_fuzzer.o: cxx
650  ......
651  ```
652
653- 进入out/rk3568,执行如下命令查看所有目标的依赖情况
654
655  ```
656  ninja -t deps
657  ```
658
659  查看所有目标的依赖情况
660
661  ```
662  ......
663  obj/third_party/openssl/crypto/dh/crypto_source/dh_kdf.o: #deps 46, deps mtime 1681891589799107971 (VALID)
664      ../../third_party/openssl/crypto/dh/dh_kdf.c
665      ../../third_party/openssl/e_os.h
666      ../../third_party/openssl/include/openssl/opensslconf.h
667      ../../third_party/openssl/include/openssl/opensslv.h
668      ../../third_party/openssl/include/openssl/e_os2.h
669      ../../third_party/openssl/include/openssl/crypto.h
670      ../../third_party/openssl/include/openssl/safestack.h
671      ../../third_party/openssl/include/openssl/stack.h
672      ../../third_party/openssl/include/openssl/ossl_typ.h
673      ../../third_party/openssl/include/openssl/cryptoerr.h
674      ../../third_party/openssl/include/openssl/symhacks.h
675      ../../third_party/openssl/include/internal/nelem.h
676      ../../third_party/openssl/include/openssl/dh.h
677      ../../third_party/openssl/include/openssl/bio.h
678      ../../third_party/openssl/include/openssl/bioerr.h
679      ../../third_party/openssl/include/openssl/asn1.h
680      ../../third_party/openssl/include/openssl/asn1err.h
681      ../../third_party/openssl/include/openssl/bn.h
682      ../../third_party/openssl/include/openssl/bnerr.h
683      ../../third_party/openssl/include/openssl/dherr.h
684      ../../third_party/openssl/include/openssl/evp.h
685      ../../third_party/openssl/include/openssl/evperr.h
686      ../../third_party/openssl/include/openssl/objects.h
687      ../../third_party/openssl/include/openssl/obj_mac.h
688      ../../third_party/openssl/include/openssl/objectserr.h
689      ../../third_party/openssl/include/openssl/cms.h
690      ../../third_party/openssl/include/openssl/x509.h
691      ../../third_party/openssl/include/openssl/buffer.h
692      ../../third_party/openssl/include/openssl/buffererr.h
693      ../../third_party/openssl/include/openssl/ec.h
694      ../../third_party/openssl/include/openssl/ecerr.h
695      ../../third_party/openssl/include/openssl/rsa.h
696      ../../third_party/openssl/include/openssl/rsaerr.h
697      ../../third_party/openssl/include/openssl/dsa.h
698      ../../third_party/openssl/include/openssl/dsaerr.h
699      ../../third_party/openssl/include/openssl/sha.h
700      ../../third_party/openssl/include/openssl/x509err.h
701      ../../third_party/openssl/include/openssl/x509_vfy.h
702      ../../third_party/openssl/include/openssl/lhash.h
703      ../../third_party/openssl/include/openssl/pkcs7.h
704      ../../third_party/openssl/include/openssl/pkcs7err.h
705      ../../third_party/openssl/include/openssl/x509v3.h
706      ../../third_party/openssl/include/openssl/conf.h
707      ../../third_party/openssl/include/openssl/conferr.h
708      ../../third_party/openssl/include/openssl/x509v3err.h
709      ../../third_party/openssl/include/openssl/cmserr.h
710
711  obj/third_party/openssl/crypto/dh/crypto_source/dh_key.o: #deps 27, deps mtime 1681891589779107209 (VALID)
712      ../../third_party/openssl/crypto/dh/dh_key.c
713      ../../third_party/openssl/include/internal/cryptlib.h
714      ../../third_party/openssl/include/openssl/crypto.h
715      ../../third_party/openssl/include/openssl/e_os2.h
716      ../../third_party/openssl/include/openssl/opensslconf.h
717      ../../third_party/openssl/include/openssl/opensslv.h
718      ../../third_party/openssl/include/openssl/safestack.h
719      ../../third_party/openssl/include/openssl/stack.h
720      ../../third_party/openssl/include/openssl/ossl_typ.h
721      ../../third_party/openssl/include/openssl/cryptoerr.h
722      ../../third_party/openssl/include/openssl/symhacks.h
723      ../../third_party/openssl/include/openssl/buffer.h
724      ../../third_party/openssl/include/openssl/buffererr.h
725      ../../third_party/openssl/include/openssl/bio.h
726      ../../third_party/openssl/include/openssl/bioerr.h
727      ../../third_party/openssl/include/openssl/err.h
728      ../../third_party/openssl/include/openssl/lhash.h
729      ../../third_party/openssl/include/internal/nelem.h
730      ../../third_party/openssl/crypto/dh/dh_local.h
731      ../../third_party/openssl/include/openssl/dh.h
732      ../../third_party/openssl/include/openssl/asn1.h
733      ../../third_party/openssl/include/openssl/asn1err.h
734      ../../third_party/openssl/include/openssl/bn.h
735      ../../third_party/openssl/include/openssl/bnerr.h
736      ../../third_party/openssl/include/openssl/dherr.h
737      ../../third_party/openssl/include/internal/refcount.h
738      ../../third_party/openssl/include/crypto/bn.h
739  ......
740  ```
741
742  其他命令就不详细一一进行介绍了,开发者可以自己探索和使用
743
744## 加快本地编译的参数
745
746```
747本地编译技巧
748
749   1、安装ccache:用来缓存编译过的.o文件等
750       export CCACHE_NOHASHDIR="true" && export CCACHE_SLOPPINESS="include_file_ctime" :设置ccache在做hash的时候不hash路径、不检查文    件的change time
751   2、--fast-rebuild:直接从ninja开始编译,跳过前面的产品配置解析和gn解析,需要在不修改gn的时候可以使用
752   3、--gn-args enable_notice_collection=false:取消收集开源notice的过程,建议加上
753   4、--disable-package-image:取消最后的image压缩成tar包的动作
754   5、--build-only-gn:重新执行Preloader、loader、gn,不进行最后的编译动作
755   6、--build-target:可以单独指定某个编译目标,在out/rk3568下面执行ninja -t targets | grep "xxx"
756   7、--gn-args enable_lto_O0=true:在链接的时候会减弱优化的等级,建议在只考虑编译是否成功的时候使用(会影响最后的so的性能和rom大小)
757   8、--gn-args archive_ndk=false:编译sdk的时候不执行输出压缩包的动作
758   9、尽量不删除out,走增量编译
759  10、export NO_DEVTOOL=1 && ./build.sh xxx: 取消webpack打包过程中生成sourcemap的动作
760
761  11、--disable-post-build:取消Postbuild过程,最后的ninja trace解析、每个子系统的的rom size统计等动作会没有
762
763  12、--gn-args skip_generate_module_list_file=true:跳过为test 生成记录文件的过程,节省gn解析的过程,只要不跑tdd测试用例,这个参数都可以加上,编译tdd用例也没关系
764
765  13、在不编译image的时候:-T packages --gn-args skip_gen_module_info=true,去掉gn阶段module info的生成
766  14、在不编译test用例的时候可以加上--gn-args load_test_config=false,来去掉gn阶段test相关u编译目标的解析
767  15、在不修改编译目标的external_deps且out输出目录不删除的情况,可以尝试使用--gn-args ohos_skip_parse_external_deps=true来缩短增量构建的gn解析时间
768```
769