1# Copyright (c) 2021-2024 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 16faultloggerd_sources = [ 17 "epoll_manager.cpp", 18 "fault_logger_config.cpp", 19 "fault_logger_daemon.cpp", 20 "fault_logger_server.cpp", 21 "fault_logger_service.cpp", 22 "temp_file_manager.cpp", 23 "fault_coredump_service.cpp", 24 "fault_common_util.cpp" 25] 26 27if (defined(ohos_lite)) { 28 copy("faultlogger.cfg") { 29 sources = [ "$faultloggerd_path/services/config/faultloggerd.cfg" ] 30 outputs = [ "$root_out_dir/etc/init/faultloggerd.cfg" ] 31 } 32 33 copy("faultlogger.conf") { 34 sources = [ "$faultloggerd_path/services/config/faultlogger.conf" ] 35 outputs = [ "$root_out_dir/etc/faultlogger.conf" ] 36 } 37 38 executable("faultloggerd") { 39 visibility = [ "*:*" ] 40 41 include_dirs = [ 42 ".", 43 "$c_utils_include_path", 44 "$faultloggerd_interfaces_path/common", 45 "$faultloggerd_path/common/dfxlog", 46 "$faultloggerd_path/common/dfxutil", 47 "$hilog_lite_include_path", 48 "$faultloggerd_path/interfaces/innerkits/faultloggerd_client/include", 49 "$faultloggerd_path/interfaces/innerkits/faultloggerd_client", 50 "$faultloggerd_interfaces_path/innerkits/procinfo/include", 51 ] 52 53 sources = faultloggerd_sources 54 sources += [ 55 "$c_utils_src_path/directory_ex.cpp", 56 "main.cpp", 57 ] 58 59 cflags = [ "-fstack-protector-strong" ] 60 61 deps = [ 62 ":faultlogger.conf", 63 "$faultloggerd_common_path/trace:dfx_trace", 64 "$faultloggerd_interfaces_path/innerkits/procinfo:libdfx_procinfo", 65 "$faultloggerd_path/common/dfxlog:dfx_hilog", 66 "$faultloggerd_path/common/dfxutil:dfx_util", 67 "$faultloggerd_path/interfaces/innerkits/faultloggerd_client:libfaultloggerd", 68 ] 69 70 external_deps = [ "hilog_lite:hilog_shared" ] 71 72 defines = [ "is_ohos_lite" ] 73 if (faultloggerd_hisysevent_enable) { 74 deps += [ "hisysevent:libhisysevent" ] 75 } else { 76 defines += [ "HISYSEVENT_DISABLE" ] 77 } 78 } 79} else { 80 faultloggerd_sources += [ 81 "./snapshot/kernel_snapshot_content_builder.cpp", 82 "./snapshot/kernel_snapshot_kernel_frame.cpp", 83 "./snapshot/kernel_snapshot_manager.cpp", 84 "./snapshot/kernel_snapshot_parser.cpp", 85 "./snapshot/kernel_snapshot_printer.cpp", 86 "./snapshot/kernel_snapshot_processor_impl.cpp", 87 "./snapshot/kernel_snapshot_reporter.cpp", 88 "./snapshot/kernel_snapshot_trie.cpp", 89 "fault_logger_pipe.cpp", 90 ] 91 92 config("faultloggerd_config") { 93 visibility = [ ":*" ] 94 95 include_dirs = [ 96 ".", 97 "./snapshot", 98 "$faultloggerd_interfaces_path/common", 99 "$faultloggerd_path/common/dfxlog", 100 "$faultloggerd_path/common/dfxutil", 101 "$faultloggerd_path/interfaces/innerkits/faultloggerd_client", 102 "$faultloggerd_path/interfaces/innerkits/signal_handler", 103 "$faultloggerd_interfaces_path/innerkits/procinfo/include", 104 ] 105 } 106 107 ohos_prebuilt_etc("faultloggerd.cfg") { 108 if (use_musl) { 109 source = "config/faultloggerd.cfg" 110 } else { 111 source = "config/bionic/faultloggerd.cfg" 112 } 113 114 relative_install_dir = "init" 115 part_name = "faultloggerd" 116 subsystem_name = "hiviewdfx" 117 } 118 119 ohos_prebuilt_etc("faultloggerd_config.json") { 120 source = "config/faultloggerd_config.json" 121 part_name = "faultloggerd" 122 subsystem_name = "hiviewdfx" 123 } 124 125 ohos_prebuilt_etc("faultloggerd.para") { 126 source = "config/faultloggerd.para" 127 relative_install_dir = "param" 128 part_name = "faultloggerd" 129 subsystem_name = "hiviewdfx" 130 } 131 132 ohos_prebuilt_etc("faultloggerd.para.dac") { 133 source = "config/faultloggerd.para.dac" 134 relative_install_dir = "param" 135 part_name = "faultloggerd" 136 subsystem_name = "hiviewdfx" 137 } 138 139 ohos_prebuilt_etc("faultlogger.conf") { 140 source = "config/faultlogger.conf" 141 part_name = "faultloggerd" 142 subsystem_name = "hiviewdfx" 143 } 144 145 ohos_executable("faultloggerd") { 146 install_enable = true 147 configs = [ 148 ":faultloggerd_config", 149 "$faultloggerd_path/common/build:coverage_flags", 150 ] 151 sources = faultloggerd_sources 152 sources += [ "main.cpp" ] 153 cflags = [ "-fstack-protector-strong" ] 154 cflags_cc = [ "-DDEBUG_CRASH_LOCAL_HANDLER" ] 155 defines = [ 156 "DFX_LOG_HILOG_BASE", 157 "DFX_ENABLE_TRACE", 158 ] 159 160 161 deps = [ 162 ":faultlogger.conf", 163 ":faultloggerd.para", 164 ":faultloggerd.para.dac", 165 ":faultloggerd_config.json", 166 "$faultloggerd_frameworks_path/localhandler:dfx_local_handler_src", 167 "$faultloggerd_interfaces_path/innerkits/procinfo:libdfx_procinfo", 168 "$faultloggerd_path/common/dfxlog:dfx_hilog_base", 169 "$faultloggerd_path/common/dfxutil:dfx_util", 170 "$faultloggerd_path/common/trace:dfx_trace", 171 "$faultloggerd_path/interfaces/innerkits/faultloggerd_client:libfaultloggerd", 172 ] 173 174 if (!is_asan) { 175 deps += [ ":faultloggerd.cfg" ] 176 } else { 177 defines += [ "DFX_ALLOCATE_ASAN" ] 178 } 179 180 external_deps = [ 181 "bounds_checking_function:libsec_shared", 182 "cJSON:cjson", 183 "c_utils:utils", 184 "hilog:libhilog_base", 185 "hisysevent:libhisysevent", 186 "hitrace:hitrace_meter", 187 "init:libbegetutil", 188 ] 189 version_script = "faultloggerd.map" 190 install_images = [ 191 "system", 192 "updater", 193 ] 194 part_name = "faultloggerd" 195 subsystem_name = "hiviewdfx" 196 } 197 198 ohos_source_set("faultloggerd_test_src") { 199 configs = [ ":faultloggerd_config" ] 200 201 defines = [ "FAULTLOGGERD_TEST" ] 202 203 sources = faultloggerd_sources 204 205 deps = [ 206 "$faultloggerd_frameworks_path/localhandler:dfx_local_handler_src", 207 "$faultloggerd_interfaces_path/innerkits/procinfo:libdfx_procinfo", 208 "$faultloggerd_path/common/dfxlog:dfx_hilog_base", 209 "$faultloggerd_path/common/dfxutil:dfx_util", 210 "$faultloggerd_path/common/trace:dfx_trace", 211 "$faultloggerd_path/interfaces/innerkits/faultloggerd_client:libfaultloggerd", 212 ] 213 214 external_deps = [ 215 "bounds_checking_function:libsec_shared", 216 "cJSON:cjson", 217 "c_utils:utils", 218 "hilog:libhilog_base", 219 "hisysevent:libhisysevent", 220 "hitrace:hitrace_meter", 221 "init:libbegetutil", 222 ] 223 part_name = "faultloggerd" 224 subsystem_name = "hiviewdfx" 225 } 226} 227