1cb7eb8c9Sopenharmony_ci# Copyright (C) 2024 Huawei Device Co., Ltd.
2cb7eb8c9Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3cb7eb8c9Sopenharmony_ci# you may not use this file except in compliance with the License.
4cb7eb8c9Sopenharmony_ci# You may obtain a copy of the License at
5cb7eb8c9Sopenharmony_ci#
6cb7eb8c9Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
7cb7eb8c9Sopenharmony_ci#
8cb7eb8c9Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9cb7eb8c9Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10cb7eb8c9Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11cb7eb8c9Sopenharmony_ci# See the License for the specific language governing permissions and
12cb7eb8c9Sopenharmony_ci# limitations under the License.
13cb7eb8c9Sopenharmony_ci
14cb7eb8c9Sopenharmony_ciimport("//build/ohos.gni")
15cb7eb8c9Sopenharmony_ciimport("//foundation/filemanagement/dfs_service/distributedfile.gni")
16cb7eb8c9Sopenharmony_ciconfig("optimize-size") {
17cb7eb8c9Sopenharmony_ci  cflags = [
18cb7eb8c9Sopenharmony_ci    "-fdata-sections",
19cb7eb8c9Sopenharmony_ci    "-ffunction-sections",
20cb7eb8c9Sopenharmony_ci    "-Oz",
21cb7eb8c9Sopenharmony_ci  ]
22cb7eb8c9Sopenharmony_ci  cflags_cc = [
23cb7eb8c9Sopenharmony_ci    "-fvisibility-inlines-hidden",
24cb7eb8c9Sopenharmony_ci    "-Oz",
25cb7eb8c9Sopenharmony_ci  ]
26cb7eb8c9Sopenharmony_ci}
27cb7eb8c9Sopenharmony_ciohos_shared_library("cloudsync_sa") {
28cb7eb8c9Sopenharmony_ci  branch_protector_ret = "pac_ret"
29cb7eb8c9Sopenharmony_ci  configs = [ ":optimize-size" ]
30cb7eb8c9Sopenharmony_ci  sanitize = {
31cb7eb8c9Sopenharmony_ci    integer_overflow = true
32cb7eb8c9Sopenharmony_ci    ubsan = true
33cb7eb8c9Sopenharmony_ci    boundary_sanitize = true
34cb7eb8c9Sopenharmony_ci    cfi = true
35cb7eb8c9Sopenharmony_ci    cfi_cross_dso = true
36cb7eb8c9Sopenharmony_ci    debug = false
37cb7eb8c9Sopenharmony_ci  }
38cb7eb8c9Sopenharmony_ci  include_dirs = [
39cb7eb8c9Sopenharmony_ci    "include",
40cb7eb8c9Sopenharmony_ci    "include/cycle_task",
41cb7eb8c9Sopenharmony_ci    "include/cycle_task/tasks",
42cb7eb8c9Sopenharmony_ci    "include/transport",
43cb7eb8c9Sopenharmony_ci    "include/transport/softbus",
44cb7eb8c9Sopenharmony_ci    "${services_path}/cloudfiledaemon/include/cloud_disk",
45cb7eb8c9Sopenharmony_ci    "${innerkits_native_path}/cloudsync_kit_inner",
46cb7eb8c9Sopenharmony_ci  ]
47cb7eb8c9Sopenharmony_ci
48cb7eb8c9Sopenharmony_ci  cycle_task = [
49cb7eb8c9Sopenharmony_ci    "src/cycle_task/cycle_task.cpp",
50cb7eb8c9Sopenharmony_ci    "src/cycle_task/cycle_task_runner.cpp",
51cb7eb8c9Sopenharmony_ci    "src/cycle_task/tasks/optimize_storage_task.cpp",
52cb7eb8c9Sopenharmony_ci    "src/cycle_task/tasks/periodic_check_task.cpp",
53cb7eb8c9Sopenharmony_ci    "src/cycle_task/tasks/report_statistics_task.cpp",
54cb7eb8c9Sopenharmony_ci    "src/cycle_task/tasks/save_subscription_task.cpp",
55cb7eb8c9Sopenharmony_ci    "src/cycle_task/tasks/database_backup_task.cpp",
56cb7eb8c9Sopenharmony_ci  ]
57cb7eb8c9Sopenharmony_ci
58cb7eb8c9Sopenharmony_ci  transport = [
59cb7eb8c9Sopenharmony_ci    "src/transport/file_transfer_manager.cpp",
60cb7eb8c9Sopenharmony_ci    "src/transport/message_handler.cpp",
61cb7eb8c9Sopenharmony_ci    "src/transport/softbus/session_manager.cpp",
62cb7eb8c9Sopenharmony_ci    "src/transport/softbus/softbus_adapter.cpp",
63cb7eb8c9Sopenharmony_ci    "src/transport/softbus/softbus_session.cpp",
64cb7eb8c9Sopenharmony_ci  ]
65cb7eb8c9Sopenharmony_ci
66cb7eb8c9Sopenharmony_ci  sources = [
67cb7eb8c9Sopenharmony_ci    "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/cloud_sync_common.cpp",
68cb7eb8c9Sopenharmony_ci    "src/ipc/cloud_sync_service.cpp",
69cb7eb8c9Sopenharmony_ci    "src/ipc/cloud_sync_service_stub.cpp",
70cb7eb8c9Sopenharmony_ci    "src/ipc/download_asset_callback_manager.cpp",
71cb7eb8c9Sopenharmony_ci    "src/ipc/download_asset_callback_proxy.cpp",
72cb7eb8c9Sopenharmony_ci    "src/sync_rule/battery_status_listener.cpp",
73cb7eb8c9Sopenharmony_ci    "src/sync_rule/screen_status_listener.cpp",
74cb7eb8c9Sopenharmony_ci    "src/sync_rule/user_status_listener.cpp",
75cb7eb8c9Sopenharmony_ci  ]
76cb7eb8c9Sopenharmony_ci
77cb7eb8c9Sopenharmony_ci  sources += cycle_task
78cb7eb8c9Sopenharmony_ci  sources += transport
79cb7eb8c9Sopenharmony_ci
80cb7eb8c9Sopenharmony_ci  defines = [
81cb7eb8c9Sopenharmony_ci    "LOG_DOMAIN=0xD004307",
82cb7eb8c9Sopenharmony_ci    "LOG_TAG=\"CLOUDSYNC_SA\"",
83cb7eb8c9Sopenharmony_ci  ]
84cb7eb8c9Sopenharmony_ci
85cb7eb8c9Sopenharmony_ci  deps = [
86cb7eb8c9Sopenharmony_ci    "${clouddisk_database_path}:clouddisk_database",
87cb7eb8c9Sopenharmony_ci    "${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit",
88cb7eb8c9Sopenharmony_ci    "${utils_path}:libdistributedfiledentry",
89cb7eb8c9Sopenharmony_ci    "${utils_path}:libdistributedfileutils",
90cb7eb8c9Sopenharmony_ci  ]
91cb7eb8c9Sopenharmony_ci
92cb7eb8c9Sopenharmony_ci  external_deps = [
93cb7eb8c9Sopenharmony_ci    "ability_base:want",
94cb7eb8c9Sopenharmony_ci    "ability_base:zuri",
95cb7eb8c9Sopenharmony_ci    "ability_runtime:ability_manager",
96cb7eb8c9Sopenharmony_ci    "app_file_service:sandbox_helper_native",
97cb7eb8c9Sopenharmony_ci    "c_utils:utils",
98cb7eb8c9Sopenharmony_ci    "common_event_service:cesfwk_innerkits",
99cb7eb8c9Sopenharmony_ci    "dsoftbus:softbus_client",
100cb7eb8c9Sopenharmony_ci    "ffrt:libffrt",
101cb7eb8c9Sopenharmony_ci    "hilog:libhilog",
102cb7eb8c9Sopenharmony_ci    "hitrace:hitrace_meter",
103cb7eb8c9Sopenharmony_ci    "init:libbegetutil",
104cb7eb8c9Sopenharmony_ci    "ipc:ipc_single",
105cb7eb8c9Sopenharmony_ci    "libfuse:libfuse",
106cb7eb8c9Sopenharmony_ci    "netmanager_base:net_conn_manager_if",
107cb7eb8c9Sopenharmony_ci    "os_account:os_account_innerkits",
108cb7eb8c9Sopenharmony_ci    "safwk:system_ability_fwk",
109cb7eb8c9Sopenharmony_ci    "samgr:samgr_proxy",
110cb7eb8c9Sopenharmony_ci  ]
111cb7eb8c9Sopenharmony_ci
112cb7eb8c9Sopenharmony_ci  if (cloudsync_service_hicollie_enable) {
113cb7eb8c9Sopenharmony_ci    external_deps += [ "hicollie:libhicollie" ]
114cb7eb8c9Sopenharmony_ci    defines += [ "HICOLLIE_ENABLE" ]
115cb7eb8c9Sopenharmony_ci  }
116cb7eb8c9Sopenharmony_ci
117cb7eb8c9Sopenharmony_ci  if (cloudsync_service_resource_schedule) {
118cb7eb8c9Sopenharmony_ci    external_deps += [ "resource_schedule_service:ressched_client" ]
119cb7eb8c9Sopenharmony_ci  }
120cb7eb8c9Sopenharmony_ci
121cb7eb8c9Sopenharmony_ci  use_exceptions = true
122cb7eb8c9Sopenharmony_ci  part_name = "dfs_service"
123cb7eb8c9Sopenharmony_ci  subsystem_name = "filemanagement"
124cb7eb8c9Sopenharmony_ci}
125cb7eb8c9Sopenharmony_ci
126cb7eb8c9Sopenharmony_ciohos_static_library("cloudsync_sa_static") {
127cb7eb8c9Sopenharmony_ci  branch_protector_ret = "pac_ret"
128cb7eb8c9Sopenharmony_ci  sanitize = {
129cb7eb8c9Sopenharmony_ci    integer_overflow = true
130cb7eb8c9Sopenharmony_ci    ubsan = true
131cb7eb8c9Sopenharmony_ci    boundary_sanitize = true
132cb7eb8c9Sopenharmony_ci    cfi = true
133cb7eb8c9Sopenharmony_ci    cfi_cross_dso = true
134cb7eb8c9Sopenharmony_ci    debug = false
135cb7eb8c9Sopenharmony_ci  }
136cb7eb8c9Sopenharmony_ci  include_dirs = [
137cb7eb8c9Sopenharmony_ci    "include",
138cb7eb8c9Sopenharmony_ci    "include/cycle_task",
139cb7eb8c9Sopenharmony_ci    "include/cycle_task/tasks",
140cb7eb8c9Sopenharmony_ci    "include/transport",
141cb7eb8c9Sopenharmony_ci    "include/transport/softbus",
142cb7eb8c9Sopenharmony_ci    "${clouddisk_database_path}/include",
143cb7eb8c9Sopenharmony_ci    "${services_path}/cloudfiledaemon/include/cloud_disk",
144cb7eb8c9Sopenharmony_ci    "${innerkits_native_path}/cloudsync_kit_inner",
145cb7eb8c9Sopenharmony_ci    "${media_library_path}/frameworks/innerkitsimpl/media_library_helper/include",
146cb7eb8c9Sopenharmony_ci    "${media_library_path}/interfaces/inner_api/media_library_helper/include",
147cb7eb8c9Sopenharmony_ci    "${media_library_path}/frameworks/services/media_thumbnail/include",
148cb7eb8c9Sopenharmony_ci    "${media_library_path}/frameworks/utils/include",
149cb7eb8c9Sopenharmony_ci    "${distributedfile_path}/test/unittests/cloudsync_sa/mock/",
150cb7eb8c9Sopenharmony_ci    "//third_party/e2fsprogs/e2fsprogs/lib",
151cb7eb8c9Sopenharmony_ci  ]
152cb7eb8c9Sopenharmony_ci
153cb7eb8c9Sopenharmony_ci  cycle_task = [
154cb7eb8c9Sopenharmony_ci    "src/cycle_task/cycle_task.cpp",
155cb7eb8c9Sopenharmony_ci    "src/cycle_task/cycle_task_runner.cpp",
156cb7eb8c9Sopenharmony_ci    "src/cycle_task/tasks/optimize_storage_task.cpp",
157cb7eb8c9Sopenharmony_ci    "src/cycle_task/tasks/periodic_check_task.cpp",
158cb7eb8c9Sopenharmony_ci    "src/cycle_task/tasks/report_statistics_task.cpp",
159cb7eb8c9Sopenharmony_ci    "src/cycle_task/tasks/save_subscription_task.cpp",
160cb7eb8c9Sopenharmony_ci    "src/cycle_task/tasks/database_backup_task.cpp",
161cb7eb8c9Sopenharmony_ci  ]
162cb7eb8c9Sopenharmony_ci
163cb7eb8c9Sopenharmony_ci  transport = [
164cb7eb8c9Sopenharmony_ci    "src/transport/file_transfer_manager.cpp",
165cb7eb8c9Sopenharmony_ci    "src/transport/message_handler.cpp",
166cb7eb8c9Sopenharmony_ci    "src/transport/softbus/session_manager.cpp",
167cb7eb8c9Sopenharmony_ci    "src/transport/softbus/softbus_adapter.cpp",
168cb7eb8c9Sopenharmony_ci    "src/transport/softbus/softbus_session.cpp",
169cb7eb8c9Sopenharmony_ci  ]
170cb7eb8c9Sopenharmony_ci
171cb7eb8c9Sopenharmony_ci  sources = [
172cb7eb8c9Sopenharmony_ci    "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/cloud_sync_common.cpp",
173cb7eb8c9Sopenharmony_ci    "${media_library_path}/frameworks/innerkitsimpl/media_library_helper/src/base_column.cpp",
174cb7eb8c9Sopenharmony_ci    "${media_library_path}/frameworks/innerkitsimpl/media_library_helper/src/media_column.cpp",
175cb7eb8c9Sopenharmony_ci    "${media_library_path}/frameworks/innerkitsimpl/media_library_helper/src/medialibrary_business_record_column.cpp",
176cb7eb8c9Sopenharmony_ci    "${media_library_path}/frameworks/innerkitsimpl/media_library_helper/src/photo_album_column.cpp",
177cb7eb8c9Sopenharmony_ci    "${media_library_path}/frameworks/innerkitsimpl/media_library_helper/src/photo_map_column.cpp",
178cb7eb8c9Sopenharmony_ci    "src/ipc/cloud_sync_service.cpp",
179cb7eb8c9Sopenharmony_ci    "src/ipc/cloud_sync_service_stub.cpp",
180cb7eb8c9Sopenharmony_ci    "src/ipc/download_asset_callback_manager.cpp",
181cb7eb8c9Sopenharmony_ci    "src/ipc/download_asset_callback_proxy.cpp",
182cb7eb8c9Sopenharmony_ci    "src/sync_rule/battery_status_listener.cpp",
183cb7eb8c9Sopenharmony_ci    "src/sync_rule/screen_status_listener.cpp",
184cb7eb8c9Sopenharmony_ci    "src/sync_rule/user_status_listener.cpp",
185cb7eb8c9Sopenharmony_ci  ]
186cb7eb8c9Sopenharmony_ci
187cb7eb8c9Sopenharmony_ci  sources += cycle_task
188cb7eb8c9Sopenharmony_ci  sources += transport
189cb7eb8c9Sopenharmony_ci
190cb7eb8c9Sopenharmony_ci  defines = [
191cb7eb8c9Sopenharmony_ci    "LOG_DOMAIN=0xD004307",
192cb7eb8c9Sopenharmony_ci    "LOG_TAG=\"CLOUDSYNC_SA\"",
193cb7eb8c9Sopenharmony_ci  ]
194cb7eb8c9Sopenharmony_ci
195cb7eb8c9Sopenharmony_ci  deps = [
196cb7eb8c9Sopenharmony_ci    "${clouddisk_database_path}:clouddisk_database",
197cb7eb8c9Sopenharmony_ci    "${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit",
198cb7eb8c9Sopenharmony_ci    "${utils_path}:libdistributedfiledentry",
199cb7eb8c9Sopenharmony_ci    "${utils_path}:libdistributedfileutils",
200cb7eb8c9Sopenharmony_ci    "//third_party/e2fsprogs:libext2_uuid",
201cb7eb8c9Sopenharmony_ci  ]
202cb7eb8c9Sopenharmony_ci
203cb7eb8c9Sopenharmony_ci  external_deps = [
204cb7eb8c9Sopenharmony_ci    "ability_base:want",
205cb7eb8c9Sopenharmony_ci    "ability_base:zuri",
206cb7eb8c9Sopenharmony_ci    "ability_runtime:ability_manager",
207cb7eb8c9Sopenharmony_ci    "ability_runtime:dataobs_manager",
208cb7eb8c9Sopenharmony_ci    "app_file_service:sandbox_helper_native",
209cb7eb8c9Sopenharmony_ci    "c_utils:utils",
210cb7eb8c9Sopenharmony_ci    "common_event_service:cesfwk_innerkits",
211cb7eb8c9Sopenharmony_ci    "dsoftbus:softbus_client",
212cb7eb8c9Sopenharmony_ci    "eventhandler:libeventhandler",
213cb7eb8c9Sopenharmony_ci    "ffrt:libffrt",
214cb7eb8c9Sopenharmony_ci    "hilog:libhilog",
215cb7eb8c9Sopenharmony_ci    "hitrace:hitrace_meter",
216cb7eb8c9Sopenharmony_ci    "init:libbegetutil",
217cb7eb8c9Sopenharmony_ci    "ipc:ipc_single",
218cb7eb8c9Sopenharmony_ci    "libfuse:libfuse",
219cb7eb8c9Sopenharmony_ci    "netmanager_base:net_conn_manager_if",
220cb7eb8c9Sopenharmony_ci    "os_account:os_account_innerkits",
221cb7eb8c9Sopenharmony_ci    "power_manager:powermgr_client",
222cb7eb8c9Sopenharmony_ci    "relational_store:native_rdb",
223cb7eb8c9Sopenharmony_ci    "safwk:system_ability_fwk",
224cb7eb8c9Sopenharmony_ci    "samgr:samgr_proxy",
225cb7eb8c9Sopenharmony_ci  ]
226cb7eb8c9Sopenharmony_ci
227cb7eb8c9Sopenharmony_ci  if (cloudsync_service_hicollie_enable) {
228cb7eb8c9Sopenharmony_ci    external_deps += [ "hicollie:libhicollie" ]
229cb7eb8c9Sopenharmony_ci    defines += [ "HICOLLIE_ENABLE" ]
230cb7eb8c9Sopenharmony_ci  }
231cb7eb8c9Sopenharmony_ci
232cb7eb8c9Sopenharmony_ci  deps +=
233cb7eb8c9Sopenharmony_ci      [ "${distributedfile_path}/adapter/cloud_adapter_example:cloud_adapter" ]
234cb7eb8c9Sopenharmony_ci
235cb7eb8c9Sopenharmony_ci  if (cloudsync_service_resource_schedule) {
236cb7eb8c9Sopenharmony_ci    external_deps += [ "resource_schedule_service:ressched_client" ]
237cb7eb8c9Sopenharmony_ci    defines += [ "CLOUDSYNC_SERVICE_RESOURCE_SCHEDULE" ]
238cb7eb8c9Sopenharmony_ci  }
239cb7eb8c9Sopenharmony_ci
240cb7eb8c9Sopenharmony_ci  if (cloudsync_service_power) {
241cb7eb8c9Sopenharmony_ci    external_deps += [ "battery_manager:batterysrv_client" ]
242cb7eb8c9Sopenharmony_ci
243cb7eb8c9Sopenharmony_ci    defines += [ "SUPPORT_POWER" ]
244cb7eb8c9Sopenharmony_ci  }
245cb7eb8c9Sopenharmony_ci
246cb7eb8c9Sopenharmony_ci  use_exceptions = true
247cb7eb8c9Sopenharmony_ci  part_name = "dfs_service"
248cb7eb8c9Sopenharmony_ci  subsystem_name = "filemanagement"
249cb7eb8c9Sopenharmony_ci}
250