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_service.cpp", 67 "src/hook_standalone.cpp", 68 "src/main.cpp", 69 "src/register.cpp", 70 "src/stack_data_repeater.cpp", 71 "src/stack_preprocess.cpp", 72 "src/symbols_file.cpp", 73 "src/utilities.cpp", 74 "src/virtual_runtime.cpp", 75 "src/virtual_thread.cpp", 76 ] 77 78 if (is_ohos) { 79 sources += [ "./src/call_stack.cpp" ] 80 } 81 82 include_dirs = [ 83 "./include", 84 "./src", 85 "../../base/include", 86 "../api/include", 87 "../api/src", 88 "${OHOS_PROFILER_DIR}/interfaces/kits", 89 "${OHOS_PROFILER_DIR}/device/services/ipc/include", 90 "${OHOS_PROFILER_DIR}/device/services/shared_memory/include", 91 ] 92 93 include_dirs += [ 94 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include", 95 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include", 96 "${OHOS_PROFILER_DIR}/device/services/profiler_service/src", 97 ] 98 99 sources += [ 100 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp", 101 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_death_recipient.cpp", 102 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_service.cpp", 103 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_stub.cpp", 104 "${OHOS_PROFILER_DIR}/device/services/profiler_service/src/trace_file_helper.cpp", 105 "${OHOS_PROFILER_DIR}/device/services/profiler_service/src/trace_file_writer.cpp", 106 ] 107 108 deps = [ 109 ":hiprofiler_daemon.cfg", 110 "${OHOS_PROFILER_DIR}/device/plugins/network_profiler/service:network_profiler_service", 111 "${OHOS_PROFILER_DIR}/device/services/shared_memory:shared_memory_source", 112 "${OHOS_PROFILER_DIR}/proto_encoder:proto_encoder_source", 113 "${OHOS_PROFILER_DIR}/protos/services:plugin_service_proto", 114 "${OHOS_PROFILER_DIR}/protos/services:profiler_service_all_type_source", 115 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp", 116 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp_standard", 117 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_encoder", 118 "../../base:hiprofiler_base", 119 ] 120 121 if (hiprofiler_use_libunwind) { 122 deps += [ "//third_party/libunwind:unwind_source_${target_cpu}" ] 123 } 124 125 external_deps = [ 126 "ability_base:extractortool", 127 "access_token:libaccesstoken_sdk", 128 "access_token:libtokensetproc_shared", 129 "bounds_checking_function:libsec_shared", 130 "c_utils:utils", 131 "hicollie:libhicollie", 132 "hisysevent:libhisysevent", 133 "init:libbegetutil", 134 "ipc:ipc_core", 135 "openssl:libcrypto_shared", 136 "protobuf:protobuf_lite", 137 "safwk:system_ability_fwk", 138 "samgr:samgr_proxy", 139 "zlib:libz", 140 ] 141 142 defines = [ "ENABLE_HAP_EXTRACTOR" ] 143 144 if (hiprofiler_use_libunwinder) { 145 external_deps += [ "faultloggerd:libunwinder" ] 146 } 147 148 if (current_toolchain != host_toolchain) { 149 defines += [ "HAVE_HILOG" ] 150 external_deps += [ "hilog:libhilog" ] 151 } 152 use_exceptions = true 153 install_enable = true 154 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 155 part_name = "${OHOS_PROFILER_PART_NAME}" 156} 157 158ohos_executable("native_daemon_client") { 159 output_name = "native_daemon_client" 160 include_dirs = [ 161 "../../base/include", 162 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include", 163 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include", 164 ] 165 166 sources = [ 167 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_client_manager.cpp", 168 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp", 169 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_proxy.cpp", 170 "../../base/src/common.cpp", 171 "native_daemon_client.cpp", 172 ] 173 174 external_deps = [ 175 "bundle_framework:appexecfwk_base", 176 "bundle_framework:appexecfwk_core", 177 "c_utils:utils", 178 "faultloggerd:libdfx_dumpcatcher", 179 "hicollie:libhicollie", 180 "hisysevent:libhisysevent", 181 "init:libbegetutil", 182 "ipc:ipc_core", 183 "os_account:os_account_innerkits", 184 "safwk:system_ability_fwk", 185 "samgr:samgr_proxy", 186 ] 187 188 if (current_toolchain != host_toolchain) { 189 defines = [ "HAVE_HILOG" ] 190 external_deps += [ "hilog:libhilog_base" ] 191 } 192 install_enable = false 193 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 194 part_name = "${OHOS_PROFILER_PART_NAME}" 195} 196 197ohos_shared_library("libnative_daemon_client") { 198 public_configs = [ ":profiler_sa_config" ] 199 include_dirs = [ 200 "../../base/include", 201 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include", 202 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include", 203 ] 204 205 sources = [ 206 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_client_manager.cpp", 207 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp", 208 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_proxy.cpp", 209 "../../base/src/common.cpp", 210 ] 211 212 external_deps = [ 213 "bundle_framework:appexecfwk_base", 214 "bundle_framework:appexecfwk_core", 215 "c_utils:utils", 216 "faultloggerd:libdfx_dumpcatcher", 217 "hicollie:libhicollie", 218 "hisysevent:libhisysevent", 219 "init:libbegetutil", 220 "ipc:ipc_core", 221 "os_account:os_account_innerkits", 222 "safwk:system_ability_fwk", 223 "samgr:samgr_proxy", 224 ] 225 226 if (current_toolchain != host_toolchain) { 227 defines = [ "HAVE_HILOG" ] 228 external_deps += [ "hilog:libhilog_base" ] 229 } 230 231 innerapi_tags = [ "platformsdk" ] 232 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 233 part_name = "${OHOS_PROFILER_PART_NAME}" 234} 235