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