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/services/shared_memory:shared_memory_source", 111 "${OHOS_PROFILER_DIR}/proto_encoder:proto_encoder_source", 112 "${OHOS_PROFILER_DIR}/protos/services:plugin_service_proto", 113 "${OHOS_PROFILER_DIR}/protos/services:profiler_service_all_type_source", 114 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp", 115 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp_standard", 116 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_encoder", 117 "../../base:hiprofiler_base", 118 ] 119 120 if (hiprofiler_use_libunwind) { 121 deps += [ "//third_party/libunwind:unwind_source_${target_cpu}" ] 122 } 123 124 external_deps = [ 125 "ability_base:extractortool", 126 "access_token:libaccesstoken_sdk", 127 "access_token:libtokensetproc_shared", 128 "bounds_checking_function:libsec_shared", 129 "hicollie:libhicollie", 130 "init:libbegetutil", 131 "ipc:ipc_core", 132 "openssl:libcrypto_shared", 133 "protobuf:protobuf_lite", 134 "safwk:system_ability_fwk", 135 "samgr:samgr_proxy", 136 "zlib:libz", 137 ] 138 139 defines = [ "ENABLE_HAP_EXTRACTOR" ] 140 141 if (hiprofiler_use_libunwinder) { 142 external_deps += [ "faultloggerd:libunwinder" ] 143 } 144 145 if (current_toolchain != host_toolchain) { 146 defines += [ "HAVE_HILOG" ] 147 external_deps += [ "hilog:libhilog" ] 148 } 149 use_exceptions = true 150 install_enable = true 151 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 152 part_name = "${OHOS_PROFILER_PART_NAME}" 153} 154 155ohos_executable("native_daemon_client") { 156 output_name = "native_daemon_client" 157 include_dirs = [ 158 "../../base/include", 159 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include", 160 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include", 161 ] 162 163 sources = [ 164 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_client_manager.cpp", 165 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp", 166 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_proxy.cpp", 167 "native_daemon_client.cpp", 168 ] 169 170 external_deps = [ 171 "c_utils:utils", 172 "hicollie:libhicollie", 173 "init:libbegetutil", 174 "ipc:ipc_core", 175 "safwk:system_ability_fwk", 176 "samgr:samgr_proxy", 177 ] 178 179 if (current_toolchain != host_toolchain) { 180 defines = [ "HAVE_HILOG" ] 181 external_deps += [ "hilog:libhilog" ] 182 } 183 install_enable = false 184 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 185 part_name = "${OHOS_PROFILER_PART_NAME}" 186} 187 188ohos_shared_library("libnative_daemon_client") { 189 public_configs = [ ":profiler_sa_config" ] 190 include_dirs = [ 191 "../../base/include", 192 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include", 193 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include", 194 ] 195 196 sources = [ 197 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_client_manager.cpp", 198 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp", 199 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_proxy.cpp", 200 "../../base/src/common.cpp", 201 ] 202 203 external_deps = [ 204 "bundle_framework:appexecfwk_base", 205 "bundle_framework:appexecfwk_core", 206 "c_utils:utils", 207 "hicollie:libhicollie", 208 "init:libbegetutil", 209 "ipc:ipc_core", 210 "os_account:os_account_innerkits", 211 "safwk:system_ability_fwk", 212 "samgr:samgr_proxy", 213 ] 214 215 if (current_toolchain != host_toolchain) { 216 defines = [ "HAVE_HILOG" ] 217 external_deps += [ "hilog:libhilog" ] 218 } 219 220 innerapi_tags = [ "platformsdk" ] 221 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 222 part_name = "${OHOS_PROFILER_PART_NAME}" 223} 224