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