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 "include/utils", 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 branch_protector_ret = "pac_ret" 51 sanitize = { 52 integer_overflow = true 53 ubsan = true 54 boundary_sanitize = true 55 cfi = true 56 cfi_cross_dso = true 57 debug = false 58 } 59 60 sources = [ 61 "ipc/src/storage_daemon.cpp", 62 "ipc/src/storage_daemon_stub.cpp", 63 "ipc/src/storage_manager_client.cpp", 64 "main.cpp", 65 "quota/quota_manager.cpp", 66 "user/src/mount_manager.cpp", 67 "user/src/user_manager.cpp", 68 "utils/disk_utils.cpp", 69 "utils/mount_argument_utils.cpp", 70 ] 71 72 defines = [ 73 "STORAGE_LOG_TAG = \"StorageDaemon\"", 74 "LOG_DOMAIN = 0xD004301", 75 "KMSG_LOG", 76 ] 77 78 if (storage_service_user_file_sharing) { 79 defines += [ "USER_FILE_SHARING" ] 80 sources += [ 81 "file_sharing/src/acl.cpp", 82 "file_sharing/src/file_sharing.cpp", 83 "file_sharing/src/setacl.cpp", 84 ] 85 } 86 87 if (storage_service_external_storage_manager) { 88 defines += [ "EXTERNAL_STORAGE_MANAGER" ] 89 sources += [ 90 "disk/src/disk_config.cpp", 91 "disk/src/disk_info.cpp", 92 "disk/src/disk_manager.cpp", 93 "netlink/src/netlink_data.cpp", 94 "netlink/src/netlink_handler.cpp", 95 "netlink/src/netlink_listener.cpp", 96 "netlink/src/netlink_manager.cpp", 97 "volume/src/external_volume_info.cpp", 98 "volume/src/process.cpp", 99 "volume/src/volume_info.cpp", 100 "volume/src/volume_manager.cpp", 101 ] 102 } 103 104 configs = [ ":storage_daemon_config" ] 105 106 deps = [ 107 ":sdc", 108 ":storage_common_utils", 109 "${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy", 110 ] 111 112 external_deps = [ 113 "ability_base:base", 114 "ability_base:want", 115 "ability_base:zuri", 116 "app_file_service:fileshare_native", 117 "app_file_service:fileuri_native", 118 "app_file_service:sandbox_helper_native", 119 "bounds_checking_function:libsec_shared", 120 "bundle_framework:appexecfwk_base", 121 "bundle_framework:appexecfwk_core", 122 "c_utils:utils", 123 "eventhandler:libeventhandler", 124 "hilog:libhilog", 125 "hisysevent:libhisysevent", 126 "init:libbegetutil", 127 "ipc:ipc_single", 128 "os_account:os_account_innerkits", 129 "safwk:system_ability_fwk", 130 "samgr:samgr_proxy", 131 ] 132 133 if (storage_service_user_crypto_manager) { 134 defines += [ 135 "USER_CRYPTO_MANAGER", 136 "USER_CRYPTO_MIGRATE_KEY", 137 ] 138 deps += [ 139 "crypto:libsdcrypto", 140 "libfscrypt:libfscryptutils", 141 ] 142 external_deps += [ "huks:libhukssdk" ] 143 } 144 145 if (enable_user_auth_framework) { 146 defines += [ "USER_AUTH_FRAMEWORK" ] 147 external_deps += [ "user_auth_framework:userauth_client" ] 148 } 149 150 if (storage_service_dfs_service) { 151 defines += [ "DFS_SERVICE" ] 152 external_deps += [ "dfs_service:cloud_daemon_kit_inner" ] 153 } 154 if (build_selinux) { 155 defines += [ "USE_LIBRESTORECON" ] 156 external_deps += [ "selinux_adapter:librestorecon" ] 157 } 158 159 if (enable_screenlock_manager) { 160 defines += [ "ENABLE_SCREENLOCK_MANAGER" ] 161 external_deps += [ "screenlock_mgr:screenlock_client" ] 162 } 163 164 if (support_open_source_libmtp) { 165 defines += [ "SUPPORT_OPEN_SOURCE_MTP_DEVICE" ] 166 sources += [ 167 "mtp/src/mtp_device_manager.cpp", 168 "mtp/src/mtp_device_monitor.cpp", 169 ] 170 external_deps += [ "libmtp:libmtp" ] 171 } 172 173 ldflags = [ 174 "-Wl,-z,max-page-size=4096", 175 "-Wl,-z,separate-code", 176 ] 177 178 subsystem_name = "filemanagement" 179 part_name = "storage_service" 180 install_enable = true 181} 182 183config("sdc_config") { 184 include_dirs = [ 185 "include", 186 "../common/include", 187 "client/include", 188 "../../interfaces/innerkits/storage_manager/native", 189 "../storage_manager/include", 190 ] 191} 192 193ohos_executable("sdc") { 194 branch_protector_ret = "pac_ret" 195 sanitize = { 196 integer_overflow = true 197 ubsan = true 198 boundary_sanitize = true 199 cfi = true 200 cfi_cross_dso = true 201 debug = false 202 } 203 204 sources = [ 205 "client/storage_daemon_client.cpp", 206 "ipc/src/storage_daemon_proxy.cpp", 207 "sdc.cpp", 208 ] 209 210 defines = [ 211 "STORAGE_LOG_TAG = \"StorageDaemon\"", 212 "LOG_DOMAIN = 0xD004301", 213 "KMSG_LOG", 214 ] 215 216 configs = [ ":sdc_config" ] 217 218 deps = [ 219 ":storage_common_utils", 220 "${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy", 221 ] 222 223 if (storage_service_user_crypto_manager) { 224 defines += [ "USER_CRYPTO_MANAGER" ] 225 deps += [ "libfscrypt:libfscryptutils" ] 226 } 227 228 if (build_variant == "root") { 229 defines += [ "SDC_TEST_ENABLE" ] 230 } 231 232 external_deps = [ 233 "c_utils:utils", 234 "hilog:libhilog", 235 "ipc:ipc_single", 236 "safwk:system_ability_fwk", 237 "samgr:samgr_proxy", 238 ] 239 240 subsystem_name = "filemanagement" 241 part_name = "storage_service" 242 install_enable = true 243} 244 245declare_args() { 246 storage_service_fstools = true 247} 248 249ohos_shared_library("storage_common_utils") { 250 branch_protector_ret = "pac_ret" 251 sanitize = { 252 integer_overflow = true 253 ubsan = true 254 boundary_sanitize = true 255 cfi = true 256 cfi_cross_dso = true 257 debug = false 258 } 259 260 include_dirs = [ 261 "./include", 262 "./include/utils", 263 "../common/include", 264 ] 265 266 defines = [ 267 "STORAGE_LOG_TAG = \"StorageCommonUtils\"", 268 "LOG_DOMAIN = 0xD004301", 269 ] 270 271 cflags = [ 272 "-D_FORTIFY_SOURCE=2", 273 "-fstack-protector-strong", 274 ] 275 276 sources = [ 277 "./utils/disk_utils.cpp", 278 "./utils/file_utils.cpp", 279 "./utils/hi_audit.cpp", 280 "./utils/mount_argument_utils.cpp", 281 "./utils/set_flag_utils.cpp", 282 "./utils/storage_radar.cpp", 283 "./utils/string_utils.cpp", 284 "./utils/zip_util.cpp", 285 ] 286 287 external_deps = [ 288 "c_utils:utils", 289 "hilog:libhilog", 290 "hisysevent:libhisysevent", 291 "zlib:shared_libz", 292 ] 293 294 if (build_selinux) { 295 defines += [ "USE_LIBRESTORECON" ] 296 297 external_deps += [ "selinux_adapter:librestorecon" ] 298 } 299 300 subsystem_name = "filemanagement" 301 part_name = "storage_service" 302 install_enable = true 303} 304 305ohos_prebuilt_etc("usb_config.para") { 306 source = "usb_config.para" 307 part_name = "storage_service" 308 subsystem_name = "filemanagement" 309 module_install_dir = "etc/param" 310} 311 312ohos_prebuilt_etc("usb_config.para.dac") { 313 source = "usb_config.para.dac" 314 part_name = "storage_service" 315 subsystem_name = "filemanagement" 316 module_install_dir = "etc/param" 317} 318 319group("storage_daemon_usb_param") { 320 deps = [ 321 ":usb_config.para", 322 ":usb_config.para.dac", 323 ] 324} 325 326group("storage_daemon_third_party") { 327 deps = [] 328 if (storage_service_external_storage_manager && storage_service_fstools) { 329 external_deps = [ 330 "FreeBSD:fsck_msdos", 331 "FreeBSD:newfs_msdos", 332 "e2fsprogs:blkid", 333 "e2fsprogs:libext2_blkid", 334 "e2fsprogs:libext2_com_err", 335 "e2fsprogs:libext2fs", 336 "exfatprogs:exfatlabel", 337 "exfatprogs:fsck.exfat", 338 "exfatprogs:mkfs.exfat", 339 "gptfdisk:sgdisk", 340 "ntfs-3g:fsck.ntfs", 341 "ntfs-3g:mount.ntfs", 342 "ntfs-3g:ntfslabel", 343 ] 344 } 345 external_deps += [ 346 "f2fs-tools:fsck.f2fs", 347 "f2fs-tools:libf2fs", 348 "f2fs-tools:mkfs.f2fs", 349 ] 350} 351 352group("storage_daemon_unit_test") { 353 testonly = true 354 deps = [ 355 "client/test:storage_daemon_client_test", 356 "crypto/test/crypto_test:crypto_test", 357 "crypto/test/fscrypt_key_v1_ext_test:fscrypt_key_v1_ext_test", 358 "crypto/test/huks_master_test:huks_master_test", 359 "crypto/test/iam_client_test:iam_client_test", 360 "crypto/test/iam_client_user_auth_framework_test:iam_client_user_auth_framework_test", 361 "crypto/test/key_backup_test:key_backup_test", 362 "crypto/test/key_manager_test:key_manager_test", 363 "file_sharing/test:file_sharing_test", 364 "ipc/test:storage_daemon_ipc_test", 365 "quota/test:storage_daemon_quota_test", 366 "user/test:storage_daemon_user_test", 367 "utils/test:storage_daemon_utils_test", 368 ] 369 370 if (storage_service_user_crypto_manager) { 371 deps += [ 372 "crypto/test:crypto_test", 373 "crypto/test/fscrypt_v1_test:fscrypt_key_v1_test", 374 "crypto/test/fscrypt_v2_test:fscrypt_key_v2_test", 375 ] 376 } 377 378 if (storage_service_external_storage_manager) { 379 deps += [ 380 "disk/test:storage_daemon_disk_test", 381 "netlink/test:storage_daemon_netlink_test", 382 "volume/test:storage_daemon_volume_test", 383 ] 384 } 385} 386