• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14if (defined(ohos_lite)) {
15  import("//build/lite/config/component/lite_component.gni")
16} else {
17  import("//build/ohos.gni")
18}
19import("//third_party/libunwind/libunwind.gni")
20
21common_source = [
22  "src/dwarf/Gexpr.c",
23  "src/dwarf/Gfde.c",
24  "src/dwarf/Gfind_proc_info-lsb.c",
25  "src/dwarf/Gfind_unwind_table.c",
26  "src/dwarf/global.c",
27  "src/dwarf/Gparser.c",
28  "src/dwarf/Gpe.c",
29  "src/dwarf/Lexpr.c",
30  "src/dwarf/Lfde.c",
31  "src/dwarf/Lfind_proc_info-lsb.c",
32  "src/dwarf/Lfind_unwind_table.c",
33  "src/dwarf/Lparser.c",
34  "src/dwarf/Lpe.c",
35  "src/mi/backtrace.c",
36  "src/mi/dyn-cancel.c",
37  "src/mi/dyn-info-list.c",
38  "src/mi/dyn-register.c",
39  "src/mi/flush_cache.c",
40  "src/mi/Gdestroy_addr_space.c",
41  "src/mi/Gdyn-extract.c",
42  "src/mi/Gdyn-remote.c",
43  "src/mi/Gfind_dynamic_proc_info.c",
44  "src/mi/Gget_accessors.c",
45  "src/mi/Gget_fpreg.c",
46  "src/mi/Gget_proc_info_by_ip.c",
47  "src/mi/Gget_proc_name.c",
48  "src/mi/Gget_reg.c",
49  "src/mi/Gput_dynamic_unwind_info.c",
50  "src/mi/Gset_cache_size.c",
51  "src/mi/Gset_caching_policy.c",
52  "src/mi/Gset_fpreg.c",
53  "src/mi/Gset_reg.c",
54  "src/mi/init.c",
55  "src/mi/Ldestroy_addr_space.c",
56  "src/mi/Ldyn-extract.c",
57  "src/mi/Lfind_dynamic_proc_info.c",
58  "src/mi/Lget_fpreg.c",
59  "src/mi/Lget_proc_info_by_ip.c",
60  "src/mi/Lget_proc_name.c",
61  "src/mi/Lget_reg.c",
62  "src/mi/Lput_dynamic_unwind_info.c",
63  "src/mi/Lset_cache_size.c",
64  "src/mi/Lset_caching_policy.c",
65  "src/mi/Lset_fpreg.c",
66  "src/mi/Lset_reg.c",
67  "src/mi/mempool.c",
68  "src/mi/strerror.c",
69  "src/os-linux.c",
70  "src/ohos-config.c",
71  "src/ptrace/_UPT_access_fpreg.c",
72  "src/ptrace/_UPT_access_mem.c",
73  "src/ptrace/_UPT_access_reg.c",
74  "src/ptrace/_UPT_accessors.c",
75  "src/ptrace/_UPT_create.c",
76  "src/ptrace/_UPT_destroy.c",
77  "src/ptrace/_UPT_find_proc_info.c",
78  "src/ptrace/_UPT_get_dyn_info_list_addr.c",
79  "src/ptrace/_UPT_get_proc_name.c",
80  "src/ptrace/_UPT_put_unwind_info.c",
81  "src/ptrace/_UPT_reg_offset.c",
82  "src/ptrace/_UPT_resume.c",
83  "src/mi/maps.c",
84]
85
86# as libc++ is static linked with libunwind.a
87# we remove the Gstep.c for duplicated symbol violation
88arm_source = [
89  "src/arm/Gapply_reg_state.c",
90  "src/arm/Gcreate_addr_space.c",
91  "src/arm/Gex_tables.c",
92  "src/arm/Gget_proc_info.c",
93  "src/arm/Gget_save_loc.c",
94  "src/arm/Gglobal.c",
95  "src/arm/Ginit.c",
96  "src/arm/Ginit_local.c",
97  "src/arm/Ginit_remote.c",
98  "src/arm/Gos-linux.c",
99  "src/arm/Greg_states_iterate.c",
100  "src/arm/Gregs.c",
101  "src/arm/Gresume.c",
102  "src/arm/Gstash_frame.c",
103  "src/arm/Gstep.c",
104  "src/arm/Gtrace.c",
105  "src/arm/Lcreate_addr_space.c",
106  "src/arm/Lex_tables.c",
107  "src/arm/Lget_proc_info.c",
108  "src/arm/Lget_save_loc.c",
109  "src/arm/Lglobal.c",
110  "src/arm/Linit.c",
111  "src/arm/Linit_local.c",
112  "src/arm/Linit_remote.c",
113  "src/arm/Los-linux.c",
114  "src/arm/Lregs.c",
115  "src/arm/Lresume.c",
116  "src/arm/Lstash_frame.c",
117  "src/arm/Lstep.c",
118  "src/arm/Ltrace.c",
119  "src/arm/getcontext.S",
120  "src/arm/is_fpreg.c",
121  "src/arm/regname.c",
122  "src/arm/siglongjmp.S",
123  "src/elf32.c",
124]
125
126arm64_source = [
127  "src/aarch64/Gcreate_addr_space.c",
128  "src/aarch64/Gget_proc_info.c",
129  "src/aarch64/Gget_save_loc.c",
130  "src/aarch64/Gglobal.c",
131  "src/aarch64/Ginit.c",
132  "src/aarch64/Ginit_local.c",
133  "src/aarch64/Ginit_remote.c",
134  "src/aarch64/Gis_signal_frame.c",
135  "src/aarch64/Gregs.c",
136  "src/aarch64/Gresume.c",
137  "src/aarch64/Gstash_frame.c",
138  "src/aarch64/Gstep.c",
139  "src/aarch64/Gtrace.c",
140  "src/aarch64/Lcreate_addr_space.c",
141  "src/aarch64/Lget_proc_info.c",
142  "src/aarch64/Lget_save_loc.c",
143  "src/aarch64/Lglobal.c",
144  "src/aarch64/Linit.c",
145  "src/aarch64/Linit_local.c",
146  "src/aarch64/Linit_remote.c",
147  "src/aarch64/Lis_signal_frame.c",
148  "src/aarch64/Lregs.c",
149  "src/aarch64/Lresume.c",
150  "src/aarch64/Lstash_frame.c",
151  "src/aarch64/Lstep.c",
152  "src/aarch64/Ltrace.c",
153  "src/aarch64/getcontext.S",
154  "src/aarch64/is_fpreg.c",
155  "src/aarch64/regname.c",
156  "src/elf64.c",
157]
158
159x64_source = [
160  "src/elf64.c",
161  "src/x86_64/Gcreate_addr_space.c",
162  "src/x86_64/Gget_proc_info.c",
163  "src/x86_64/Gget_save_loc.c",
164  "src/x86_64/Gglobal.c",
165  "src/x86_64/Ginit.c",
166  "src/x86_64/Ginit_local.c",
167  "src/x86_64/Ginit_remote.c",
168  "src/x86_64/Gos-linux.c",
169  "src/x86_64/Gregs.c",
170  "src/x86_64/Gresume.c",
171  "src/x86_64/Gstash_frame.c",
172  "src/x86_64/Gstep.c",
173  "src/x86_64/Gtrace.c",
174  "src/x86_64/Lcreate_addr_space.c",
175  "src/x86_64/Lget_proc_info.c",
176  "src/x86_64/Lget_save_loc.c",
177  "src/x86_64/Lglobal.c",
178  "src/x86_64/Linit.c",
179  "src/x86_64/Linit_local.c",
180  "src/x86_64/Linit_remote.c",
181  "src/x86_64/Los-linux.c",
182  "src/x86_64/Lregs.c",
183  "src/x86_64/Lresume.c",
184  "src/x86_64/Lstash_frame.c",
185  "src/x86_64/Lstep.c",
186  "src/x86_64/Ltrace.c",
187  "src/x86_64/getcontext.S",
188  "src/x86_64/is_fpreg.c",
189  "src/x86_64/regname.c",
190  "src/x86_64/setcontext.S",
191]
192
193remove_sources = []
194
195ptrace_sources = [
196  "src/ptrace/_UPT_access_fpreg.c",
197  "src/ptrace/_UPT_access_mem.c",
198  "src/ptrace/_UPT_access_reg.c",
199  "src/ptrace/_UPT_accessors.c",
200  "src/ptrace/_UPT_create.c",
201  "src/ptrace/_UPT_destroy.c",
202  "src/ptrace/_UPT_find_proc_info.c",
203  "src/ptrace/_UPT_get_dyn_info_list_addr.c",
204  "src/ptrace/_UPT_get_proc_name.c",
205  "src/ptrace/_UPT_put_unwind_info.c",
206  "src/ptrace/_UPT_reg_offset.c",
207  "src/ptrace/_UPT_resume.c",
208]
209
210libunwind_la_SOURCES_local_nounwind = [
211  "src/mi/backtrace.c",
212  "src/mi/dyn-cancel.c",
213  "src/mi/dyn-info-list.c",
214  "src/mi/dyn-register.c",
215  "src/mi/Ldyn-extract.c",
216  "src/mi/Lfind_dynamic_proc_info.c",
217
218  # "src/mi/Lget_accessors.c", # miss
219  "src/mi/Lget_proc_info_by_ip.c",
220  "src/mi/Lget_proc_name.c",
221  "src/mi/Lput_dynamic_unwind_info.c",
222  "src/mi/Ldestroy_addr_space.c",
223  "src/mi/Lget_reg.c",
224  "src/mi/Lset_reg.c",
225  "src/mi/Lget_fpreg.c",
226  "src/mi/Lset_fpreg.c",
227  "src/mi/Lset_caching_policy.c",
228  "src/mi/Lset_cache_size.c",
229]
230
231libunwind_dwarf_local_la_SOURCES = [
232  "src/dwarf/Lexpr.c",
233  "src/dwarf/Lfde.c",
234  "src/dwarf/Lparser.c",
235  "src/dwarf/Lpe.c",
236  "src/dwarf/Lfind_proc_info-lsb.c",
237  "src/dwarf/Lfind_unwind_table.c",
238]
239
240# remove local file
241remove_sources += libunwind_la_SOURCES_local_nounwind
242remove_sources += libunwind_dwarf_local_la_SOURCES
243remove_sources += ptrace_sources
244
245if (is_mingw) {
246  common_source += [ "src/mingw/pal-single-threaded.c" ]
247}
248
249config("unwind_config_public") {
250  include_dirs = [
251    "src",
252    "include",
253  ]
254
255  cflags = [
256    "-D_GNU_SOURCE",
257    "-DHAVE_CONFIG_H",
258    "-DNDEBUG",
259    "-DCC_IS_CLANG",
260    "-fcommon",
261    "-Werror",
262    "-Wno-absolute-value",
263    "-Wno-header-guard",
264    "-Wno-unused-parameter",
265    "-Wno-unused-variable",
266    "-Wno-int-to-pointer-cast",
267    "-Wno-pointer-to-int-cast",
268  ]
269
270  if (defined(ohos_lite)) {
271    cflags += [ "-fPIC" ]
272  }
273
274  if (target_cpu == "arm") {
275    include_dirs += [ "include/tdep-arm" ]
276    cflags += [
277      "-Wno-inline-asm",
278      "-Wno-shift-count-overflow",
279      "-Wno-tautological-constant-out-of-range-compare",
280      "-Wno-unused-function",
281    ]
282  } else if (target_cpu == "arm64") {
283    include_dirs += [ "include/tdep-aarch64" ]
284    cflags += [ "-Wno-incompatible-pointer-types" ]
285  } else if (target_cpu == "x64" || target_cpu == "x86_64") {
286    include_dirs += [ "include/tdep-x86_64" ]
287  } else if (target_cpu == "mipsel") {
288    include_dirs += [ "include/tdep-mips" ]
289  }
290}
291
292config("unwind_config_remote") {
293  cflags =
294      [ "-Wno-format" ]  # some debug feature will warning in host x64 build
295}
296
297config("unwind_config_local_only") {
298  defines = [ "UNW_LOCAL_ONLY" ]
299}
300
301config("unwind_config_remote_public") {
302  cflags = []
303  include_dirs = []
304  defines = []
305
306  # this is a host tools build
307  # what means host use remote mode to unwind
308  # with dwarf from stack or coredump or something not real target
309  # There is an exception, we can support local unwind for linux.
310  cflags += [ "-DUNW_REMOTE_ONLY" ]
311
312  cflags += [ "-DBUILD_REMOTE" ]
313
314  cflags += [ "-Wno-sometimes-uninitialized" ]  # some value not initialized in
315                                                # host x64 build
316  cflags += [ "-Wno-int-to-void-pointer-cast" ]
317
318  if (is_mingw) {
319    include_dirs += [ "include/mingw" ]
320    cflags += [ "-DMINGW" ]
321  } else if (is_linux) {
322    cflags += [ "-g" ]  # we need debug info when it crash.
323  }
324
325  defines += [ "build_remote=1" ]
326  defines += [ "target_cpu=${target_cpu}" ]
327  defines += [ "host_toolchain=${host_toolchain}" ]
328  defines += [ "current_toolchain=${current_toolchain}" ]
329  defines += [ "default_toolchain=${default_toolchain}" ]
330}
331
332config("unwind_config_arm") {
333  defines = [ "UNW_TARGET_ARM" ]
334}
335
336config("unwind_config_arm64") {
337  defines = [ "UNW_TARGET_ARM64" ]
338}
339
340config("unwind_config_arm64_opt") {
341  defines = [ "ONLY_RECOVER_GENERAL_REGS" ]
342}
343
344config("unwind_config_x64") {
345  defines = [ "UNW_TARGET_X86_64" ]
346  defines += [ "UNW_TARGET_X86_64_LINUX" ]
347}
348
349config("unwind_config_x86_64") {
350  defines = [ "UNW_TARGET_X86_64" ]
351  defines += [ "UNW_TARGET_X86_64_LINUX" ]
352}
353
354if (defined(ohos_lite)) {
355  source_set("unwind_source_arm") {
356    configs += [ ":unwind_config_remote" ]
357    public_configs = [
358      ":unwind_config_public",
359      ":unwind_config_remote_public",
360      ":unwind_config_arm",
361    ]
362    sources = common_source
363
364    # no jump lib
365    arm_source -= [
366      "src/arm/getcontext.S",
367      "src/arm/siglongjmp.S",
368    ]
369    sources += arm_source
370    sources -= remove_sources
371  }
372
373  source_set("unwind_source_arm64") {
374    configs += [ ":unwind_config_remote" ]
375    public_configs = [
376      ":unwind_config_public",
377      ":unwind_config_remote_public",
378      ":unwind_config_arm64",
379    ]
380    sources = common_source
381
382    arm64_source -= [ "src/aarch64/getcontext.S" ]
383
384    sources += arm64_source
385    sources -= remove_sources
386  }
387
388  source_set("unwind_source_x64") {
389    configs += [ ":unwind_config_remote" ]
390    public_configs = [
391      ":unwind_config_public",
392      ":unwind_config_remote_public",
393      ":unwind_config_x64",
394    ]
395    sources = common_source
396
397    # no jump lib
398    x64_source -= [
399      "src/x86_64/getcontext.S",
400      "src/x86_64/setcontext.S",
401    ]
402    sources += x64_source
403    sources -= remove_sources
404  }
405
406  source_set("unwind_source") {
407    configs += [ ":unwind_config_public" ]
408    sources = common_source
409
410    if (target_cpu == "arm") {
411      # no jump lib
412      arm_source -= [
413        "src/arm/getcontext.S",
414        "src/arm/siglongjmp.S",
415      ]
416
417      # as libc++ is static linked with libunwind.a
418      # we remove the Gstep.c for duplicated symbol violation
419      sources += arm_source
420      public_configs = [ ":unwind_config_arm" ]
421    } else if (target_cpu == "arm64") {
422      sources += arm64_source
423      public_configs = [ ":unwind_config_arm64" ]
424    } else if (target_cpu == "x64") {
425      sources += x64_source
426      public_configs = [ ":unwind_config_x64" ]
427    } else if (target_cpu == "x86_64") {
428      sources += x64_source
429      public_configs = [ ":unwind_config_x86_64" ]
430    }
431
432    sources += [ "src/os-ohos.c" ]
433  }
434
435  shared_library("libunwind") {
436    deps = [ ":unwind_source" ]
437    public_configs = [ ":unwind_config_public" ]
438  }
439
440  static_library("libunwind_local") {
441    sources = common_source
442    public_configs = [ ":unwind_config_public" ]
443    public_configs += [ ":unwind_config_local_only" ]
444
445    if (target_cpu == "arm") {
446      sources += arm_source
447      sources -= arm_source_local
448      public_configs += [ ":unwind_config_arm" ]
449    } else if (target_cpu == "arm64") {
450      sources += arm64_source
451      sources -= arm64_source_local
452      public_configs += [ ":unwind_config_arm64" ]
453    } else if (target_cpu == "x64") {
454      sources += x64_source
455      sources -= x64_source_local
456      public_configs += [ ":unwind_config_x64" ]
457    } else if (target_cpu == "x86_64") {
458      sources += x64_source
459      sources -= x64_source_local
460      public_configs += [ ":unwind_config_x86_64" ]
461    }
462
463    sources += [ "src/os-ohos.c" ]
464    sources -= libunwind_dwarf_local_la_SOURCES
465    sources -= libunwind_la_SOURCES_local
466    sources -= ptrace_sources
467
468    cflags = [
469      "-DHAS_ARK_FRAME",
470      "-DPARSE_BUILD_ID",
471      "-DUNW_LOCAL_ONLY",
472      "-DNO_RESERVE_CACHE",
473    ]
474  }
475} else {
476  ohos_source_set("unwind_source_arm") {
477    configs = [ ":unwind_config_remote" ]
478    public_configs = [
479      ":unwind_config_public",
480      ":unwind_config_remote_public",
481      ":unwind_config_arm",
482    ]
483    sources = common_source
484
485    # no jump lib
486    arm_source -= [
487      "src/arm/getcontext.S",
488      "src/arm/siglongjmp.S",
489    ]
490    sources += arm_source
491    sources -= remove_sources
492  }
493
494  ohos_source_set("unwind_source_arm64") {
495    configs = [ ":unwind_config_remote" ]
496    public_configs = [
497      ":unwind_config_public",
498      ":unwind_config_remote_public",
499      ":unwind_config_arm64",
500    ]
501    sources = common_source
502
503    arm64_source -= [ "src/aarch64/getcontext.S" ]
504
505    sources += arm64_source
506    sources -= remove_sources
507  }
508
509  ohos_source_set("unwind_source_arm64_opt") {
510    configs = [ ":unwind_config_remote" ]
511    public_configs = [
512      ":unwind_config_public",
513      ":unwind_config_remote_public",
514      ":unwind_config_arm64",
515      ":unwind_config_arm64_opt",
516    ]
517    sources = common_source
518
519    arm64_source -= [ "src/aarch64/getcontext.S" ]
520
521    sources += arm64_source
522    sources -= remove_sources
523  }
524
525  ohos_source_set("unwind_source_x64") {
526    configs = [ ":unwind_config_remote" ]
527    public_configs = [
528      ":unwind_config_public",
529      ":unwind_config_remote_public",
530      ":unwind_config_x64",
531    ]
532    sources = common_source
533
534    # no jump lib
535    x64_source -= [
536      "src/x86_64/getcontext.S",
537      "src/x86_64/setcontext.S",
538    ]
539    sources += x64_source
540    sources -= remove_sources
541  }
542
543  ohos_source_set("unwind_source_x86_64") {
544    configs = [ ":unwind_config_remote" ]
545    public_configs = [
546      ":unwind_config_public",
547      ":unwind_config_remote_public",
548      ":unwind_config_x86_64",
549    ]
550    sources = common_source
551
552    # no jump lib
553    x64_source -= [
554      "src/x86_64/getcontext.S",
555      "src/x86_64/setcontext.S",
556    ]
557    sources += x64_source
558    sources -= remove_sources
559  }
560
561  ohos_source_set("unwind_source") {
562    configs = [ ":unwind_config_public" ]
563    sources = common_source
564
565    if (target_cpu == "arm") {
566      # as libc++ is static linked with libunwind.a
567      # we remove the Gstep.c for duplicated symbol violation
568      sources += arm_source
569      public_configs = [ ":unwind_config_arm" ]
570    } else if (target_cpu == "arm64") {
571      sources += arm64_source
572      public_configs = [ ":unwind_config_arm64" ]
573    } else if (target_cpu == "x64") {
574      sources += x64_source
575      public_configs = [ ":unwind_config_x64" ]
576    } else if (target_cpu == "x86_64") {
577      sources += x64_source
578      public_configs = [ ":unwind_config_x86_64" ]
579    }
580
581    sources += [ "src/os-ohos.c" ]
582    cflags = [
583      "-DHAS_ARK_FRAME",
584      "-DPARSE_BUILD_ID",
585      "-DPARSE_ELF_IN_HAP",
586    ]
587  }
588
589  ohos_shared_library("libunwind") {
590    deps = [ ":unwind_source" ]
591    install_images = [
592      "system",
593      "updater",
594    ]
595    public_configs = [ ":unwind_config_public" ]
596    innerapi_tags = [
597      "platformsdk",
598      "chipsetsdk",
599    ]
600    subsystem_name = "thirdparty"
601    part_name = "libunwind"
602  }
603
604  ohos_static_library("libunwind_local") {
605    sources = common_source
606    public_configs = [ ":unwind_config_public" ]
607    public_configs += [ ":unwind_config_local_only" ]
608
609    if (target_cpu == "arm") {
610      sources += arm_source
611      sources -= arm_source_local
612      public_configs += [ ":unwind_config_arm" ]
613    } else if (target_cpu == "arm64") {
614      sources += arm64_source
615      sources -= arm64_source_local
616      public_configs += [ ":unwind_config_arm64" ]
617    } else if (target_cpu == "x64") {
618      sources += x64_source
619      sources -= x64_source_local
620      public_configs += [ ":unwind_config_x64" ]
621    } else if (target_cpu == "x86_64") {
622      sources += x64_source
623      sources -= x64_source_local
624      public_configs += [ ":unwind_config_x86_64" ]
625    }
626
627    sources += [ "src/os-ohos.c" ]
628    sources -= libunwind_dwarf_local_la_SOURCES
629    sources -= libunwind_la_SOURCES_local
630    sources -= ptrace_sources
631
632    cflags = [
633      "-DHAS_ARK_FRAME",
634      "-DPARSE_BUILD_ID",
635      "-DUNW_LOCAL_ONLY",
636      "-DNO_RESERVE_CACHE",
637      "-DHAVE_PIPE2",
638    ]
639
640    subsystem_name = "thirdparty"
641    part_name = "libunwind"
642  }
643}
644
645if (!defined(ohos_lite)) {
646  import("//build/test.gni")
647  module_output_path = "thirdparty/libunwind"
648  group("unittest") {
649    testonly = true
650    deps = [
651      ":Gtest_bt",
652      ":Gtest_dyn1",
653      ":Gtest_init",
654      ":Gtest_trace",
655      ":Ltest_bt",
656      ":Ltest_cxx_exceptions",
657      ":Ltest_dyn1",
658      ":Ltest_init",
659      ":Ltest_init_local_signal",
660      ":Ltest_mem_validate",
661      ":Ltest_nocalloc",
662      ":Ltest_nomalloc",
663      ":Ltest_trace",
664      ":test_ptrace_misc",
665      ":test_static_link",
666    ]
667  }
668  config("unwind_test") {
669    cflags = [ "-O0" ]
670  }
671
672  ohos_unittest("Gtest_init") {
673    module_out_path = module_output_path
674    sources = [ "tests/Gtest-init.cxx" ]
675    include_dirs = [
676      "tests",
677      "include",
678    ]
679
680    configs = [ ":unwind_test" ]
681    deps = [ ":libunwind" ]
682    subsystem_name = "thirdparty"
683    part_name = "libunwind"
684  }
685
686  ohos_unittest("Ltest_init") {
687    module_out_path = module_output_path
688    sources = [ "tests/Ltest-init.cxx" ]
689    include_dirs = [
690      "tests",
691      "include",
692    ]
693    configs = [ ":unwind_test" ]
694    deps = [ ":libunwind" ]
695    subsystem_name = "thirdparty"
696    part_name = "libunwind"
697  }
698
699  ohos_unittest("Ltest_cxx_exceptions") {
700    module_out_path = module_output_path
701    sources = [ "tests/Ltest-cxx-exceptions.cxx" ]
702    include_dirs = [
703      "tests",
704      "include",
705    ]
706    configs = [ ":unwind_test" ]
707    cflags = [ "-fexceptions" ]
708    deps = [ ":libunwind" ]
709    subsystem_name = "thirdparty"
710    part_name = "libunwind"
711    remove_configs = [ "//build/config/compiler:no_exceptions" ]
712  }
713
714  ohos_unittest("Ltest_init_local_signal") {
715    module_out_path = module_output_path
716    sources = [
717      "tests/Ltest-init-local-signal-lib.c",
718      "tests/Ltest-init-local-signal.c",
719    ]
720    include_dirs = [
721      "tests",
722      "include",
723    ]
724    configs = [ ":unwind_test" ]
725    deps = [ ":libunwind" ]
726    subsystem_name = "thirdparty"
727    part_name = "libunwind"
728  }
729
730  ohos_unittest("Gtest_dyn1") {
731    module_out_path = module_output_path
732    sources = [
733      "tests/Gtest-dyn1.c",
734      "tests/flush-cache.h",
735    ]
736    if (target_cpu == "arm") {
737      sources += [ "tests/flush-cache.S" ]
738    }
739    include_dirs = [
740      "tests",
741      "include",
742    ]
743    configs = [ ":unwind_test" ]
744    cflags = [ "-DHAVE__BUILTIN___CLEAR_CACHE" ]
745    deps = [ ":libunwind" ]
746    subsystem_name = "thirdparty"
747    part_name = "libunwind"
748  }
749
750  ohos_unittest("Ltest_dyn1") {
751    module_out_path = module_output_path
752    sources = [
753      "tests/Ltest-dyn1.c",
754      "tests/flush-cache.h",
755    ]
756    if (target_cpu == "arm") {
757      sources += [ "tests/flush-cache.S" ]
758    }
759    include_dirs = [
760      "tests",
761      "include",
762    ]
763    configs = [ ":unwind_test" ]
764    cflags = [ "-DHAVE__BUILTIN___CLEAR_CACHE" ]
765    deps = [ ":libunwind" ]
766    subsystem_name = "thirdparty"
767    part_name = "libunwind"
768  }
769
770  ohos_unittest("test_static_link") {
771    module_out_path = module_output_path
772    sources = [
773      "tests/test-static-link-gen.c",
774      "tests/test-static-link-loc.c",
775    ]
776    include_dirs = [
777      "tests",
778      "include",
779    ]
780    configs = [ ":unwind_test" ]
781    deps = [ ":libunwind" ]
782    subsystem_name = "thirdparty"
783    part_name = "libunwind"
784  }
785
786  ohos_unittest("Gtest_bt") {
787    module_out_path = module_output_path
788    sources = [
789      "tests/Gtest-bt.c",
790      "tests/dummy_backtrace.c",
791      "tests/ident.c",
792    ]
793    include_dirs = [
794      "tests",
795      "include",
796    ]
797    configs = [ ":unwind_test" ]
798    deps = [ ":libunwind" ]
799    subsystem_name = "thirdparty"
800    part_name = "libunwind"
801  }
802
803  ohos_unittest("Ltest_bt") {
804    module_out_path = module_output_path
805    sources = [
806      "tests/Ltest-bt.c",
807      "tests/dummy_backtrace.c",
808      "tests/ident.c",
809    ]
810    include_dirs = [
811      "tests",
812      "include",
813    ]
814    configs = [ ":unwind_test" ]
815    deps = [ ":libunwind" ]
816    subsystem_name = "thirdparty"
817    part_name = "libunwind"
818  }
819
820  ohos_unittest("test_ptrace_misc") {
821    module_out_path = module_output_path
822    sources = [
823      "tests/ident.c",
824      "tests/test-ptrace-misc.c",
825    ]
826    include_dirs = [
827      "tests",
828      "include",
829    ]
830    configs = [ ":unwind_test" ]
831    deps = [ ":libunwind" ]
832    subsystem_name = "thirdparty"
833    part_name = "libunwind"
834  }
835
836  ohos_unittest("Ltest_nomalloc") {
837    module_out_path = module_output_path
838    sources = [ "tests/Ltest-nomalloc.c" ]
839    include_dirs = [
840      "tests",
841      "include",
842    ]
843    configs = [ ":unwind_test" ]
844    deps = [ ":libunwind" ]
845    subsystem_name = "thirdparty"
846    part_name = "libunwind"
847  }
848
849  ohos_unittest("Ltest_nocalloc") {
850    module_out_path = module_output_path
851    sources = [ "tests/Ltest-nocalloc.c" ]
852    include_dirs = [
853      "tests",
854      "include",
855    ]
856    configs = [ ":unwind_test" ]
857    deps = [ ":libunwind" ]
858    subsystem_name = "thirdparty"
859    part_name = "libunwind"
860  }
861
862  ohos_unittest("Gtest_trace") {
863    module_out_path = module_output_path
864    sources = [
865      "tests/Gtest-trace.c",
866      "tests/dummy_backtrace.c",
867      "tests/ident.c",
868    ]
869    include_dirs = [
870      "tests",
871      "include",
872    ]
873    configs = [ ":unwind_test" ]
874    deps = [ ":libunwind" ]
875    subsystem_name = "thirdparty"
876    part_name = "libunwind"
877  }
878
879  ohos_unittest("Ltest_trace") {
880    module_out_path = module_output_path
881    sources = [
882      "tests/Ltest-trace.c",
883      "tests/dummy_backtrace.c",
884      "tests/ident.c",
885    ]
886    include_dirs = [
887      "tests",
888      "include",
889    ]
890    configs = [ ":unwind_test" ]
891    deps = [ ":libunwind" ]
892    subsystem_name = "thirdparty"
893    part_name = "libunwind"
894  }
895
896  ohos_unittest("Ltest_mem_validate") {
897    module_out_path = module_output_path
898    sources = [ "tests/Ltest-mem-validate.c" ]
899    include_dirs = [
900      "tests",
901      "include",
902    ]
903    configs = [ ":unwind_test" ]
904    deps = [ ":libunwind" ]
905    subsystem_name = "thirdparty"
906    part_name = "libunwind"
907  }
908} else {
909  group("unittest") {
910    testonly = true
911    deps = []
912  }
913}
914