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