• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2023 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
14import("//base/hiviewdfx/faultloggerd/faultloggerd.gni")
15
16if (!defined(ohos_lite)) {
17  callstack_sources = [
18    "src/callstack.cpp",
19    "src/register.cpp",
20  ]
21
22  config("common_callstack_config") {
23    visibility = [ ":*" ]
24    include_dirs = [
25      "include",
26      "$faultloggerd_path/common",
27    ]
28    defines = [ "HAVE_LIBUNWIND" ]
29
30    cflags = [ "-Wno-unused-private-field" ]
31
32    ldflags = []
33
34    if (is_mingw) {
35      # lld: error: unable to find library -latomic
36      # lld: error: unable to find library -ldl
37      # lld: error: unable to find library -lrt
38      ldflags += [
39        "-Wl,--whole-archive",
40        "-lpthread",
41        "-Wl,--no-whole-archive",
42      ]
43    } else if (is_linux) {
44      ldflags += [
45        "-lpthread",
46        "-latomic",
47        "-ldl",
48        "-lrt",
49        "-Wl,--no-whole-archive",
50      ]
51    }
52
53    cflags += [ "-std=c++17" ]
54    defines += [ "is_mingw=${is_mingw}" ]
55    if (is_ohos) {
56      defines += [ "CALLSTACK_PRINT_LOG" ]
57    }
58    if (is_mingw) {
59      cflags += [ "-includeMingW64Fix.h" ]
60      defines += [ "WIN32_LEAN_AND_MEAN" ]
61      defines += [ "__LITTLE_ENDIAN_BITFIELD" ]
62
63      include_dirs += [
64        "../../../../../../developtools/hiperf/include/nonlinux/",
65        "../../../../../../kernel/linux/patches/linux-5.10/prebuilts/usr/include",
66      ]
67    }
68  }
69
70  config("hiperf_callstack_config") {
71    defines = [ "HIPERF_USE_CALLSTACK" ]
72    include_dirs = [ "../../../../../../developtools/hiperf/include" ]
73  }
74
75  config("nativedaemon_callstack_config") {
76    defines = [ "NATIVEDAEMON_USE_CALLSTACK" ]
77    include_dirs = [ "../../../../../../developtools/profiler/device/plugins/native_daemon/include" ]
78  }
79
80  # callstack_perf static library only support for hiperf currently.
81  # some configs have to be exposed.
82  ohos_static_library("callstack_perf") {
83    public_configs = [
84      ":common_callstack_config",
85      ":hiperf_callstack_config",
86      "../../../../../../commonlibrary/c_utils/base:utils_config",
87      "//third_party/bounds_checking_function:libsec_public_config",
88      "//third_party/googletest:gtest_config",
89      "$faultloggerd_path/common/build:coverage_flags",
90    ]
91
92    include_dirs = [
93      "$faultloggerd_path/common/dfxlog",
94      "$faultloggerd_path/common/dfxutil",
95    ]
96
97    sources = callstack_sources
98
99    deps = []
100    public_deps = []
101
102    if (is_ohos) {
103      deps += [
104        "$faultloggerd_path/common/dfxlog:static_common_log",
105        "//third_party/bounds_checking_function:libsec_shared",
106      ]
107      if (target_cpu == "arm64") {
108        public_deps += [ "//third_party/libunwind:unwind_source_arm64_opt" ]
109      } else {
110        public_deps += [ "//third_party/libunwind:unwind_source_${target_cpu}" ]
111      }
112      external_deps = [ "c_utils:utils" ]
113    } else {
114      deps += [ "//third_party/bounds_checking_function:libsec_static" ]
115      public_deps += [ "//third_party/libunwind:unwind_source_${host_cpu}" ]
116    }
117
118    part_name = "faultloggerd"
119    subsystem_name = "hiviewdfx"
120  }
121
122  # callstack_nativedaemon static library only support for profiler nativedaemon plugin currently.
123  # some configs have to be exposed.
124  ohos_static_library("callstack_nativedaemon") {
125    public_configs = [
126      ":common_callstack_config",
127      ":nativedaemon_callstack_config",
128      "../../../../../../commonlibrary/c_utils/base:utils_config",
129      "//third_party/bounds_checking_function:libsec_public_config",
130      "//third_party/googletest:gtest_config",
131      "$faultloggerd_path/common/build:coverage_flags",
132    ]
133
134    include_dirs = [
135      "$faultloggerd_path/common/dfxlog",
136      "$faultloggerd_path/common/dfxutil",
137    ]
138
139    sources = callstack_sources
140    deps = []
141    public_deps = []
142
143    if (is_ohos) {
144      deps += [
145        "$faultloggerd_path/common/dfxlog:static_common_log",
146        "//third_party/bounds_checking_function:libsec_shared",
147      ]
148      if (target_cpu == "arm64") {
149        public_deps += [ "//third_party/libunwind:unwind_source_arm64_opt" ]
150      } else {
151        public_deps += [ "//third_party/libunwind:unwind_source_${target_cpu}" ]
152      }
153      external_deps = [ "c_utils:utils" ]
154    } else {
155      deps += [ "//third_party/bounds_checking_function:libsec_static" ]
156      public_deps += [ "//third_party/libunwind:unwind_source_${host_cpu}" ]
157    }
158
159    part_name = "faultloggerd"
160    subsystem_name = "hiviewdfx"
161  }
162}
163