1# Copyright (c) 2022 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.
13
14import("//build/ohos.gni")
15import("//build/ohos_var.gni")
16
17import("../../memmgr.gni")
18
19## Install .rc or .cfg file to /system/etc/init/
20ohos_prebuilt_etc("memmgrservice_init") {
21  if (use_musl) {
22    source = "memmgrservice.cfg"
23  } else {
24    source = "memmgrservice.rc"
25  }
26  relative_install_dir = "init"
27  part_name = "${memmgr_part_name}"
28  subsystem_name = "${memmgr_subsystem_name}"
29}
30
31config("memory_memmgr_config") {
32  visibility = [ ":*" ]
33  visibility += [ "${memmgr_root_path}/test/*" ]
34  include_dirs = [
35    "include",
36    "${memmgr_root_path}/common/include",
37    "${memmgr_root_path}/common/include/config",
38    "${memmgr_root_path}/common/src/",
39    "${memmgr_root_path}/common/src/config",
40    "${memgr_innerkits_path}/include",
41    "include/event/",
42    "include/memory_level_manager/",
43    "include/nandlife_controller",
44    "include/reclaim_priority_manager/",
45    "include/kill_strategy_manager/",
46    "include/reclaim_strategy_manager/",
47  ]
48
49  defines = []
50  if (memmgr_report_has_bg_task_mgr) {
51    defines += [ "CONFIG_BGTASK_MGR" ]
52  }
53  if (memmgr_purgeable_memory) {
54    defines += [ "USE_PURGEABLE_MEMORY" ]
55    include_dirs += [ "include/purgeable_mem_manager/" ]
56  }
57  if (memmgr_hyperhold_memory) {
58    defines += [ "USE_HYPERHOLD_MEMORY" ]
59  }
60}
61
62ohos_shared_library("memmgrservice") {
63  install_enable = true
64  use_exceptions = true
65  sources = [
66    "${memmgr_common_path}/src/config/avail_buffer_config.cpp",
67    "${memmgr_common_path}/src/config/kill_config.cpp",
68    "${memmgr_common_path}/src/config/nand_life_config.cpp",
69    "${memmgr_common_path}/src/config/purgeablemem_config.cpp",
70    "${memmgr_common_path}/src/config/reclaim_config.cpp",
71    "${memmgr_common_path}/src/config/reclaim_priority_config.cpp",
72    "${memmgr_common_path}/src/config/switch_config.cpp",
73    "${memmgr_common_path}/src/config/system_memory_level_config.cpp",
74    "${memmgr_common_path}/src/kernel_interface.cpp",
75    "${memmgr_common_path}/src/memmgr_config_manager.cpp",
76    "${memmgr_common_path}/src/xml_helper.cpp",
77    "src/event/account_observer.cpp",
78    "src/event/app_state_observer.cpp",
79    "src/event/common_event_observer.cpp",
80    "src/event/extension_connection_observer.cpp",
81    "src/event/kswapd_observer.cpp",
82    "src/event/mem_mgr_event_center.cpp",
83    "src/event/memory_pressure_observer.cpp",
84    "src/event/window_visibility_observer.cpp",
85    "src/kill_strategy_manager/low_memory_killer.cpp",
86    "src/mem_mgr_service.cpp",
87    "src/mem_mgr_stub.cpp",
88    "src/memory_level_manager/memory_level_manager.cpp",
89    "src/nandlife_controller/nandlife_controller.cpp",
90    "src/reclaim_priority_manager/account_bundle_info.cpp",
91    "src/reclaim_priority_manager/account_priority_info.cpp",
92    "src/reclaim_priority_manager/bundle_priority_info.cpp",
93    "src/reclaim_priority_manager/default_multi_account_priority.cpp",
94    "src/reclaim_priority_manager/multi_account_manager.cpp",
95    "src/reclaim_priority_manager/oom_score_adj_utils.cpp",
96    "src/reclaim_priority_manager/process_priority_info.cpp",
97    "src/reclaim_priority_manager/reclaim_priority_manager.cpp",
98    "src/reclaim_strategy_manager/avail_buffer_manager.cpp",
99    "src/reclaim_strategy_manager/memcg.cpp",
100    "src/reclaim_strategy_manager/memcg_mgr.cpp",
101    "src/reclaim_strategy_manager/reclaim_strategy_manager.cpp",
102  ]
103
104  configs = [ ":memory_memmgr_config" ]
105
106  external_deps = [
107    "ability_base:want",
108    "ability_runtime:app_context",
109    "ability_runtime:app_manager",
110    "ability_runtime:connection_obs_manager",
111    "ability_runtime:wantagent_innerkits",
112    "access_token:libaccesstoken_sdk",
113    "bundle_framework:appexecfwk_base",
114    "bundle_framework:appexecfwk_core",
115    "c_utils:utils",
116    "common_event_service:cesfwk_core",
117    "common_event_service:cesfwk_innerkits",
118    "eventhandler:libeventhandler",
119    "hilog:libhilog",
120    "init:libbegetutil",
121    "ipc:ipc_core",
122    "json:nlohmann_json_static",
123    "libxml2:libxml2",
124    "memmgr:memmgrclient",
125    "os_account:os_account_innerkits",
126    "resource_management:global_resmgr",
127    "safwk:system_ability_fwk",
128    "samgr:samgr_proxy",
129  ]
130
131  if (memmgr_report_has_bg_task_mgr) {
132    sources += [ "src/event/bg_task_observer.cpp" ]
133    external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
134  }
135
136  if (memmgr_purgeable_memory) {
137    sources += [
138      "src/purgeable_mem_manager/app_state_subscriber_proxy.cpp",
139      "src/purgeable_mem_manager/app_state_subscriber_stub.cpp",
140      "src/purgeable_mem_manager/purgeable_mem_manager.cpp",
141      "src/purgeable_mem_manager/purgeable_mem_utils.cpp",
142    ]
143    external_deps += [ "access_token:libaccesstoken_sdk" ]
144  }
145
146  sanitize = {
147    cfi = true
148    cfi_cross_dso = true
149    debug = false
150  }
151  branch_protector_ret = "pac_ret"
152
153  part_name = "${memmgr_part_name}"
154  subsystem_name = "${memmgr_subsystem_name}"
155}
156