• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2025 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/file_api/file_api.gni")
16
17ohos_shared_library("cj_file_fs_ffi") {
18  sanitize = {
19    integer_overflow = true
20    ubsan = true
21    boundary_sanitize = true
22    cfi = true
23    cfi_cross_dso = true
24    debug = false
25  }
26
27  defines = []
28  cflags = [
29    "-fvisibility=hidden",
30    "-fdata-sections",
31    "-ffunction-sections",
32    "-Oz",
33  ]
34  cflags_cc = [
35    "-fvisibility-inlines-hidden",
36    "-Oz",
37  ]
38  if (is_mingw || is_mac || is_linux) {
39    defines += [ "PREVIEW" ]
40  }
41
42  if (current_os == "ohos" && current_cpu == "x86_64") {
43    defines += [ "SIMULATOR" ]
44  }
45  if (is_ohos) {
46    defines += [ "OHOS_PLATFORM" ]
47    if (use_musl && !is_asan) {
48      defines += [ "HOOK_ENABLE" ]
49    }
50  } else if (is_mingw) {
51    defines += [ "WINDOWS_PLATFORM" ]
52    cflags_cc += [ "-std=c++17" ]
53  } else if (is_mac) {
54    defines += [ "MAC_PLATFORM" ]
55  } else if (is_linux) {
56    defines += [ "LINUX_PLATFORM" ]
57    cflags_cc += [ "-std=c++17" ]
58  } else if (is_arkui_x && target_os == "ios") {
59    defines += [ "IOS_PLATFORM" ]
60  }
61
62  include_dirs = [
63    "${src_path}/common",
64    "${src_path}/common/file_helper",
65    "${src_path}/mod_fs",
66    "${src_path}/mod_fs/class_file",
67    "${src_path}/mod_fs/class_randomaccessfile",
68    "${src_path}/mod_fs/class_readeriterator",
69    "${src_path}/mod_fs/class_stream",
70    "${src_path}/mod_fs/properties",
71    "${utils_path}/common/include",
72    "${utils_path}/filemgmt_libhilog",
73    "${utils_path}/filemgmt_libh",
74    "${utils_path}/filemgmt_libn/include",
75    "${file_api_path}/interfaces/kits/cj/src",
76    "${file_api_path}/interfaces/kits/native/remote_uri",
77    "${file_api_path}/interfaces/kits/native/task_signal",
78    "${file_api_path}/interfaces/kits/rust/include",
79  ]
80
81  if (!defined(defines)) {
82    defines = []
83  }
84
85  use_exceptions = true
86
87  if (product_name != "ohos-sdk") {
88    deps = [
89      "${file_api_path}/interfaces/kits/js:build_kits_js",
90      "${file_api_path}/interfaces/kits/js:fs",
91      "${file_api_path}/interfaces/kits/native:remote_uri_native",
92      "${file_api_path}/interfaces/kits/native:task_signal_native",
93      "${file_api_path}/interfaces/kits/rust:rust_file",
94      "${utils_path}/filemgmt_libhilog:filemgmt_libhilog",
95      "${utils_path}/filemgmt_libn:filemgmt_libn",
96    ]
97    external_deps = [
98      "ability_base:zuri",
99      "ability_runtime:ability_manager",
100      "ability_runtime:abilitykit_native",
101      "access_token:libtokenid_sdk",
102      "app_file_service:fileuri_native",
103      "bounds_checking_function:libsec_shared",
104      "bundle_framework:appexecfwk_base",
105      "bundle_framework:appexecfwk_core",
106      "c_utils:utils",
107      "data_share:datashare_common",
108      "data_share:datashare_consumer",
109      "dfs_service:distributed_file_daemon_kit_inner",
110      "hilog:libhilog",
111      "ipc:ipc_core",
112      "napi:ace_napi",
113      "napi:cj_bind_ffi",
114      "napi:cj_bind_native",
115      "samgr:samgr_proxy",
116    ]
117    sources = [
118      "../js/src/common/file_helper/fd_guard.cpp",
119      "../js/src/mod_fs/class_file/file_n_exporter.cpp",
120      "../js/src/mod_fs/class_stream/stream_n_exporter.cpp",
121      "../js/src/mod_fs/common_func.cpp",
122      "src/copy.cpp",
123      "src/copy_dir.cpp",
124      "src/copy_file.cpp",
125      "src/fdatasync.cpp",
126      "src/file_ffi.cpp",
127      "src/file_fs_ffi.cpp",
128      "src/file_fs_impl.cpp",
129      "src/file_impl.cpp",
130      "src/fsync.cpp",
131      "src/list_file.cpp",
132      "src/lseek.cpp",
133      "src/mkdtemp.cpp",
134      "src/move_file.cpp",
135      "src/randomAccessFile_impl.cpp",
136      "src/readerIterator_impl.cpp",
137      "src/stat_ffi.cpp",
138      "src/stream_ffi.cpp",
139      "src/stream_impl.cpp",
140      "src/symlink.cpp",
141      "src/task_signal_impl.cpp",
142      "src/translistener.cpp",
143      "src/uni_error.cpp",
144      "src/utils.cpp",
145      "src/watcher_impl.cpp",
146    ]
147  } else {
148    defines += [ "PREVIEWER" ]
149    sources = [ "src/file_fs_mock.cpp" ]
150    external_deps = [ "napi:cj_bind_ffi" ]
151  }
152
153  if (current_os == "ohos") {
154    defines += [ "OHOS_PLATFORM" ]
155  }
156
157  if (current_os == "mingw") {
158    defines += [ "WINDOWS_PLATFORM" ]
159  }
160
161  innerapi_tags = [ "platformsdk" ]
162  part_name = "file_api"
163  subsystem_name = "filemanagement"
164}
165
166ohos_shared_library("cj_statvfs_ffi") {
167  sanitize = {
168    integer_overflow = true
169    ubsan = true
170    boundary_sanitize = true
171    cfi = true
172    cfi_cross_dso = true
173    debug = false
174  }
175
176  defines = []
177  cflags = [
178    "-fvisibility=hidden",
179    "-fdata-sections",
180    "-ffunction-sections",
181    "-Oz",
182  ]
183  cflags_cc = [
184    "-fvisibility-inlines-hidden",
185    "-Oz",
186  ]
187  if (is_mingw || is_mac || is_linux) {
188    defines += [ "PREVIEW" ]
189  }
190
191  if (current_os == "ohos" && current_cpu == "x86_64") {
192    defines += [ "SIMULATOR" ]
193  }
194  if (is_ohos) {
195    defines += [ "OHOS_PLATFORM" ]
196    if (use_musl && !is_asan) {
197      defines += [ "HOOK_ENABLE" ]
198    }
199  } else if (is_mingw) {
200    defines += [ "WINDOWS_PLATFORM" ]
201    cflags_cc += [ "-std=c++17" ]
202  } else if (is_mac) {
203    defines += [ "MAC_PLATFORM" ]
204  } else if (is_linux) {
205    defines += [ "LINUX_PLATFORM" ]
206    cflags_cc += [ "-std=c++17" ]
207  } else if (is_arkui_x && target_os == "ios") {
208    defines += [ "IOS_PLATFORM" ]
209  }
210
211  include_dirs = [
212    "${src_path}/common",
213    "${src_path}/common/napi",
214    "${src_path}/common/napi/n_async",
215    "${src_path}/common/file_helper",
216    "${src_path}/mod_fs",
217    "${src_path}/mod_fs/class_randomaccessfile",
218    "${src_path}/mod_fs/class_readeriterator",
219    "${src_path}/mod_fs/properties",
220    "${utils_path}/common/include",
221    "${utils_path}/filemgmt_libhilog",
222    "${utils_path}/filemgmt_libh",
223    "${utils_path}/filemgmt_libn/include",
224    "${file_api_path}/interfaces/kits/cj/src",
225    "${file_api_path}/interfaces/kits/native/remote_uri",
226    "${file_api_path}/interfaces/kits/native/task_signal",
227    "${file_api_path}/interfaces/kits/rust/include",
228  ]
229
230  if (!defined(defines)) {
231    defines = []
232  }
233
234  use_exceptions = true
235
236  if (product_name != "ohos-sdk") {
237    deps = [
238      "${file_api_path}/interfaces/kits/js:build_kits_js",
239      "${file_api_path}/interfaces/kits/js:fs",
240      "${file_api_path}/interfaces/kits/native:remote_uri_native",
241      "${file_api_path}/interfaces/kits/native:task_signal_native",
242      "${file_api_path}/interfaces/kits/rust:rust_file",
243      "${utils_path}/filemgmt_libhilog:filemgmt_libhilog",
244      "${utils_path}/filemgmt_libn:filemgmt_libn",
245    ]
246    external_deps = [
247      "ability_base:zuri",
248      "ability_runtime:ability_manager",
249      "ability_runtime:abilitykit_native",
250      "access_token:libtokenid_sdk",
251      "app_file_service:fileuri_native",
252      "bounds_checking_function:libsec_shared",
253      "bundle_framework:appexecfwk_base",
254      "bundle_framework:appexecfwk_core",
255      "c_utils:utils",
256      "data_share:datashare_common",
257      "data_share:datashare_consumer",
258      "dfs_service:distributed_file_daemon_kit_inner",
259      "hilog:libhilog",
260      "ipc:ipc_core",
261      "napi:ace_napi",
262      "napi:cj_bind_ffi",
263      "napi:cj_bind_native",
264      "samgr:samgr_proxy",
265    ]
266    sources = [
267      "src/statvfs_ffi.cpp",
268      "src/statvfs_impl.cpp",
269      "src/uni_error.cpp",
270    ]
271  } else {
272    defines += [ "PREVIEWER" ]
273    external_deps = [ "napi:cj_bind_ffi" ]
274  }
275
276  if (current_os == "ohos") {
277    defines += [ "OHOS_PLATFORM" ]
278  }
279
280  if (current_os == "mingw") {
281    defines += [ "WINDOWS_PLATFORM" ]
282  }
283
284  innerapi_tags = [ "platformsdk" ]
285  part_name = "file_api"
286  subsystem_name = "filemanagement"
287}
288
289group("fs_ffi_packages") {
290  deps = [
291    ":cj_file_fs_ffi",
292    ":cj_statvfs_ffi",
293  ]
294}
295