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