1cb7eb8c9Sopenharmony_ci# Copyright (c) 2021 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_ci
17cb7eb8c9Sopenharmony_ciconfig("compiler_configs") {
18cb7eb8c9Sopenharmony_ci  visibility = [ ":*" ]
19cb7eb8c9Sopenharmony_ci  visibility += [
20cb7eb8c9Sopenharmony_ci    "${distributedfile_path}/services/*",
21cb7eb8c9Sopenharmony_ci    "${distributedfile_path}/test/moduletest/*",
22cb7eb8c9Sopenharmony_ci  ]
23cb7eb8c9Sopenharmony_ci
24cb7eb8c9Sopenharmony_ci  cflags = [
25cb7eb8c9Sopenharmony_ci    "-Wall",
26cb7eb8c9Sopenharmony_ci    "-Werror",
27cb7eb8c9Sopenharmony_ci    "-Wdate-time",
28cb7eb8c9Sopenharmony_ci    "-Wfloat-equal",
29cb7eb8c9Sopenharmony_ci    "-Wshadow",
30cb7eb8c9Sopenharmony_ci    "-Wformat=2",
31cb7eb8c9Sopenharmony_ci    "-ffunction-sections",
32cb7eb8c9Sopenharmony_ci    "-Os",
33cb7eb8c9Sopenharmony_ci  ]
34cb7eb8c9Sopenharmony_ci  configs = [ "//build/config/compiler:exceptions" ]
35cb7eb8c9Sopenharmony_ci
36cb7eb8c9Sopenharmony_ci  cflags_cc = [
37cb7eb8c9Sopenharmony_ci    "-fvisibility-inlines-hidden",
38cb7eb8c9Sopenharmony_ci    "-Os",
39cb7eb8c9Sopenharmony_ci  ]
40cb7eb8c9Sopenharmony_ci
41cb7eb8c9Sopenharmony_ci  defines = [
42cb7eb8c9Sopenharmony_ci    "LOG_DOMAIN=0xD001600",
43cb7eb8c9Sopenharmony_ci    "LOG_LEVEL=INFO",
44cb7eb8c9Sopenharmony_ci  ]
45cb7eb8c9Sopenharmony_ci}
46cb7eb8c9Sopenharmony_ci
47cb7eb8c9Sopenharmony_ciconfig("utils_public_config") {
48cb7eb8c9Sopenharmony_ci  include_dirs = [
49cb7eb8c9Sopenharmony_ci    "inner_api",
50cb7eb8c9Sopenharmony_ci    "load/include",
51cb7eb8c9Sopenharmony_ci    "log/include",
52cb7eb8c9Sopenharmony_ci    "work/include",
53cb7eb8c9Sopenharmony_ci    "system/include",
54cb7eb8c9Sopenharmony_ci  ]
55cb7eb8c9Sopenharmony_ci}
56cb7eb8c9Sopenharmony_ci
57cb7eb8c9Sopenharmony_ciconfig("optimize-size") {
58cb7eb8c9Sopenharmony_ci  cflags = [
59cb7eb8c9Sopenharmony_ci    "-fdata-sections",
60cb7eb8c9Sopenharmony_ci    "-ffunction-sections",
61cb7eb8c9Sopenharmony_ci    "-Oz",
62cb7eb8c9Sopenharmony_ci  ]
63cb7eb8c9Sopenharmony_ci  cflags_cc = [
64cb7eb8c9Sopenharmony_ci    "-fvisibility-inlines-hidden",
65cb7eb8c9Sopenharmony_ci    "-Oz",
66cb7eb8c9Sopenharmony_ci  ]
67cb7eb8c9Sopenharmony_ci}
68cb7eb8c9Sopenharmony_ci
69cb7eb8c9Sopenharmony_ciohos_shared_library("libdistributedfileutils") {
70cb7eb8c9Sopenharmony_ci  branch_protector_ret = "pac_ret"
71cb7eb8c9Sopenharmony_ci  configs = [ ":optimize-size" ]
72cb7eb8c9Sopenharmony_ci  sanitize = {
73cb7eb8c9Sopenharmony_ci    integer_overflow = true
74cb7eb8c9Sopenharmony_ci    ubsan = true
75cb7eb8c9Sopenharmony_ci    boundary_sanitize = true
76cb7eb8c9Sopenharmony_ci    cfi = true
77cb7eb8c9Sopenharmony_ci    cfi_cross_dso = true
78cb7eb8c9Sopenharmony_ci    debug = false
79cb7eb8c9Sopenharmony_ci  }
80cb7eb8c9Sopenharmony_ci  sources = [
81cb7eb8c9Sopenharmony_ci    "cloud_disk/src/cloud_file_utils.cpp",
82cb7eb8c9Sopenharmony_ci    "dfx/src/xcollie_helper.cpp",
83cb7eb8c9Sopenharmony_ci    "ffrt/src/ffrt_timer.cpp",
84cb7eb8c9Sopenharmony_ci    "load/src/plugin_loader.cpp",
85cb7eb8c9Sopenharmony_ci    "log/src/dfs_error.cpp",
86cb7eb8c9Sopenharmony_ci    "log/src/utils_log.cpp",
87cb7eb8c9Sopenharmony_ci    "preference/src/cloud_pref_impl.cpp",
88cb7eb8c9Sopenharmony_ci    "system/src/dfsu_access_token_helper.cpp",
89cb7eb8c9Sopenharmony_ci    "system/src/dfsu_fd_guard.cpp",
90cb7eb8c9Sopenharmony_ci    "system/src/dfsu_memory_guard.cpp",
91cb7eb8c9Sopenharmony_ci    "system/src/dfsu_mount_argument_descriptors.cpp",
92cb7eb8c9Sopenharmony_ci    "system/src/dfsu_timer.cpp",
93cb7eb8c9Sopenharmony_ci    "system/src/sys_utils.cpp",
94cb7eb8c9Sopenharmony_ci    "system/src/utils_directory.cpp",
95cb7eb8c9Sopenharmony_ci    "work/src/async_work.cpp",
96cb7eb8c9Sopenharmony_ci  ]
97cb7eb8c9Sopenharmony_ci
98cb7eb8c9Sopenharmony_ci  configs += [ "//build/config/compiler:exceptions" ]
99cb7eb8c9Sopenharmony_ci  public_configs = [ ":utils_public_config" ]
100cb7eb8c9Sopenharmony_ci
101cb7eb8c9Sopenharmony_ci  cflags = [
102cb7eb8c9Sopenharmony_ci    "-D_FORTIFY_SOURCE=2",
103cb7eb8c9Sopenharmony_ci    "-fstack-protector-strong",
104cb7eb8c9Sopenharmony_ci  ]
105cb7eb8c9Sopenharmony_ci
106cb7eb8c9Sopenharmony_ci  defines = [
107cb7eb8c9Sopenharmony_ci    "LOG_DOMAIN=0xD004308",
108cb7eb8c9Sopenharmony_ci    "LOG_TAG=\"distributedfile_utils\"",
109cb7eb8c9Sopenharmony_ci  ]
110cb7eb8c9Sopenharmony_ci
111cb7eb8c9Sopenharmony_ci  if (use_musl) {
112cb7eb8c9Sopenharmony_ci    if (musl_use_jemalloc && musl_use_jemalloc_dfx_intf) {
113cb7eb8c9Sopenharmony_ci      defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ]
114cb7eb8c9Sopenharmony_ci    }
115cb7eb8c9Sopenharmony_ci  }
116cb7eb8c9Sopenharmony_ci
117cb7eb8c9Sopenharmony_ci  external_deps = [
118cb7eb8c9Sopenharmony_ci    "ability_base:want",
119cb7eb8c9Sopenharmony_ci    "ability_base:zuri",
120cb7eb8c9Sopenharmony_ci    "ability_runtime:uri_permission_mgr",
121cb7eb8c9Sopenharmony_ci    "access_token:libaccesstoken_sdk",
122cb7eb8c9Sopenharmony_ci    "access_token:libtokenid_sdk",
123cb7eb8c9Sopenharmony_ci    "c_utils:utils",
124cb7eb8c9Sopenharmony_ci    "device_manager:devicemanagersdk",
125cb7eb8c9Sopenharmony_ci    "ffrt:libffrt",
126cb7eb8c9Sopenharmony_ci    "file_api:filemgmt_libhilog",
127cb7eb8c9Sopenharmony_ci    "file_api:filemgmt_libn",
128cb7eb8c9Sopenharmony_ci    "hilog:libhilog",
129cb7eb8c9Sopenharmony_ci    "hisysevent:libhisysevent",
130cb7eb8c9Sopenharmony_ci    "ipc:ipc_core",
131cb7eb8c9Sopenharmony_ci    "napi:ace_napi",
132cb7eb8c9Sopenharmony_ci    "preferences:native_preferences",
133cb7eb8c9Sopenharmony_ci  ]
134cb7eb8c9Sopenharmony_ci
135cb7eb8c9Sopenharmony_ci  if (cloudsync_service_hicollie_enable) {
136cb7eb8c9Sopenharmony_ci    external_deps += [ "hicollie:libhicollie" ]
137cb7eb8c9Sopenharmony_ci    defines += [ "HICOLLIE_ENABLE" ]
138cb7eb8c9Sopenharmony_ci  }
139cb7eb8c9Sopenharmony_ci
140cb7eb8c9Sopenharmony_ci  part_name = "dfs_service"
141cb7eb8c9Sopenharmony_ci  innerapi_tags = [ "platformsdk" ]
142cb7eb8c9Sopenharmony_ci  subsystem_name = "filemanagement"
143cb7eb8c9Sopenharmony_ci}
144cb7eb8c9Sopenharmony_ci
145cb7eb8c9Sopenharmony_ciconfig("dentry_public_config") {
146cb7eb8c9Sopenharmony_ci  include_dirs = [
147cb7eb8c9Sopenharmony_ci    "dentry/include",
148cb7eb8c9Sopenharmony_ci    "inner_api",
149cb7eb8c9Sopenharmony_ci    "system/include",
150cb7eb8c9Sopenharmony_ci  ]
151cb7eb8c9Sopenharmony_ci}
152cb7eb8c9Sopenharmony_ci
153cb7eb8c9Sopenharmony_ciohos_shared_library("libdistributedfiledentry") {
154cb7eb8c9Sopenharmony_ci  branch_protector_ret = "pac_ret"
155cb7eb8c9Sopenharmony_ci  configs = [ ":optimize-size" ]
156cb7eb8c9Sopenharmony_ci  sanitize = {
157cb7eb8c9Sopenharmony_ci    integer_overflow = true
158cb7eb8c9Sopenharmony_ci    ubsan = true
159cb7eb8c9Sopenharmony_ci    boundary_sanitize = true
160cb7eb8c9Sopenharmony_ci    cfi = true
161cb7eb8c9Sopenharmony_ci    cfi_cross_dso = true
162cb7eb8c9Sopenharmony_ci    debug = false
163cb7eb8c9Sopenharmony_ci  }
164cb7eb8c9Sopenharmony_ci
165cb7eb8c9Sopenharmony_ci  sources = [
166cb7eb8c9Sopenharmony_ci    "dentry/src/file_utils.cpp",
167cb7eb8c9Sopenharmony_ci    "dentry/src/meta_file.cpp",
168cb7eb8c9Sopenharmony_ci    "dentry/src/meta_file_clouddisk.cpp",
169cb7eb8c9Sopenharmony_ci    "system/src/utils_directory.cpp",
170cb7eb8c9Sopenharmony_ci  ]
171cb7eb8c9Sopenharmony_ci
172cb7eb8c9Sopenharmony_ci  public_configs = [ ":dentry_public_config" ]
173cb7eb8c9Sopenharmony_ci
174cb7eb8c9Sopenharmony_ci  cflags = [
175cb7eb8c9Sopenharmony_ci    "-D_FORTIFY_SOURCE=2",
176cb7eb8c9Sopenharmony_ci    "-fstack-protector-strong",
177cb7eb8c9Sopenharmony_ci  ]
178cb7eb8c9Sopenharmony_ci
179cb7eb8c9Sopenharmony_ci  deps = [ "${utils_path}:libdistributedfileutils" ]
180cb7eb8c9Sopenharmony_ci
181cb7eb8c9Sopenharmony_ci  external_deps = [
182cb7eb8c9Sopenharmony_ci    "c_utils:utils",
183cb7eb8c9Sopenharmony_ci    "device_manager:devicemanagersdk",
184cb7eb8c9Sopenharmony_ci    "hilog:libhilog",
185cb7eb8c9Sopenharmony_ci    "hisysevent:libhisysevent",
186cb7eb8c9Sopenharmony_ci  ]
187cb7eb8c9Sopenharmony_ci
188cb7eb8c9Sopenharmony_ci  defines = [
189cb7eb8c9Sopenharmony_ci    "LOG_DOMAIN=0xD004307",
190cb7eb8c9Sopenharmony_ci    "LOG_TAG=\"CLOUDSYNC_SA\"",
191cb7eb8c9Sopenharmony_ci  ]
192cb7eb8c9Sopenharmony_ci
193cb7eb8c9Sopenharmony_ci  if (cloudsync_service_hicollie_enable) {
194cb7eb8c9Sopenharmony_ci    external_deps += [ "hicollie:libhicollie" ]
195cb7eb8c9Sopenharmony_ci    defines += [ "HICOLLIE_ENABLE" ]
196cb7eb8c9Sopenharmony_ci  }
197cb7eb8c9Sopenharmony_ci
198cb7eb8c9Sopenharmony_ci  part_name = "dfs_service"
199cb7eb8c9Sopenharmony_ci  subsystem_name = "filemanagement"
200cb7eb8c9Sopenharmony_ci}
201cb7eb8c9Sopenharmony_ci
202cb7eb8c9Sopenharmony_ciconfig("utils_lite_public_config") {
203cb7eb8c9Sopenharmony_ci  include_dirs = [
204cb7eb8c9Sopenharmony_ci    "dentry/include",
205cb7eb8c9Sopenharmony_ci    "inner_api",
206cb7eb8c9Sopenharmony_ci    "load/include",
207cb7eb8c9Sopenharmony_ci    "log/include",
208cb7eb8c9Sopenharmony_ci    "system/include",
209cb7eb8c9Sopenharmony_ci  ]
210cb7eb8c9Sopenharmony_ci}
211cb7eb8c9Sopenharmony_ci
212cb7eb8c9Sopenharmony_ciohos_shared_library("libdistributedfileutils_lite") {
213cb7eb8c9Sopenharmony_ci  branch_protector_ret = "pac_ret"
214cb7eb8c9Sopenharmony_ci  configs = [ ":optimize-size" ]
215cb7eb8c9Sopenharmony_ci  sanitize = {
216cb7eb8c9Sopenharmony_ci    integer_overflow = true
217cb7eb8c9Sopenharmony_ci    ubsan = true
218cb7eb8c9Sopenharmony_ci    boundary_sanitize = true
219cb7eb8c9Sopenharmony_ci    cfi = true
220cb7eb8c9Sopenharmony_ci    cfi_cross_dso = true
221cb7eb8c9Sopenharmony_ci    debug = false
222cb7eb8c9Sopenharmony_ci  }
223cb7eb8c9Sopenharmony_ci
224cb7eb8c9Sopenharmony_ci  sources = [
225cb7eb8c9Sopenharmony_ci    "cloud_disk/src/cloud_file_utils.cpp",
226cb7eb8c9Sopenharmony_ci    "dentry/src/file_utils.cpp",
227cb7eb8c9Sopenharmony_ci    "dentry/src/meta_file.cpp",
228cb7eb8c9Sopenharmony_ci    "dentry/src/meta_file_clouddisk.cpp",
229cb7eb8c9Sopenharmony_ci    "dfx/src/xcollie_helper.cpp",
230cb7eb8c9Sopenharmony_ci    "ffrt/src/ffrt_timer.cpp",
231cb7eb8c9Sopenharmony_ci    "load/src/plugin_loader.cpp",
232cb7eb8c9Sopenharmony_ci    "log/src/dfs_error.cpp",
233cb7eb8c9Sopenharmony_ci    "log/src/utils_log.cpp",
234cb7eb8c9Sopenharmony_ci    "system/src/dfsu_memory_guard.cpp",
235cb7eb8c9Sopenharmony_ci    "system/src/utils_directory.cpp",
236cb7eb8c9Sopenharmony_ci  ]
237cb7eb8c9Sopenharmony_ci
238cb7eb8c9Sopenharmony_ci  configs += [ "//build/config/compiler:exceptions" ]
239cb7eb8c9Sopenharmony_ci  public_configs = [ ":utils_lite_public_config" ]
240cb7eb8c9Sopenharmony_ci
241cb7eb8c9Sopenharmony_ci  cflags = [
242cb7eb8c9Sopenharmony_ci    "-D_FORTIFY_SOURCE=2",
243cb7eb8c9Sopenharmony_ci    "-fstack-protector-strong",
244cb7eb8c9Sopenharmony_ci  ]
245cb7eb8c9Sopenharmony_ci
246cb7eb8c9Sopenharmony_ci  defines = [
247cb7eb8c9Sopenharmony_ci    "LOG_DOMAIN=0xD004308",
248cb7eb8c9Sopenharmony_ci    "LOG_TAG=\"CloudFileDaemon\"",
249cb7eb8c9Sopenharmony_ci  ]
250cb7eb8c9Sopenharmony_ci
251cb7eb8c9Sopenharmony_ci  deps = []
252cb7eb8c9Sopenharmony_ci
253cb7eb8c9Sopenharmony_ci  external_deps = [
254cb7eb8c9Sopenharmony_ci    "c_utils:utils",
255cb7eb8c9Sopenharmony_ci    "device_manager:devicemanagersdk",
256cb7eb8c9Sopenharmony_ci    "ffrt:libffrt",
257cb7eb8c9Sopenharmony_ci    "hilog:libhilog",
258cb7eb8c9Sopenharmony_ci    "hisysevent:libhisysevent",
259cb7eb8c9Sopenharmony_ci  ]
260cb7eb8c9Sopenharmony_ci
261cb7eb8c9Sopenharmony_ci  if (use_musl) {
262cb7eb8c9Sopenharmony_ci    if (musl_use_jemalloc && musl_use_jemalloc_dfx_intf) {
263cb7eb8c9Sopenharmony_ci      defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ]
264cb7eb8c9Sopenharmony_ci    }
265cb7eb8c9Sopenharmony_ci  }
266cb7eb8c9Sopenharmony_ci
267cb7eb8c9Sopenharmony_ci  if (cloudsync_service_hicollie_enable) {
268cb7eb8c9Sopenharmony_ci    external_deps += [ "hicollie:libhicollie" ]
269cb7eb8c9Sopenharmony_ci    defines += [ "HICOLLIE_ENABLE" ]
270cb7eb8c9Sopenharmony_ci  }
271cb7eb8c9Sopenharmony_ci
272cb7eb8c9Sopenharmony_ci  part_name = "dfs_service"
273cb7eb8c9Sopenharmony_ci  innerapi_tags = [ "platformsdk" ]
274cb7eb8c9Sopenharmony_ci  subsystem_name = "filemanagement"
275cb7eb8c9Sopenharmony_ci}
276