• 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
14import("//base/hiviewdfx/faultloggerd/faultloggerd.gni")
15
16if (defined(ohos_lite)) {
17  shared_library("dfx_signalhandler") {
18    visibility = [ "*:*" ]
19    include_dirs = [
20      "include",
21      "//commonlibrary/c_utils/base/include",
22      "$faultloggerd_interfaces_path/common",
23      "$faultloggerd_path/common",
24      "$faultloggerd_path/common/cutil",
25      "$faultloggerd_path/common/dfxlog",
26    ]
27    sources = [ "dfx_signal_handler.c" ]
28
29    deps = [
30      "$faultloggerd_path/common/cutil:dfx_cutil",
31      "//third_party/bounds_checking_function:libsec_shared",
32    ]
33
34    cflags = [
35      "-fPIC",
36      "-fno-builtin",
37      "-DDFX_NO_PRINT_LOG",
38    ]
39  }
40} else {
41  inherited_configs = [
42    "//build/config/compiler:afdo",
43    "//build/config/compiler:afdo_optimize_size",
44    "//build/config/compiler:compiler",
45    "//build/config/compiler:compiler_arm_fpu",
46    "//build/config/compiler:compiler_arm_thumb",
47    "//build/config/compiler:chromium_code",
48    "//build/config/compiler:default_include_dirs",
49    "//build/config/compiler:default_optimization",
50    "//build/config/compiler:default_stack_frames",
51    "//build/config/compiler:default_symbols",
52    "//build/config/compiler:export_dynamic",
53    "//build/config/compiler:no_exceptions",
54    "//build/config/compiler:no_rtti",
55    "//build/config/compiler:runtime_library",
56    "//build/config/compiler:thin_archive",
57    "//build/config/sanitizers:default_sanitizer_flags",
58  ]
59
60  config("dfx_signal_handler_config") {
61    visibility = [ "*:*" ]
62    include_dirs = [
63      "include",
64      "$faultloggerd_interfaces_path/common",
65    ]
66  }
67
68  config("static_sighandler_config") {
69    include_dirs = [
70      "include",
71      "$faultloggerd_interfaces_path/common",
72      "$faultloggerd_path/common",
73      "$faultloggerd_path/common/cutil",
74      "$faultloggerd_path/common/dfxlog",
75    ]
76
77    defines = []
78    configs = []
79    if (is_posix) {
80      configs += [ "//build/config/posix:runtime_library" ]
81    }
82
83    cflags_cc = []
84    libs = []
85
86    defines = [
87      "__GNU_SOURCE=1",  # Necessary for clone().
88      "CHROMIUM_CXX_TWEAK_INLINES",  # Saves binary size.
89    ]
90
91    defines += [
92      "__MUSL__",
93      "_LIBCPP_HAS_MUSL_LIBC",
94      "__BUILD_LINUX_WITH_CLANG",
95      "ENABLE_SIGHAND_MUSL_LOG",
96      "ENABLE_MUSL_CUTIL",
97    ]
98
99    ldflags = [ "-nostdlib" ]
100  }
101
102  ohos_static_library("dfx_local_handler") {
103    public_configs = [
104      ":dfx_signal_handler_config",
105      "$faultloggerd_path/common/build:coverage_flags",
106    ]
107    include_dirs = [
108      ".",
109      "$faultloggerd_path/common",
110      "$faultloggerd_path/common/cutil",
111      "$faultloggerd_path/common/dfxlog",
112    ]
113    sources = [
114      "dfx_crash_local_handler.c",
115      "dfx_signal_local_handler.c",
116    ]
117
118    deps = [
119      "$faultloggerd_path/common/cutil:dfx_cutil",
120      "$faultloggerd_path/common/dfxlog:static_hilog_base",
121      "$faultloggerd_path/interfaces/innerkits/faultloggerd_client:libfaultloggerd",
122      "//third_party/libunwind:libunwind",
123    ]
124
125    external_deps = [
126      "c_utils:utils",
127      "hilog:libhilog_base",
128    ]
129
130    part_name = "faultloggerd"
131    subsystem_name = "hiviewdfx"
132  }
133
134  ohos_shared_library("dfx_signalhandler") {
135    public_configs = [
136      ":dfx_signal_handler_config",
137      "$faultloggerd_path/common/build:coverage_flags",
138    ]
139    include_dirs = [
140      "$faultloggerd_path/common",
141      "$faultloggerd_path/common/cutil",
142      "$faultloggerd_path/common/dfxlog",
143    ]
144    cflags = [ "-DDFX_LOG_USE_HILOG_BASE" ]
145    version_script = "libdfx_signalhandler.map"
146    sources = [ "dfx_signal_handler.c" ]
147
148    deps = [
149      "$faultloggerd_path/common/cutil:dfx_cutil",
150      "$faultloggerd_path/common/dfxlog:static_hilog_base",
151    ]
152
153    external_deps = [
154      "c_utils:utils",
155      "hilog:libhilog_base",
156    ]
157
158    innerapi_tags = [
159      "chipsetsdk_indirect",
160      "platformsdk_indirect",
161    ]
162    if (use_musl) {
163      install_enable = false
164    } else {
165      install_enable = true
166    }
167
168    install_images = [
169      "system",
170      "updater",
171    ]
172
173    part_name = "faultloggerd"
174    subsystem_name = "hiviewdfx"
175  }
176
177  source_set("dfxsignalhandler") {
178    cflags = [ "-DDFX_SIGNAL_LIBC" ]
179
180    sources = [ "dfx_signal_handler.c" ]
181    configs -= inherited_configs
182    configs += [
183      "//build/config/compiler:compiler",
184      ":static_sighandler_config",
185    ]
186
187    deps = [
188      "//third_party/musl:create_alltypes_h",
189      "//third_party/musl:create_porting_src",
190      "//third_party/musl:create_syscall_h",
191      "//third_party/musl:create_version_h",
192      "//third_party/musl:musl_copy_inc_bits",
193      "//third_party/musl:musl_copy_inc_root",
194      "//third_party/musl:musl_copy_inc_sys",
195    ]
196  }
197}
198