1# Copyright (c) 2023-2025 Huawei Device Co., Ltd. 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. 13import("//base/hiviewdfx/hiview/hiview.gni") 14import("//build/ohos.gni") 15 16config("unified_collector_config") { 17 visibility = [ "*:*" ] 18 include_dirs = [ 19 "include", 20 "observer/include", 21 "storage/include", 22 "task/include", 23 "$hiview_framework/native/unified_collection/collector/config", 24 "$hiview_framework/native/unified_collection/collector/inner_include", 25 "$hiview_framework/native/unified_collection/process/include", 26 "$hiview_framework/native/unified_collection/decorator/include", 27 ] 28 29 if (power_manager_enable) { 30 include_dirs += [ "power/include" ] 31 } 32} 33 34ohos_source_set("unified_collector") { 35 branch_protector_ret = "pac_ret" 36 sanitize = { 37 cfi = true 38 cfi_cross_dso = true 39 cfi_vcall_icall_only = true 40 debug = false 41 } 42 configs = [ ":unified_collector_config" ] 43 44 sources = [ 45 "observer/uc_app_state_observer.cpp", 46 "observer/uc_observer_mgr.cpp", 47 "observer/uc_render_state_observer.cpp", 48 "observer/uc_system_ability_listener.cpp", 49 "storage/cpu_storage.cpp", 50 "task/cpu_collection_task.cpp", 51 "task/cpu_perf_dump.cpp", 52 "unified_collector.cpp", 53 ] 54 55 deps = [ 56 "$hiview_base:hiviewbase", 57 "$hiview_interfaces/inner_api/unified_collection/utility:libucollection_utility", 58 "config:UnifiedCollector_event", 59 ] 60 61 defines = [ "PC_APP_STATE_COLLECT_ENABLE = $hiview_unified_collector_PC_app_state_collect_enable" ] 62 63 if (hiview_unified_collector_trace_enable) { 64 sources += [ 65 "observer/uc_telemetry_listener.cpp", 66 "observer/uc_telemetry_callback.cpp" 67 ] 68 deps += [ "$hiview_framework/native/unified_collection/trace_manager:libtrace_manager" ] 69 defines += [ "UNIFIED_COLLECTOR_TRACE_ENABLE" ] 70 if (hiview_unified_collector_low_mem_threshold != 0) { 71 sources += [ "task/trace_cache_monitor.cpp" ] 72 defines += [ "HIVIEW_LOW_MEM_THRESHOLD=${hiview_unified_collector_low_mem_threshold}" ] 73 } 74 } 75 76 external_deps = [ 77 "ability_runtime:app_manager", 78 "cJSON:cjson", 79 "c_utils:utils", 80 "ffrt:libffrt", 81 "hilog:libhilog", 82 "hisysevent:libhisysevent", 83 "ipc:ipc_single", 84 "jsoncpp:jsoncpp", 85 "relational_store:native_rdb", 86 "safwk:system_ability_fwk", 87 "samgr:samgr_proxy", 88 ] 89 90 if (has_hiperf && hiview_unified_collector_perf_enable) { 91 cflags = [ "-DHAS_HIPERF" ] 92 } 93 94 if (power_manager_enable) { 95 external_deps += [ 96 "ability_base:want", 97 "common_event_service:cesfwk_innerkits", 98 "power_manager:powermgr_client", 99 ] 100 sources += [ "power/power_status_manager.cpp" ] 101 defines += [ "POWER_MANAGER_ENABLE" ] 102 } 103 104 if (hiview_unified_collector_trace_for_cpu_high_load) { 105 sources += [ "task/dump_trace_controller.cpp" ] 106 defines += [ "CATCH_TRACE_FOR_CPU_HIGH_LOAD" ] 107 } 108 109 part_name = "hiview" 110 subsystem_name = "hiviewdfx" 111} 112 113group("unittest") { 114 testonly = true 115 deps = [ 116 "test/unittest/common:CpuStorageTest", 117 "test/unittest/common:UCStateObserverTest", 118 ] 119} 120 121group("moduletest") { 122 testonly = true 123 deps = [] 124} 125