1# Copyright (c) 2022-2024 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
16if (enable_hiview_usage_event_report_build) {
17  config("usage_event_report_config") {
18    visibility = [ "*:*" ]
19    include_dirs = [
20      "cache/include",
21      "event/include",
22      "include",
23    ]
24
25    if (power_manager_enable) {
26      include_dirs += [ "idl/include" ]
27    }
28  }
29
30  ohos_source_set("usage_event_report") {
31    branch_protector_ret = "pac_ret"
32    sanitize = {
33      cfi = true
34      cfi_cross_dso = true
35      cfi_vcall_icall_only = true
36      debug = false
37    }
38    configs = [ ":usage_event_report_config" ]
39
40    sources = [
41      "cache/event_db_helper.cpp",
42      "cache/fold_app_usage_db_helper.cpp",
43      "cache/fold_app_usage_event_factory.cpp",
44      "cache/fold_event_cacher.cpp",
45      "cache/json_parser.cpp",
46      "cache/usage_event_cacher.cpp",
47      "event/fold_app_usage_event.cpp",
48      "event/sys_usage_event.cpp",
49      "usage_event_report.cpp",
50    ]
51
52    if (power_manager_enable) {
53      sources += [ "idl/hiview_shutdown_callback.cpp" ]
54    }
55
56    deps = [
57      "$hiview_base:hiviewbase",
58      "config:usageEventPipeline",
59    ]
60
61    external_deps = [
62      "ability_runtime:ability_manager",
63      "ability_runtime:app_manager",
64      "bounds_checking_function:libsec_shared",
65      "bundle_framework:appexecfwk_base",
66      "bundle_framework:appexecfwk_core",
67      "ffrt:libffrt",
68      "hilog:libhilog",
69      "hisysevent:libhisysevent",
70      "ipc:ipc_single",
71      "jsoncpp:jsoncpp",
72      "relational_store:native_rdb",
73      "samgr:samgr_proxy",
74      "window_manager:libdm",
75    ]
76
77    defines = []
78    if (power_manager_enable) {
79      external_deps += [ "power_manager:powermgr_client" ]
80      defines += [ "POWER_MANAGER_ENABLE" ]
81    }
82
83    part_name = "hiview"
84    subsystem_name = "hiviewdfx"
85  }
86
87  ohos_source_set("usage_event_report_for_test") {
88    configs = [ ":usage_event_report_config" ]
89
90    sources = [
91      "cache/event_db_helper.cpp",
92      "cache/fold_app_usage_db_helper.cpp",
93      "cache/fold_app_usage_event_factory.cpp",
94      "cache/fold_event_cacher.cpp",
95      "cache/json_parser.cpp",
96      "cache/usage_event_cacher.cpp",
97      "event/fold_app_usage_event.cpp",
98      "event/sys_usage_event.cpp",
99      "usage_event_report.cpp",
100    ]
101
102    if (power_manager_enable) {
103      sources += [ "idl/hiview_shutdown_callback.cpp" ]
104    }
105
106    deps = [
107      "$hiview_base:hiviewbase",
108      "config:usageEventPipeline",
109    ]
110
111    external_deps = [
112      "ability_runtime:ability_manager",
113      "ability_runtime:app_manager",
114      "bounds_checking_function:libsec_shared",
115      "bundle_framework:appexecfwk_base",
116      "bundle_framework:appexecfwk_core",
117      "ffrt:libffrt",
118      "hilog:libhilog",
119      "hisysevent:libhisysevent",
120      "ipc:ipc_single",
121      "jsoncpp:jsoncpp",
122      "relational_store:native_rdb",
123      "samgr:samgr_proxy",
124      "window_manager:libdm",
125    ]
126
127    defines = []
128    if (power_manager_enable) {
129      external_deps += [ "power_manager:powermgr_client" ]
130      defines += [ "POWER_MANAGER_ENABLE" ]
131    }
132
133    part_name = "hiview"
134    subsystem_name = "hiviewdfx"
135  }
136} else {
137  ohos_source_set("usage_event_report") {
138  }
139
140  ohos_source_set("usage_event_report_for_test") {
141  }
142}
143
144group("unittest") {
145  testonly = true
146  deps = []
147
148  if (enable_hiview_usage_event_report_build) {
149    deps += [
150      "test/unittest:FoldAppUsageTest",
151      "test/unittest:UsageEventReportCacheTest",
152      "test/unittest:UsageEventReportTest",
153    ]
154  }
155}
156
157group("moduletest") {
158  testonly = true
159  deps = []
160}
161