1# Copyright (c) 2021-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/sa_profile/sa_profile.gni")
16import("//foundation/filemanagement/storage_service/storage_service_aafwk.gni")
17
18config("storage_manager_config") {
19  include_dirs = [
20    "include",
21    "../../interfaces/innerkits/storage_manager/native",
22    "../storage_daemon/include",
23    "../common/include",
24  ]
25
26  cflags = [
27    "-D_FORTIFY_SOURCE=2",
28    "-fstack-protector-strong",
29  ]
30}
31
32ohos_shared_library("storage_manager") {
33  branch_protector_ret = "pac_ret"
34  sanitize = {
35    integer_overflow = true
36    ubsan = true
37    boundary_sanitize = true
38    cfi = true
39    cfi_cross_dso = true
40    debug = false
41  }
42
43  sources = [
44    "ipc/src/storage_manager.cpp",
45    "ipc/src/storage_manager_stub.cpp",
46    "storage_daemon_communication/src/storage_daemon_communication.cpp",
47    "user/src/multi_user_manager_service.cpp",
48    "utils/src/storage_utils.cpp",
49  ]
50
51  defines = [
52    "STORAGE_LOG_TAG = \"StorageManager\"",
53    "LOG_DOMAIN = 0xD004300",
54  ]
55
56  if (storage_service_user_crypto_manager) {
57    defines += [ "USER_CRYPTO_MANAGER" ]
58    sources += [ "crypto/filesystem_crypto.cpp" ]
59  }
60
61  if (storage_service_external_storage_manager) {
62    defines += [ "EXTERNAL_STORAGE_MANAGER" ]
63    sources += [
64      "disk/src/disk_manager_service.cpp",
65      "volume/src/notification.cpp",
66      "volume/src/volume_manager_service.cpp",
67    ]
68  }
69
70  configs = [ ":storage_manager_config" ]
71
72  deps = [
73    "${storage_daemon_path}:storage_common_utils",
74    "${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy",
75  ]
76
77  external_deps = [
78    "ability_base:base",
79    "ability_base:want",
80    "ability_runtime:extensionkit_native",
81    "access_token:libaccesstoken_sdk",
82    "cJSON:cjson",
83    "c_utils:utils",
84    "common_event_service:cesfwk_innerkits",
85    "hilog:libhilog",
86    "hitrace:hitrace_meter",
87    "ipc:ipc_single",
88    "os_account:os_account_innerkits",
89    "safwk:system_ability_fwk",
90    "samgr:samgr_proxy",
91  ]
92
93  if (storage_service_storage_statistics_manager) {
94    defines += [ "STORAGE_STATISTICS_MANAGER" ]
95    sources += [
96      "account_subscriber/account_subscriber.cpp",
97      "storage/src/bundle_manager_connector.cpp",
98      "storage/src/storage_monitor_service.cpp",
99      "storage/src/storage_status_service.cpp",
100      "storage/src/storage_total_status_service.cpp",
101      "storage/src/volume_storage_status_service.cpp",
102    ]
103    external_deps += [
104      "ability_runtime:abilitykit_native",
105      "ability_runtime:dataobs_manager",
106      "bundle_framework:appexecfwk_base",
107      "bundle_framework:appexecfwk_core",
108      "data_share:datashare_consumer",
109      "eventhandler:libeventhandler",
110      "init:libbegetutil",
111      "relational_store:native_rdb",
112    ]
113    deps += [ ":storage_manager_monitor_config" ]
114    if (storage_service_graphic) {
115      defines += [ "STORAGE_SERVICE_GRAPHIC" ]
116      external_deps += [ "data_share:datashare_common" ]
117    }
118  }
119
120  if (enable_screenlock_manager) {
121    defines += [ "ENABLE_SCREENLOCK_MANAGER" ]
122    external_deps += [ "screenlock_mgr:screenlock_client" ]
123  }
124
125  subsystem_name = "filemanagement"
126  part_name = "storage_service"
127  install_enable = true
128}
129
130ohos_prebuilt_etc("storage_manager_config.para") {
131  source = "storage_manager_config.para"
132  part_name = "storage_service"
133  subsystem_name = "filemanagement"
134  module_install_dir = "etc/param"
135}
136
137ohos_prebuilt_etc("storage_manager_config.para.dac") {
138  source = "storage_manager_config.para.dac"
139  part_name = "storage_service"
140  subsystem_name = "filemanagement"
141  module_install_dir = "etc/param"
142}
143
144group("storage_manager_monitor_config") {
145  deps = [
146    ":storage_manager_config.para",
147    ":storage_manager_config.para.dac",
148  ]
149}
150
151group("storage_manager_unit_test") {
152  testonly = true
153  deps = [
154    "client/test:storage_manager_client_test",
155    "innerkits_impl/test:storage_manager_innerkits_test",
156    "ipc/test:storage_manager_ipc_test",
157    "storage_daemon_communication/test:storage_manager_communication_test",
158    "user/test:storage_manager_user_test",
159  ]
160
161  if (storage_service_user_crypto_manager) {
162    deps += [ "crypto/test:storage_manager_crypto_test" ]
163  }
164
165  if (storage_service_storage_statistics_manager) {
166    deps += [ "storage/test:storage_manager_storage_test" ]
167  }
168
169  if (storage_service_external_storage_manager) {
170    deps += [
171      "disk/test:storage_manager_disk_test",
172      "volume/test:storage_manager_volume_test",
173    ]
174  }
175}
176