106f6ba60Sopenharmony_ci# Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. 206f6ba60Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 306f6ba60Sopenharmony_ci# you may not use this file except in compliance with the License. 406f6ba60Sopenharmony_ci# You may obtain a copy of the License at 506f6ba60Sopenharmony_ci# 606f6ba60Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 706f6ba60Sopenharmony_ci# 806f6ba60Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 906f6ba60Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 1006f6ba60Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1106f6ba60Sopenharmony_ci# See the License for the specific language governing permissions and 1206f6ba60Sopenharmony_ci# limitations under the License. 1306f6ba60Sopenharmony_ci 1406f6ba60Sopenharmony_ciimport("//build/ohos.gni") 1506f6ba60Sopenharmony_ciimport("../../base/config.gni") 1606f6ba60Sopenharmony_ci 1706f6ba60Sopenharmony_ciconfig("cflags_config") { 1806f6ba60Sopenharmony_ci cflags = [ "-O3" ] 1906f6ba60Sopenharmony_ci} 2006f6ba60Sopenharmony_ci 2106f6ba60Sopenharmony_ciconfig("hook_config") { 2206f6ba60Sopenharmony_ci defines = [ 2306f6ba60Sopenharmony_ci "HAVE_LIBUNWIND=0", 2406f6ba60Sopenharmony_ci "HAVE_LIBUNWINDER=1", 2506f6ba60Sopenharmony_ci "HIPERF_DEBUG", 2606f6ba60Sopenharmony_ci "CONFIG_NO_HILOG", 2706f6ba60Sopenharmony_ci "NATIVEDAEMON_USE_CALLSTACK", 2806f6ba60Sopenharmony_ci ] 2906f6ba60Sopenharmony_ci defines += [ "target_cpu_${target_cpu}" ] 3006f6ba60Sopenharmony_ci if (musl_use_jemalloc) { 3106f6ba60Sopenharmony_ci defines += [ "USE_JEMALLOC" ] 3206f6ba60Sopenharmony_ci } 3306f6ba60Sopenharmony_ci} 3406f6ba60Sopenharmony_ci 3506f6ba60Sopenharmony_ciconfig("profiler_sa_config") { 3606f6ba60Sopenharmony_ci visibility = [ ":*" ] 3706f6ba60Sopenharmony_ci include_dirs = [ 3806f6ba60Sopenharmony_ci "native_memory_profiler_sa/include", 3906f6ba60Sopenharmony_ci "native_memory_profiler_sa/util/include", 4006f6ba60Sopenharmony_ci "../../base/include", 4106f6ba60Sopenharmony_ci ] 4206f6ba60Sopenharmony_ci} 4306f6ba60Sopenharmony_ci 4406f6ba60Sopenharmony_ciohos_prebuilt_etc("hiprofiler_daemon.cfg") { 4506f6ba60Sopenharmony_ci source = "../../etc/hiprofiler_daemon.cfg" 4606f6ba60Sopenharmony_ci relative_install_dir = "init" 4706f6ba60Sopenharmony_ci part_name = "${OHOS_PROFILER_PART_NAME}" 4806f6ba60Sopenharmony_ci subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 4906f6ba60Sopenharmony_ci} 5006f6ba60Sopenharmony_ci 5106f6ba60Sopenharmony_ciohos_executable("native_daemon") { 5206f6ba60Sopenharmony_ci output_name = "native_daemon" 5306f6ba60Sopenharmony_ci configs = [ ":cflags_config" ] 5406f6ba60Sopenharmony_ci public_configs = [ 5506f6ba60Sopenharmony_ci ":hook_config", 5606f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/base:hiprofiler_test_config", 5706f6ba60Sopenharmony_ci ] 5806f6ba60Sopenharmony_ci sources = [ 5906f6ba60Sopenharmony_ci "../api/src/buffer_writer.cpp", 6006f6ba60Sopenharmony_ci "../api/src/command_poller.cpp", 6106f6ba60Sopenharmony_ci "../api/src/writer_adapter.cpp", 6206f6ba60Sopenharmony_ci "src/debug_logger.cpp", 6306f6ba60Sopenharmony_ci "src/dwarf_encoding.cpp", 6406f6ba60Sopenharmony_ci "src/get_thread_id.cpp", 6506f6ba60Sopenharmony_ci "src/hook_manager.cpp", 6606f6ba60Sopenharmony_ci "src/hook_service.cpp", 6706f6ba60Sopenharmony_ci "src/hook_standalone.cpp", 6806f6ba60Sopenharmony_ci "src/main.cpp", 6906f6ba60Sopenharmony_ci "src/register.cpp", 7006f6ba60Sopenharmony_ci "src/stack_data_repeater.cpp", 7106f6ba60Sopenharmony_ci "src/stack_preprocess.cpp", 7206f6ba60Sopenharmony_ci "src/symbols_file.cpp", 7306f6ba60Sopenharmony_ci "src/utilities.cpp", 7406f6ba60Sopenharmony_ci "src/virtual_runtime.cpp", 7506f6ba60Sopenharmony_ci "src/virtual_thread.cpp", 7606f6ba60Sopenharmony_ci ] 7706f6ba60Sopenharmony_ci 7806f6ba60Sopenharmony_ci if (is_ohos) { 7906f6ba60Sopenharmony_ci sources += [ "./src/call_stack.cpp" ] 8006f6ba60Sopenharmony_ci } 8106f6ba60Sopenharmony_ci 8206f6ba60Sopenharmony_ci include_dirs = [ 8306f6ba60Sopenharmony_ci "./include", 8406f6ba60Sopenharmony_ci "./src", 8506f6ba60Sopenharmony_ci "../../base/include", 8606f6ba60Sopenharmony_ci "../api/include", 8706f6ba60Sopenharmony_ci "../api/src", 8806f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/interfaces/kits", 8906f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/services/ipc/include", 9006f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/services/shared_memory/include", 9106f6ba60Sopenharmony_ci ] 9206f6ba60Sopenharmony_ci 9306f6ba60Sopenharmony_ci include_dirs += [ 9406f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include", 9506f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include", 9606f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/services/profiler_service/src", 9706f6ba60Sopenharmony_ci ] 9806f6ba60Sopenharmony_ci 9906f6ba60Sopenharmony_ci sources += [ 10006f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp", 10106f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_death_recipient.cpp", 10206f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_service.cpp", 10306f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_stub.cpp", 10406f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/services/profiler_service/src/trace_file_helper.cpp", 10506f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/services/profiler_service/src/trace_file_writer.cpp", 10606f6ba60Sopenharmony_ci ] 10706f6ba60Sopenharmony_ci 10806f6ba60Sopenharmony_ci deps = [ 10906f6ba60Sopenharmony_ci ":hiprofiler_daemon.cfg", 11006f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/services/shared_memory:shared_memory_source", 11106f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/proto_encoder:proto_encoder_source", 11206f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/protos/services:plugin_service_proto", 11306f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/protos/services:profiler_service_all_type_source", 11406f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp", 11506f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp_standard", 11606f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_encoder", 11706f6ba60Sopenharmony_ci "../../base:hiprofiler_base", 11806f6ba60Sopenharmony_ci ] 11906f6ba60Sopenharmony_ci 12006f6ba60Sopenharmony_ci if (hiprofiler_use_libunwind) { 12106f6ba60Sopenharmony_ci deps += [ "//third_party/libunwind:unwind_source_${target_cpu}" ] 12206f6ba60Sopenharmony_ci } 12306f6ba60Sopenharmony_ci 12406f6ba60Sopenharmony_ci external_deps = [ 12506f6ba60Sopenharmony_ci "ability_base:extractortool", 12606f6ba60Sopenharmony_ci "access_token:libaccesstoken_sdk", 12706f6ba60Sopenharmony_ci "access_token:libtokensetproc_shared", 12806f6ba60Sopenharmony_ci "bounds_checking_function:libsec_shared", 12906f6ba60Sopenharmony_ci "init:libbegetutil", 13006f6ba60Sopenharmony_ci "ipc:ipc_core", 13106f6ba60Sopenharmony_ci "openssl:libcrypto_shared", 13206f6ba60Sopenharmony_ci "protobuf:protobuf_lite", 13306f6ba60Sopenharmony_ci "safwk:system_ability_fwk", 13406f6ba60Sopenharmony_ci "samgr:samgr_proxy", 13506f6ba60Sopenharmony_ci "zlib:libz", 13606f6ba60Sopenharmony_ci ] 13706f6ba60Sopenharmony_ci 13806f6ba60Sopenharmony_ci defines = [ "ENABLE_HAP_EXTRACTOR" ] 13906f6ba60Sopenharmony_ci 14006f6ba60Sopenharmony_ci if (hiprofiler_use_libunwinder) { 14106f6ba60Sopenharmony_ci external_deps += [ "faultloggerd:libunwinder" ] 14206f6ba60Sopenharmony_ci } 14306f6ba60Sopenharmony_ci 14406f6ba60Sopenharmony_ci if (current_toolchain != host_toolchain) { 14506f6ba60Sopenharmony_ci defines += [ "HAVE_HILOG" ] 14606f6ba60Sopenharmony_ci external_deps += [ "hilog:libhilog_base" ] 14706f6ba60Sopenharmony_ci } 14806f6ba60Sopenharmony_ci use_exceptions = true 14906f6ba60Sopenharmony_ci install_enable = true 15006f6ba60Sopenharmony_ci subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 15106f6ba60Sopenharmony_ci part_name = "${OHOS_PROFILER_PART_NAME}" 15206f6ba60Sopenharmony_ci} 15306f6ba60Sopenharmony_ci 15406f6ba60Sopenharmony_ciohos_executable("native_daemon_client") { 15506f6ba60Sopenharmony_ci output_name = "native_daemon_client" 15606f6ba60Sopenharmony_ci include_dirs = [ 15706f6ba60Sopenharmony_ci "../../base/include", 15806f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include", 15906f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include", 16006f6ba60Sopenharmony_ci ] 16106f6ba60Sopenharmony_ci 16206f6ba60Sopenharmony_ci sources = [ 16306f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_client_manager.cpp", 16406f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp", 16506f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_proxy.cpp", 16606f6ba60Sopenharmony_ci "native_daemon_client.cpp", 16706f6ba60Sopenharmony_ci ] 16806f6ba60Sopenharmony_ci 16906f6ba60Sopenharmony_ci external_deps = [ 17006f6ba60Sopenharmony_ci "c_utils:utils", 17106f6ba60Sopenharmony_ci "init:libbegetutil", 17206f6ba60Sopenharmony_ci "ipc:ipc_core", 17306f6ba60Sopenharmony_ci "safwk:system_ability_fwk", 17406f6ba60Sopenharmony_ci "samgr:samgr_proxy", 17506f6ba60Sopenharmony_ci ] 17606f6ba60Sopenharmony_ci 17706f6ba60Sopenharmony_ci if (current_toolchain != host_toolchain) { 17806f6ba60Sopenharmony_ci defines = [ "HAVE_HILOG" ] 17906f6ba60Sopenharmony_ci external_deps += [ "hilog:libhilog_base" ] 18006f6ba60Sopenharmony_ci } 18106f6ba60Sopenharmony_ci install_enable = false 18206f6ba60Sopenharmony_ci subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 18306f6ba60Sopenharmony_ci part_name = "${OHOS_PROFILER_PART_NAME}" 18406f6ba60Sopenharmony_ci} 18506f6ba60Sopenharmony_ci 18606f6ba60Sopenharmony_ciohos_shared_library("libnative_daemon_client") { 18706f6ba60Sopenharmony_ci public_configs = [ ":profiler_sa_config" ] 18806f6ba60Sopenharmony_ci include_dirs = [ 18906f6ba60Sopenharmony_ci "../../base/include", 19006f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include", 19106f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include", 19206f6ba60Sopenharmony_ci ] 19306f6ba60Sopenharmony_ci 19406f6ba60Sopenharmony_ci sources = [ 19506f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_client_manager.cpp", 19606f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp", 19706f6ba60Sopenharmony_ci "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_proxy.cpp", 19806f6ba60Sopenharmony_ci "../../base/src/common.cpp", 19906f6ba60Sopenharmony_ci ] 20006f6ba60Sopenharmony_ci 20106f6ba60Sopenharmony_ci external_deps = [ 20206f6ba60Sopenharmony_ci "bundle_framework:appexecfwk_base", 20306f6ba60Sopenharmony_ci "bundle_framework:appexecfwk_core", 20406f6ba60Sopenharmony_ci "c_utils:utils", 20506f6ba60Sopenharmony_ci "init:libbegetutil", 20606f6ba60Sopenharmony_ci "ipc:ipc_core", 20706f6ba60Sopenharmony_ci "os_account:os_account_innerkits", 20806f6ba60Sopenharmony_ci "safwk:system_ability_fwk", 20906f6ba60Sopenharmony_ci "samgr:samgr_proxy", 21006f6ba60Sopenharmony_ci ] 21106f6ba60Sopenharmony_ci 21206f6ba60Sopenharmony_ci if (current_toolchain != host_toolchain) { 21306f6ba60Sopenharmony_ci defines = [ "HAVE_HILOG" ] 21406f6ba60Sopenharmony_ci external_deps += [ "hilog:libhilog_base" ] 21506f6ba60Sopenharmony_ci } 21606f6ba60Sopenharmony_ci 21706f6ba60Sopenharmony_ci innerapi_tags = [ "platformsdk" ] 21806f6ba60Sopenharmony_ci subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 21906f6ba60Sopenharmony_ci part_name = "${OHOS_PROFILER_PART_NAME}" 22006f6ba60Sopenharmony_ci} 221