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 (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 "//third_party/bounds_checking_function/include", 92 "//third_party/googletest/googletest/include", 93 ] 94 95 include_dirs += [ 96 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include", 97 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include", 98 "${OHOS_PROFILER_DIR}/device/services/profiler_service/src", 99 ] 100 101 sources += [ 102 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp", 103 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_death_recipient.cpp", 104 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_service.cpp", 105 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_stub.cpp", 106 "${OHOS_PROFILER_DIR}/device/services/profiler_service/src/trace_file_helper.cpp", 107 "${OHOS_PROFILER_DIR}/device/services/profiler_service/src/trace_file_writer.cpp", 108 ] 109 110 deps = [ 111 ":hiprofiler_daemon.cfg", 112 "${OHOS_PROFILER_DIR}/device/services/shared_memory:shared_memory_source", 113 "${OHOS_PROFILER_DIR}/proto_encoder:proto_encoder_source", 114 "${OHOS_PROFILER_DIR}/protos/services:plugin_service_proto", 115 "${OHOS_PROFILER_DIR}/protos/services:profiler_service_all_type_source", 116 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp", 117 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp_standard", 118 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_encoder", 119 "../../base:hiprofiler_base", 120 "//third_party/bounds_checking_function:libsec_static", 121 "//third_party/openssl:libcrypto_shared", 122 "//third_party/zlib:libz", 123 ] 124 125 if (hiprofiler_use_libunwind) { 126 deps += [ "//third_party/libunwind:unwind_source_${target_cpu}" ] 127 } 128 129 external_deps = [ 130 "ability_base:extractortool", 131 "access_token:libaccesstoken_sdk", 132 "access_token:libtoken_setproc", 133 "init:libbegetutil", 134 "ipc:ipc_core", 135 "safwk:system_ability_fwk", 136 "samgr:samgr_proxy", 137 ] 138 139 defines = [ "ENABLE_HAP_EXTRACTOR" ] 140 141 if (hiprofiler_use_libunwinder) { 142 external_deps += [ "faultloggerd:libunwinder_static" ] 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 "init:libbegetutil", 173 "ipc:ipc_core", 174 "safwk:system_ability_fwk", 175 "samgr:samgr_proxy", 176 ] 177 178 if (current_toolchain != host_toolchain) { 179 defines = [ "HAVE_HILOG" ] 180 external_deps += [ "hilog:libhilog" ] 181 } 182 183 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 184 part_name = "${OHOS_PROFILER_PART_NAME}" 185} 186 187ohos_shared_library("libnative_daemon_client") { 188 public_configs = [ ":profiler_sa_config" ] 189 include_dirs = [ 190 "../../base/include", 191 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include", 192 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include", 193 ] 194 195 sources = [ 196 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_client_manager.cpp", 197 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp", 198 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_proxy.cpp", 199 "../../base/src/common.cpp", 200 ] 201 202 external_deps = [ 203 "bundle_framework:appexecfwk_base", 204 "bundle_framework:appexecfwk_core", 205 "c_utils:utils", 206 "init:libbegetutil", 207 "ipc:ipc_core", 208 "os_account:os_account_innerkits", 209 "safwk:system_ability_fwk", 210 "samgr:samgr_proxy", 211 ] 212 213 if (current_toolchain != host_toolchain) { 214 defines = [ "HAVE_HILOG" ] 215 external_deps += [ "hilog:libhilog" ] 216 } 217 218 innerapi_tags = [ "platformsdk" ] 219 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 220 part_name = "${OHOS_PROFILER_PART_NAME}" 221} 222