• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 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("//foundation/filemanagement/storage_service/storage_service_aafwk.gni")
16
17## Install storage_daemon.cfg to /system/etc/init/storage_daemon.cfg {{{
18ohos_prebuilt_etc("storage_daemon_cfg") {
19  source = "storage_daemon.cfg"
20  relative_install_dir = "init"
21  part_name = "storage_service"
22  subsystem_name = "filemanagement"
23}
24
25## Install storage_daemon.cfg to /system/etc/init/storage_daemon.cfg }}}
26
27config("storage_daemon_config") {
28  include_dirs = [
29    "include",
30    "//third_party/bounds_checking_function/include",
31    "../storage_manager/include",
32    "${storage_interface_path}/innerkits/storage_manager/native",
33    "../common/include",
34  ]
35}
36
37## Install disk_config to /system/etc/storage_daemon/disk_config {{{
38ohos_prebuilt_etc("storage_daemon_disk_config") {
39  source = "disk_config"
40  relative_install_dir = "storage_daemon"
41  part_name = "storage_service"
42  subsystem_name = "filemanagement"
43}
44
45declare_args() {
46  storage_service_user_file_sharing = true
47}
48
49ohos_executable("storage_daemon") {
50  sources = [
51    "ipc/src/storage_daemon.cpp",
52    "ipc/src/storage_daemon_stub.cpp",
53    "ipc/src/storage_manager_client.cpp",
54    "main.cpp",
55    "quota/quota_manager.cpp",
56    "user/src/mount_manager.cpp",
57    "user/src/user_manager.cpp",
58    "utils/disk_utils.cpp",
59    "utils/mount_argument_utils.cpp",
60  ]
61
62  defines = [
63    "STORAGE_LOG_TAG = \"StorageDaemon\"",
64    "LOG_DOMAIN = 0xD004301",
65  ]
66
67  if (storage_service_user_file_sharing) {
68    defines += [ "USER_FILE_SHARING" ]
69    sources += [
70      "file_sharing/src/acl.cpp",
71      "file_sharing/src/file_sharing.cpp",
72      "file_sharing/src/setacl.cpp",
73    ]
74  }
75
76  if (storage_service_external_storage_manager) {
77    defines += [ "EXTERNAL_STORAGE_MANAGER" ]
78    sources += [
79      "disk/src/disk_config.cpp",
80      "disk/src/disk_info.cpp",
81      "disk/src/disk_manager.cpp",
82      "netlink/src/netlink_data.cpp",
83      "netlink/src/netlink_handler.cpp",
84      "netlink/src/netlink_listener.cpp",
85      "netlink/src/netlink_manager.cpp",
86      "volume/src/external_volume_info.cpp",
87      "volume/src/process.cpp",
88      "volume/src/volume_info.cpp",
89      "volume/src/volume_manager.cpp",
90    ]
91  }
92
93  configs = [ ":storage_daemon_config" ]
94
95  deps = [
96    ":sdc",
97    ":storage_common_utils",
98    "${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy",
99  ]
100
101  external_deps = [
102    "ability_base:base",
103    "ability_base:want",
104    "ability_base:zuri",
105    "c_utils:utils",
106    "dfs_service:cloud_daemon_kit_inner",
107    "hilog:libhilog",
108    "init:libbegetutil",
109    "ipc:ipc_core",
110    "safwk:system_ability_fwk",
111    "samgr:samgr_proxy",
112  ]
113
114  if (storage_service_user_crypto_manager) {
115    defines += [ "USER_CRYPTO_MANAGER" ]
116    deps += [
117      "crypto:libsdcrypto",
118      "libfscrypt:libfscryptutils",
119    ]
120    external_deps += [ "huks:libhukssdk" ]
121  }
122
123  ldflags = [
124    "-Wl,-z,max-page-size=4096",
125    "-Wl,-z,separate-code",
126  ]
127
128  subsystem_name = "filemanagement"
129  part_name = "storage_service"
130  install_enable = true
131}
132
133config("sdc_config") {
134  include_dirs = [
135    "include",
136    "../common/include",
137    "client/include",
138    "../../interfaces/innerkits/storage_manager/native",
139    "../storage_manager/include",
140    "${bundlemanager_framework_path}/services/bundlemgr/include",
141  ]
142}
143
144ohos_executable("sdc") {
145  sources = [
146    "client/storage_daemon_client.cpp",
147    "ipc/src/storage_daemon_proxy.cpp",
148    "sdc.cpp",
149  ]
150
151  defines = [
152    "STORAGE_LOG_TAG = \"StorageDaemon\"",
153    "LOG_DOMAIN = 0xD004301",
154  ]
155
156  configs = [ ":sdc_config" ]
157
158  deps = [
159    ":storage_common_utils",
160    "${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy",
161  ]
162
163  if (storage_service_user_crypto_manager) {
164    defines += [ "USER_CRYPTO_MANAGER" ]
165    deps += [ "libfscrypt:libfscryptutils" ]
166  }
167
168  external_deps = [
169    "c_utils:utils",
170    "hilog:libhilog",
171    "ipc:ipc_core",
172    "safwk:system_ability_fwk",
173    "samgr:samgr_proxy",
174  ]
175
176  subsystem_name = "filemanagement"
177  part_name = "storage_service"
178  install_enable = true
179}
180
181declare_args() {
182  storage_service_fstools = true
183}
184
185ohos_shared_library("storage_common_utils") {
186  include_dirs = [
187    "./include",
188    "../common/include",
189  ]
190
191  defines = [
192    "STORAGE_LOG_TAG = \"StorageCommonUtils\"",
193    "LOG_DOMAIN = 0xD004301",
194  ]
195
196  sources = [
197    "./utils/disk_utils.cpp",
198    "./utils/file_utils.cpp",
199    "./utils/mount_argument_utils.cpp",
200    "./utils/string_utils.cpp",
201  ]
202
203  external_deps = [
204    "c_utils:utils",
205    "hilog:libhilog",
206  ]
207
208  if (build_selinux) {
209    defines += [ "USE_LIBRESTORECON" ]
210
211    external_deps += [ "selinux_adapter:librestorecon" ]
212  }
213
214  subsystem_name = "filemanagement"
215  part_name = "storage_service"
216  install_enable = true
217}
218
219ohos_prebuilt_etc("usb_config.para") {
220  source = "usb_config.para"
221  part_name = "storage_service"
222  subsystem_name = "filemanagement"
223  module_install_dir = "etc/param"
224}
225
226ohos_prebuilt_etc("usb_config.para.dac") {
227  source = "usb_config.para.dac"
228  part_name = "storage_service"
229  subsystem_name = "filemanagement"
230  module_install_dir = "etc/param"
231}
232
233group("storage_daemon_usb_param") {
234  deps = [
235    ":usb_config.para",
236    ":usb_config.para.dac",
237  ]
238}
239
240group("storage_daemon_third_party") {
241  deps = []
242  if (storage_service_external_storage_manager && storage_service_fstools) {
243    deps += [
244      "//third_party/FreeBSD/sbin/fsck_msdosfs:fsck_msdos",
245      "//third_party/FreeBSD/sbin/newfs_msdos:newfs_msdos",
246      "//third_party/e2fsprogs:blkid",
247      "//third_party/exfatprogs:exfatprogs",
248      "//third_party/f2fs-tools:f2fs-tools",
249      "//third_party/gptfdisk:sgdisk",
250      "//third_party/ntfs-3g:ntfsprogs",
251    ]
252  }
253}
254
255group("storage_daemon_unit_test") {
256  testonly = true
257  deps = [
258    "client/test:storage_daemon_client_test",
259    "file_sharing/test:file_sharing_test",
260    "ipc/test:storage_daemon_ipc_test",
261    "quota/test:storage_daemon_quota_test",
262    "user/test:storage_daemon_user_test",
263    "utils/test:storage_daemon_utils_test",
264  ]
265
266  if (storage_service_user_crypto_manager) {
267    deps += [ "crypto/test:crypto_test" ]
268  }
269
270  if (storage_service_external_storage_manager) {
271    deps += [
272      "disk/test:storage_daemon_disk_test",
273      "netlink/test:storage_daemon_netlink_test",
274      "volume/test:storage_daemon_volume_test",
275    ]
276  }
277}
278