1# Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. 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("//build/ohos.gni") 15import("../../base/config.gni") 16 17config("cflags_config") { 18 cflags = [ "-O3" ] 19} 20 21config("hook_config") { 22 defines = [ 23 "HAVE_LIBUNWIND=0", 24 "HAVE_LIBUNWINDER=1", 25 "HIPERF_DEBUG", 26 "CONFIG_NO_HILOG", 27 "NATIVEDAEMON_USE_CALLSTACK", 28 ] 29 defines += [ "target_cpu_${target_cpu}" ] 30 if (musl_use_jemalloc) { 31 defines += [ "USE_JEMALLOC" ] 32 } 33} 34 35config("profiler_sa_config") { 36 visibility = [ ":*" ] 37 include_dirs = [ 38 "native_memory_profiler_sa/include", 39 "native_memory_profiler_sa/util/include", 40 "../../base/include", 41 ] 42} 43 44ohos_prebuilt_etc("hiprofiler_daemon.cfg") { 45 source = "../../etc/hiprofiler_daemon.cfg" 46 relative_install_dir = "init" 47 part_name = "${OHOS_PROFILER_PART_NAME}" 48 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 49} 50 51ohos_executable("native_daemon") { 52 output_name = "native_daemon" 53 configs = [ ":cflags_config" ] 54 public_configs = [ 55 ":hook_config", 56 "${OHOS_PROFILER_DIR}/device/base:hiprofiler_test_config", 57 ] 58 sources = [ 59 "../api/src/buffer_writer.cpp", 60 "../api/src/command_poller.cpp", 61 "../api/src/writer_adapter.cpp", 62 "src/debug_logger.cpp", 63 "src/dwarf_encoding.cpp", 64 "src/get_thread_id.cpp", 65 "src/hook_manager.cpp", 66 "src/hook_record.cpp", 67 "src/hook_record_factory.cpp", 68 "src/hook_service.cpp", 69 "src/hook_standalone.cpp", 70 "src/main.cpp", 71 "src/register.cpp", 72 "src/stack_builder.cpp", 73 "src/stack_data_repeater.cpp", 74 "src/stack_preprocess.cpp", 75 "src/symbols_file.cpp", 76 "src/utilities.cpp", 77 "src/virtual_runtime.cpp", 78 "src/virtual_thread.cpp", 79 ] 80 81 if (is_ohos) { 82 sources += [ "./src/call_stack.cpp" ] 83 } 84 85 include_dirs = [ 86 "./include", 87 "./src", 88 "../../base/include", 89 "../api/include", 90 "../api/src", 91 "${OHOS_PROFILER_DIR}/interfaces/kits", 92 "${OHOS_PROFILER_DIR}/device/services/ipc/include", 93 "${OHOS_PROFILER_DIR}/device/services/shared_memory/include", 94 ] 95 96 include_dirs += [ 97 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include", 98 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include", 99 "${OHOS_PROFILER_DIR}/device/services/profiler_service/src", 100 ] 101 102 sources += [ 103 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp", 104 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_death_recipient.cpp", 105 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_service.cpp", 106 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_stub.cpp", 107 "${OHOS_PROFILER_DIR}/device/services/profiler_service/src/trace_file_helper.cpp", 108 "${OHOS_PROFILER_DIR}/device/services/profiler_service/src/trace_file_writer.cpp", 109 ] 110 111 deps = [ 112 ":hiprofiler_daemon.cfg", 113 "${OHOS_PROFILER_DIR}/device/plugins/network_profiler/service:network_profiler_service", 114 "${OHOS_PROFILER_DIR}/device/services/shared_memory:shared_memory_source", 115 "${OHOS_PROFILER_DIR}/proto_encoder:proto_encoder_source", 116 "${OHOS_PROFILER_DIR}/protos/services:plugin_service_proto", 117 "${OHOS_PROFILER_DIR}/protos/services:profiler_service_all_type_source", 118 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp", 119 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp_standard", 120 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_encoder", 121 "../../base:hiprofiler_base", 122 ] 123 124 if (hiprofiler_use_libunwind) { 125 deps += [ "//third_party/libunwind:unwind_source_${target_cpu}" ] 126 } 127 128 external_deps = [ 129 "ability_base:extractortool", 130 "access_token:libaccesstoken_sdk", 131 "access_token:libtokensetproc_shared", 132 "bounds_checking_function:libsec_shared", 133 "cJSON:cjson", 134 "c_utils:utils", 135 "hicollie:libhicollie", 136 "hisysevent:libhisysevent", 137 "init:libbegetutil", 138 "ipc:ipc_core", 139 "openssl:libcrypto_shared", 140 "protobuf:protobuf_lite", 141 "safwk:system_ability_fwk", 142 "samgr:samgr_proxy", 143 "zlib:libz", 144 ] 145 146 defines = [ "ENABLE_HAP_EXTRACTOR" ] 147 148 if (hiprofiler_use_libunwinder) { 149 external_deps += [ "faultloggerd:libunwinder" ] 150 } 151 152 if (current_toolchain != host_toolchain) { 153 defines += [ "HAVE_HILOG" ] 154 external_deps += [ "hilog:libhilog" ] 155 } 156 use_exceptions = true 157 install_enable = true 158 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 159 part_name = "${OHOS_PROFILER_PART_NAME}" 160} 161 162ohos_executable("native_daemon_client") { 163 output_name = "native_daemon_client" 164 include_dirs = [ 165 "../../base/include", 166 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include", 167 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include", 168 ] 169 170 sources = [ 171 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_client_manager.cpp", 172 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp", 173 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_proxy.cpp", 174 "../../base/src/common.cpp", 175 "native_daemon_client.cpp", 176 ] 177 178 external_deps = [ 179 "bundle_framework:appexecfwk_base", 180 "bundle_framework:appexecfwk_core", 181 "c_utils:utils", 182 "faultloggerd:libdfx_dumpcatcher", 183 "hicollie:libhicollie", 184 "hisysevent:libhisysevent", 185 "init:libbegetutil", 186 "ipc:ipc_core", 187 "os_account:os_account_innerkits", 188 "safwk:system_ability_fwk", 189 "samgr:samgr_proxy", 190 ] 191 192 if (current_toolchain != host_toolchain) { 193 defines = [ "HAVE_HILOG" ] 194 external_deps += [ "hilog:libhilog_base" ] 195 } 196 install_enable = false 197 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 198 part_name = "${OHOS_PROFILER_PART_NAME}" 199} 200 201ohos_shared_library("libnative_daemon_client") { 202 public_configs = [ ":profiler_sa_config" ] 203 include_dirs = [ 204 "../../base/include", 205 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include", 206 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include", 207 ] 208 209 sources = [ 210 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_client_manager.cpp", 211 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp", 212 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_proxy.cpp", 213 "../../base/src/common.cpp", 214 ] 215 216 external_deps = [ 217 "bundle_framework:appexecfwk_base", 218 "bundle_framework:appexecfwk_core", 219 "c_utils:utils", 220 "faultloggerd:libdfx_dumpcatcher", 221 "hicollie:libhicollie", 222 "hisysevent:libhisysevent", 223 "init:libbegetutil", 224 "ipc:ipc_core", 225 "os_account:os_account_innerkits", 226 "safwk:system_ability_fwk", 227 "samgr:samgr_proxy", 228 ] 229 230 if (current_toolchain != host_toolchain) { 231 defines = [ "HAVE_HILOG" ] 232 external_deps += [ "hilog:libhilog_base" ] 233 } 234 235 innerapi_tags = [ "platformsdk" ] 236 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 237 part_name = "${OHOS_PROFILER_PART_NAME}" 238} 239