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