# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//build/ohos.gni") import("//foundation/filemanagement/storage_service/storage_service_aafwk.gni") ## Install storage_daemon.cfg to /system/etc/init/storage_daemon.cfg {{{ ohos_prebuilt_etc("storage_daemon_cfg") { source = "storage_daemon.cfg" relative_install_dir = "init" part_name = "storage_service" subsystem_name = "filemanagement" } ## Install storage_daemon.cfg to /system/etc/init/storage_daemon.cfg }}} config("storage_daemon_config") { include_dirs = [ "include", "../storage_manager/include", "${storage_interface_path}/innerkits/storage_manager/native", "../common/include", ] } ## Install disk_config to /system/etc/storage_daemon/disk_config {{{ ohos_prebuilt_etc("storage_daemon_disk_config") { source = "disk_config" relative_install_dir = "storage_daemon" part_name = "storage_service" subsystem_name = "filemanagement" } declare_args() { storage_service_user_file_sharing = true } ohos_executable("storage_daemon") { branch_protector_ret = "pac_ret" sanitize = { integer_overflow = true ubsan = true boundary_sanitize = true cfi = true cfi_cross_dso = true debug = false } sources = [ "ipc/src/storage_daemon.cpp", "ipc/src/storage_daemon_stub.cpp", "ipc/src/storage_manager_client.cpp", "main.cpp", "quota/quota_manager.cpp", "user/src/mount_manager.cpp", "user/src/user_manager.cpp", "utils/disk_utils.cpp", "utils/mount_argument_utils.cpp", ] defines = [ "STORAGE_LOG_TAG = \"StorageDaemon\"", "LOG_DOMAIN = 0xD004301", "KMSG_LOG", ] if (storage_service_user_file_sharing) { defines += [ "USER_FILE_SHARING" ] sources += [ "file_sharing/src/acl.cpp", "file_sharing/src/file_sharing.cpp", "file_sharing/src/setacl.cpp", ] } if (storage_service_external_storage_manager) { defines += [ "EXTERNAL_STORAGE_MANAGER" ] sources += [ "disk/src/disk_config.cpp", "disk/src/disk_info.cpp", "disk/src/disk_manager.cpp", "netlink/src/netlink_data.cpp", "netlink/src/netlink_handler.cpp", "netlink/src/netlink_listener.cpp", "netlink/src/netlink_manager.cpp", "volume/src/external_volume_info.cpp", "volume/src/process.cpp", "volume/src/volume_info.cpp", "volume/src/volume_manager.cpp", ] } configs = [ ":storage_daemon_config" ] deps = [ ":sdc", ":storage_common_utils", "${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy", ] external_deps = [ "ability_base:base", "ability_base:want", "ability_base:zuri", "app_file_service:fileshare_native", "app_file_service:fileuri_native", "app_file_service:sandbox_helper_native", "bounds_checking_function:libsec_shared", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", "eventhandler:libeventhandler", "hilog:libhilog", "hisysevent:libhisysevent", "init:libbegetutil", "ipc:ipc_single", "os_account:os_account_innerkits", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] if (storage_service_user_crypto_manager) { defines += [ "USER_CRYPTO_MANAGER", "USER_CRYPTO_MIGRATE_KEY", ] deps += [ "crypto:libsdcrypto", "libfscrypt:libfscryptutils", ] external_deps += [ "huks:libhukssdk" ] } if (enable_user_auth_framework) { defines += [ "USER_AUTH_FRAMEWORK" ] external_deps += [ "user_auth_framework:userauth_client" ] } if (storage_service_dfs_service) { defines += [ "DFS_SERVICE" ] external_deps += [ "dfs_service:cloud_daemon_kit_inner" ] } if (build_selinux) { defines += [ "USE_LIBRESTORECON" ] external_deps += [ "selinux_adapter:librestorecon" ] } if (enable_screenlock_manager) { defines += [ "ENABLE_SCREENLOCK_MANAGER" ] external_deps += [ "screenlock_mgr:screenlock_client" ] } ldflags = [ "-Wl,-z,max-page-size=4096", "-Wl,-z,separate-code", ] subsystem_name = "filemanagement" part_name = "storage_service" install_enable = true } config("sdc_config") { include_dirs = [ "include", "../common/include", "client/include", "../../interfaces/innerkits/storage_manager/native", "../storage_manager/include", ] } ohos_executable("sdc") { branch_protector_ret = "pac_ret" sanitize = { integer_overflow = true ubsan = true boundary_sanitize = true cfi = true cfi_cross_dso = true debug = false } sources = [ "client/storage_daemon_client.cpp", "ipc/src/storage_daemon_proxy.cpp", "sdc.cpp", ] defines = [ "STORAGE_LOG_TAG = \"StorageDaemon\"", "LOG_DOMAIN = 0xD004301", "KMSG_LOG", ] configs = [ ":sdc_config" ] deps = [ ":storage_common_utils", "${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy", ] if (storage_service_user_crypto_manager) { defines += [ "USER_CRYPTO_MANAGER" ] deps += [ "libfscrypt:libfscryptutils" ] } if (build_variant == "root") { defines += [ "SDC_TEST_ENABLE" ] } external_deps = [ "c_utils:utils", "hilog:libhilog", "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] subsystem_name = "filemanagement" part_name = "storage_service" install_enable = true } declare_args() { storage_service_fstools = true } ohos_shared_library("storage_common_utils") { branch_protector_ret = "pac_ret" sanitize = { integer_overflow = true ubsan = true boundary_sanitize = true cfi = true cfi_cross_dso = true debug = false } include_dirs = [ "./include", "../common/include", ] defines = [ "STORAGE_LOG_TAG = \"StorageCommonUtils\"", "LOG_DOMAIN = 0xD004301", ] cflags = [ "-D_FORTIFY_SOURCE=2", "-fstack-protector-strong", ] sources = [ "./utils/disk_utils.cpp", "./utils/file_utils.cpp", "./utils/mount_argument_utils.cpp", "./utils/set_flag_utils.cpp", "./utils/storage_radar.cpp", "./utils/string_utils.cpp", ] external_deps = [ "c_utils:utils", "hilog:libhilog", "hisysevent:libhisysevent", ] if (build_selinux) { defines += [ "USE_LIBRESTORECON" ] external_deps += [ "selinux_adapter:librestorecon" ] } subsystem_name = "filemanagement" part_name = "storage_service" install_enable = true } ohos_prebuilt_etc("usb_config.para") { source = "usb_config.para" part_name = "storage_service" subsystem_name = "filemanagement" module_install_dir = "etc/param" } ohos_prebuilt_etc("usb_config.para.dac") { source = "usb_config.para.dac" part_name = "storage_service" subsystem_name = "filemanagement" module_install_dir = "etc/param" } group("storage_daemon_usb_param") { deps = [ ":usb_config.para", ":usb_config.para.dac", ] } group("storage_daemon_third_party") { deps = [] if (storage_service_external_storage_manager && storage_service_fstools) { external_deps = [ "FreeBSD:fsck_msdos", "FreeBSD:newfs_msdos", "e2fsprogs:blkid", "e2fsprogs:libext2_blkid", "e2fsprogs:libext2_com_err", "e2fsprogs:libext2fs", "exfatprogs:exfatlabel", "exfatprogs:fsck.exfat", "exfatprogs:mkfs.exfat", "gptfdisk:sgdisk", "ntfs-3g:fsck.ntfs", "ntfs-3g:mount.ntfs", "ntfs-3g:ntfslabel", ] } external_deps += [ "f2fs-tools:fsck.f2fs", "f2fs-tools:libf2fs", "f2fs-tools:mkfs.f2fs", ] } group("storage_daemon_unit_test") { testonly = true deps = [ "client/test:storage_daemon_client_test", "crypto/test/fscrypt_key_v1_ext_test:fscrypt_key_v1_ext_test", "crypto/test/iam_client_test:iam_client_test", "crypto/test/iam_client_user_auth_framework_test:iam_client_user_auth_framework_test", "crypto/test/key_manager_test:key_manager_test", "file_sharing/test:file_sharing_test", "ipc/test:storage_daemon_ipc_test", "quota/test:storage_daemon_quota_test", "user/test:storage_daemon_user_test", "utils/test:storage_daemon_utils_test", ] if (storage_service_user_crypto_manager) { deps += [ "crypto/test/fscrypt_v2_test:fscrypt_key_v2_test" ] } if (storage_service_external_storage_manager) { deps += [ "disk/test:storage_daemon_disk_test", "netlink/test:storage_daemon_netlink_test", "volume/test:storage_daemon_volume_test", ] } }